commit a323fdb

Hubert Hirtz  ·  2020-08-01 12:23:28 +0000 UTC
parent c74ac4a
Add /quote command
2 files changed,  +17, -0
+2, -0
1@@ -229,6 +229,8 @@ func handleInput(s *irc.Session, buffer, content string) {
2 		}
3 
4 		s.PrivMsg(buffer, args)
5+	case "QUOTE":
6+		s.SendRaw(args)
7 	case "J", "JOIN":
8 		s.Join(args)
9 	case "PART":
+15, -0
 1@@ -85,6 +85,10 @@ type Channel struct {
 2 type action interface{}
 3 
 4 type (
 5+	actionSendRaw struct {
 6+		raw string
 7+	}
 8+
 9 	actionJoin struct {
10 		Channel string
11 	}
12@@ -220,6 +224,15 @@ func (s *Session) IsChannel(name string) bool {
13 	return strings.IndexAny(name, "#&") == 0 // TODO compute CHANTYPES
14 }
15 
16+func (s *Session) SendRaw(raw string) {
17+	s.acts <- actionSendRaw{raw}
18+}
19+
20+func (s *Session) sendRaw(act actionSendRaw) (err error) {
21+	err = s.send("%s\r\n", act.raw)
22+	return
23+}
24+
25 func (s *Session) Join(channel string) {
26 	s.acts <- actionJoin{channel}
27 }
28@@ -304,6 +317,8 @@ func (s *Session) run() {
29 		select {
30 		case act := <-s.acts:
31 			switch act := act.(type) {
32+			case actionSendRaw:
33+				err = s.sendRaw(act)
34 			case actionJoin:
35 				err = s.join(act)
36 			case actionPart: