From 93e3cda102be0870171ecd9ad0d6507566c7ffd1 Mon Sep 17 00:00:00 2001 From: brain Date: Sun, 22 Jan 2006 19:23:20 +0000 Subject: Added facility for servers to send KICK message (ew, i hate this crap) git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@2830 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/channels.cpp | 51 ++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 46 insertions(+), 5 deletions(-) (limited to 'src/channels.cpp') diff --git a/src/channels.cpp b/src/channels.cpp index 2b1fac5f2..9179c8002 100644 --- a/src/channels.cpp +++ b/src/channels.cpp @@ -451,6 +451,52 @@ chanrec* del_channel(userrec *user, const char* cname, const char* reason, bool return NULL; } +void server_kick_channel(userrec* user, chanrec* Ptr, char* reason, bool triggerevents) +{ + if ((!user) || (!Ptr) || (!reason)) + { + return; + } + + if (!has_channel(user,Ptr)) + { + /* Not on channel */ + return; + } + + if (triggerevents) + { + FOREACH_MOD(I_OnUserKick,OnUserKick(NULL,user,Ptr,reason)); + } + + for (unsigned int i =0; i < user->chans.size(); i++) + { + if (user->chans[i].channel) + if (!strcasecmp(user->chans[i].channel->name,Ptr->name)) + { + WriteChannelWithServ(Ptr,"KICK %s %s :%s",Ptr->name, user->nick, reason); + user->chans[i].uc_modes = 0; + user->chans[i].channel = NULL; + break; + } + } + + Ptr->DelUser((char*)user); + + if (!usercount(Ptr)) + { + chan_hash::iterator iter = chanlist.find(Ptr->name); + log(DEBUG,"del_channel: destroying channel: %s",Ptr->name); + /* kill the record */ + if (iter != chanlist.end()) + { + log(DEBUG,"del_channel: destroyed: %s",Ptr->name); + FOREACH_MOD(I_OnChannelDelete,OnChannelDelete(Ptr)); + delete Ptr; + chanlist.erase(iter); + } + } +} void kick_channel(userrec *src,userrec *user, chanrec *Ptr, char* reason) { @@ -460,11 +506,6 @@ void kick_channel(userrec *src,userrec *user, chanrec *Ptr, char* reason) return; } - if ((!Ptr) || (!user) || (!src)) - { - return; - } - log(DEBUG,"kick_channel: removing: %s %s %s",user->nick,Ptr->name,src->nick); if (!has_channel(user,Ptr)) -- cgit v1.2.3