diff options
author | Hubert Hirtz <hubert@hirtz.pm> | 2021-02-18 17:13:16 +0100 |
---|---|---|
committer | Hubert Hirtz <hubert@hirtz.pm> | 2021-02-18 17:25:31 +0100 |
commit | fc101c7f0aa0323ef97fd55db6534aa65f4831af (patch) | |
tree | 54f62f02f18e773103a9291a032008c198b50b6b /irc | |
parent | Recognize beginning of commands (diff) |
Add the QUIT command
Diffstat (limited to 'irc')
-rw-r--r-- | irc/states.go | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/irc/states.go b/irc/states.go index 87c2a06..9737565 100644 --- a/irc/states.go +++ b/irc/states.go @@ -96,6 +96,9 @@ type ( Channel string Topic string } + actionQuit struct { + Reason string + } actionPrivMsg struct { Target string @@ -390,6 +393,15 @@ func (s *Session) setTopic(act actionSetTopic) (err error) { return } +func (s *Session) Quit(reason string) { + s.acts <- actionQuit{reason} +} + +func (s *Session) quit(act actionQuit) (err error) { + err = s.send("QUIT :%s\r\n", act.Reason) + return +} + func (s *Session) PrivMsg(target, content string) { s.acts <- actionPrivMsg{target, content} } @@ -469,6 +481,8 @@ func (s *Session) run() { err = s.part(act) case actionSetTopic: err = s.setTopic(act) + case actionQuit: + err = s.quit(act) case actionPrivMsg: err = s.privMsg(act) case actionTyping: |