diff options
author | delthas <delthas@dille.cc> | 2022-11-22 11:10:05 +0100 |
---|---|---|
committer | delthas <delthas@dille.cc> | 2022-11-22 11:10:05 +0100 |
commit | c7d2032082d3f96dafbe92d774feb98b0fa0af4d (patch) | |
tree | 4fc489ebf3ab8c7072cd0032aaf6c41f7699657f | |
parent | Support irc URLs in the config addr (diff) |
Implement /MOTD
-rw-r--r-- | commands.go | 14 | ||||
-rw-r--r-- | irc/session.go | 4 |
2 files changed, 18 insertions, 0 deletions
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 |