diff --git a/server.go b/server.go index e2d429e..5aab0ef 100644 --- a/server.go +++ b/server.go @@ -255,7 +255,15 @@ func (srv *Server) channelJoin(nick, ch string) { srv.channelBroadcast(ch, irc.M(nick, "JOIN", ch, "")) } -func (srv *Server) channelPart(nick, ch string) { +func (srv *Server) channelPart(nick, ch, reason string) { + if _, exists := srv.channels[ch]; !exists { + return + } + if _, exists := srv.channels[ch][nick]; !exists { + return + } + srv.channelBroadcast(ch, irc.M(nick, "PART", ch, reason)) + delete(srv.channels[ch][nick]) } type SrvCommandHook struct { @@ -304,7 +312,7 @@ func srvHandleCmdJoin(srv *Server, msg *irc.Message) { } func srvHandleCmdPart(srv *Server, msg *irc.Message) { - srv.channelPart(msg.Pre, msg.Args[0]) + srv.channelPart(msg.Pre, msg.Args[0], msg.Trailing) } func srvHandleCmdOper(srv *Server, msg *irc.Message) {