channel part implemented

This commit is contained in:
Andreas Neue 2016-07-18 19:02:15 +02:00
parent 39816874d2
commit c4b4e47cdf
1 changed files with 10 additions and 2 deletions

View File

@ -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) {