From c7d2032082d3f96dafbe92d774feb98b0fa0af4d Mon Sep 17 00:00:00 2001 From: delthas Date: Tue, 22 Nov 2022 11:10:05 +0100 Subject: Implement /MOTD --- commands.go | 14 ++++++++++++++ irc/session.go | 4 ++++ 2 files changed, 18 insertions(+) diff --git a/commands.go b/commands.go index 132f914..55582a0 100644 --- a/commands.go +++ b/commands.go @@ -65,6 +65,10 @@ func init() { Desc: "send a message to the given target", Handle: commandDoMsg, }, + "MOTD": { + Desc: "show the message of the day (MOTD)", + Handle: commandDoMOTD, + }, "NAMES": { Desc: "show the member list of the current channel", Handle: commandDoNames, @@ -345,6 +349,16 @@ func commandDoMsg(app *App, args []string) (err error) { return commandSendMessage(app, target, content) } +func commandDoMOTD(app *App, args []string) (err error) { + netID, _ := app.win.CurrentBuffer() + s := app.sessions[netID] + if s == nil { + return errOffline + } + s.MOTD() + return nil +} + func commandDoNames(app *App, args []string) (err error) { netID, buffer := app.win.CurrentBuffer() s := app.sessions[netID] diff --git a/irc/session.go b/irc/session.go index 3706cad..04942ae 100644 --- a/irc/session.go +++ b/irc/session.go @@ -361,6 +361,10 @@ func (s *Session) ChangeNick(nick string) { s.out <- NewMessage("NICK", nick) } +func (s *Session) MOTD() { + s.out <- NewMessage("MOTD") +} + func (s *Session) Who(target string) { if s.whox { // only request what we need, to optimize server who cache hits and reduce traffic -- cgit v1.2.3