diff options
author | Hubert Hirtz <hubert@hirtz.pm> | 2020-10-19 14:25:14 +0200 |
---|---|---|
committer | Hubert Hirtz <hubert@hirtz.pm> | 2020-10-19 14:25:14 +0200 |
commit | 94b025d595b27f2b6ed3c6e52e518cc7dafe09c9 (patch) | |
tree | c2dd9da1f0238330e69e42e0beaf1205fa8f02dc /irc | |
parent | Show topic changes (diff) |
Handle KICK messages
Diffstat (limited to 'irc')
-rw-r--r-- | irc/states.go | 27 | ||||
-rw-r--r-- | irc/tokens.go | 2 |
2 files changed, 27 insertions, 2 deletions
diff --git a/irc/states.go b/irc/states.go index 5502dd0..4317369 100644 --- a/irc/states.go +++ b/irc/states.go @@ -700,7 +700,7 @@ func (s *Session) handle(msg Message) (err error) { for u := range c.Members { s.cleanUser(u) } - s.evts <- SelfPartEvent{Channel: msg.Params[0]} + s.evts <- SelfPartEvent{Channel: c.Name} } } else if c, ok := s.channels[channelCf]; ok { if u, ok := s.users[nickCf]; ok { @@ -715,6 +715,31 @@ func (s *Session) handle(msg Message) (err error) { } } } + case "KICK": + channelCf := s.Casemap(msg.Params[0]) + nickCf := s.Casemap(msg.Params[1]) + + if nickCf == s.nickCf { + if c, ok := s.channels[channelCf]; ok { + delete(s.channels, channelCf) + for u := range c.Members { + s.cleanUser(u) + } + s.evts <- SelfPartEvent{Channel: c.Name} + } + } else if c, ok := s.channels[channelCf]; ok { + if u, ok := s.users[nickCf]; ok { + delete(c.Members, u) + s.cleanUser(u) + s.typings.Done(channelCf, nickCf) + + s.evts <- UserPartEvent{ + User: u.Name.Copy(), + Channel: c.Name, + Time: msg.TimeOrNow(), + } + } + } case "QUIT": nickCf := s.Casemap(msg.Prefix.Name) diff --git a/irc/tokens.go b/irc/tokens.go index b09c884..1a4067e 100644 --- a/irc/tokens.go +++ b/irc/tokens.go @@ -311,7 +311,7 @@ func (msg *Message) IsValid() bool { return 8 <= len(msg.Params) case "JOIN", "NICK", "PART", "TAGMSG": return 1 <= len(msg.Params) && msg.Prefix != nil - case "PRIVMSG", "NOTICE", "TOPIC": + case "KICK", "PRIVMSG", "NOTICE", "TOPIC": return 2 <= len(msg.Params) && msg.Prefix != nil case "QUIT": return msg.Prefix != nil |