commit c7d2032

delthas  ·  2022-11-22 10:10:05 +0000 UTC
parent 68e1efc
Implement /MOTD
2 files changed,  +18, -0
+14, -0
 1@@ -65,6 +65,10 @@ func init() {
 2 			Desc:      "send a message to the given target",
 3 			Handle:    commandDoMsg,
 4 		},
 5+		"MOTD": {
 6+			Desc:   "show the message of the day (MOTD)",
 7+			Handle: commandDoMOTD,
 8+		},
 9 		"NAMES": {
10 			Desc:   "show the member list of the current channel",
11 			Handle: commandDoNames,
12@@ -345,6 +349,16 @@ func commandDoMsg(app *App, args []string) (err error) {
13 	return commandSendMessage(app, target, content)
14 }
15 
16+func commandDoMOTD(app *App, args []string) (err error) {
17+	netID, _ := app.win.CurrentBuffer()
18+	s := app.sessions[netID]
19+	if s == nil {
20+		return errOffline
21+	}
22+	s.MOTD()
23+	return nil
24+}
25+
26 func commandDoNames(app *App, args []string) (err error) {
27 	netID, buffer := app.win.CurrentBuffer()
28 	s := app.sessions[netID]
+4, -0
 1@@ -361,6 +361,10 @@ func (s *Session) ChangeNick(nick string) {
 2 	s.out <- NewMessage("NICK", nick)
 3 }
 4 
 5+func (s *Session) MOTD() {
 6+	s.out <- NewMessage("MOTD")
 7+}
 8+
 9 func (s *Session) Who(target string) {
10 	if s.whox {
11 		// only request what we need, to optimize server who cache hits and reduce traffic