From c4b4e47cdf12121e76e0e7ff29b96ec451b48db6 Mon Sep 17 00:00:00 2001 From: Andreas Neue Date: Mon, 18 Jul 2016 19:02:15 +0200 Subject: [PATCH] channel part implemented --- server.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) 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) {