Added support for part messages in the module API (and therefore between servers too)

git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@2815 e03df62e-2008-0410-955e-edbf42e46eb7
This commit is contained in:
brain 2006-01-17 21:39:35 +00:00
parent 7254428c00
commit 7e6dfdf211
7 changed files with 11 additions and 7 deletions

View File

@ -353,8 +353,9 @@ class Module : public classbase
* and the details of the channel they have left is available in the variable chanrec *channel * and the details of the channel they have left is available in the variable chanrec *channel
* @param user The user who is parting * @param user The user who is parting
* @param channel The channel being parted * @param channel The channel being parted
* @param partmessage The part message, or an empty string
*/ */
virtual void OnUserPart(userrec* user, chanrec* channel); virtual void OnUserPart(userrec* user, chanrec* channel, std::string partmessage);
/** Called on rehash. /** Called on rehash.
* This method is called prior to a /REHASH or when a SIGHUP is received from the operating * This method is called prior to a /REHASH or when a SIGHUP is received from the operating

View File

@ -404,7 +404,6 @@ chanrec* del_channel(userrec *user, const char* cname, const char* reason, bool
if (!Ptr) if (!Ptr)
return NULL; return NULL;
FOREACH_MOD(I_OnUserPart,OnUserPart(user,Ptr));
log(DEBUG,"del_channel: removing: %s %s",user->nick,Ptr->name); log(DEBUG,"del_channel: removing: %s %s",user->nick,Ptr->name);
for (unsigned int i =0; i < user->chans.size(); i++) for (unsigned int i =0; i < user->chans.size(); i++)
@ -414,10 +413,12 @@ chanrec* del_channel(userrec *user, const char* cname, const char* reason, bool
{ {
if (reason) if (reason)
{ {
FOREACH_MOD(I_OnUserPart,OnUserPart(user,Ptr,reason));
WriteChannel(Ptr,user,"PART %s :%s",Ptr->name, reason); WriteChannel(Ptr,user,"PART %s :%s",Ptr->name, reason);
} }
else else
{ {
FOREACH_MOD(I_OnUserPart,OnUserPart(user,Ptr,""));
WriteChannel(Ptr,user,"PART :%s",Ptr->name); WriteChannel(Ptr,user,"PART :%s",Ptr->name);
} }
user->chans[i].uc_modes = 0; user->chans[i].uc_modes = 0;

View File

@ -223,7 +223,7 @@ void Module::OnUserConnect(userrec* user) { }
void Module::OnUserQuit(userrec* user, std::string message) { } void Module::OnUserQuit(userrec* user, std::string message) { }
void Module::OnUserDisconnect(userrec* user) { } void Module::OnUserDisconnect(userrec* user) { }
void Module::OnUserJoin(userrec* user, chanrec* channel) { } void Module::OnUserJoin(userrec* user, chanrec* channel) { }
void Module::OnUserPart(userrec* user, chanrec* channel) { } void Module::OnUserPart(userrec* user, chanrec* channel, std::string partmessage) { }
void Module::OnRehash(std::string parameter) { } void Module::OnRehash(std::string parameter) { }
void Module::OnServerRaw(std::string &raw, bool inbound, userrec* user) { } void Module::OnServerRaw(std::string &raw, bool inbound, userrec* user) { }
int Module::OnUserPreJoin(userrec* user, chanrec* chan, const char* cname) { return 0; } int Module::OnUserPreJoin(userrec* user, chanrec* chan, const char* cname) { return 0; }

View File

@ -72,7 +72,7 @@ class ModuleChanFilter : public Module
output = temp2.substr(0,temp2.length()-1); output = temp2.substr(0,temp2.length()-1);
} }
virtual void OnUserPart(userrec* user, chanrec* channel) virtual void OnUserPart(userrec* user, chanrec* channel, std::string partreason)
{ {
// when the last user parts, delete the list // when the last user parts, delete the list
if (Srv->CountUsers(channel) == 1) if (Srv->CountUsers(channel) == 1)

View File

@ -85,7 +85,7 @@ class ModuleChanProtect : public Module
user->Shrink("cm_protect_"+std::string(chan->name)); user->Shrink("cm_protect_"+std::string(chan->name));
} }
virtual void OnUserPart(userrec* user, chanrec* channel) virtual void OnUserPart(userrec* user, chanrec* channel, std::string partreason)
{ {
// FIX: when someone parts a channel we must remove their Extensibles! // FIX: when someone parts a channel we must remove their Extensibles!
user->Shrink("cm_founder_"+std::string(channel->name)); user->Shrink("cm_founder_"+std::string(channel->name));

View File

@ -86,7 +86,7 @@ class ModuleFoobar : public Module
Srv->Log(DEBUG,"Foobar: User " + b + " joined " + c); Srv->Log(DEBUG,"Foobar: User " + b + " joined " + c);
} }
virtual void OnUserPart(userrec* user, chanrec* channel) virtual void OnUserPart(userrec* user, chanrec* channel, std::string partreason)
{ {
// method called when a user parts a channel // method called when a user parts a channel

View File

@ -2988,12 +2988,14 @@ class ModuleSpanningTree : public Module
DoOneToMany(user->nick,"FNAME",params); DoOneToMany(user->nick,"FNAME",params);
} }
virtual void OnUserPart(userrec* user, chanrec* channel) virtual void OnUserPart(userrec* user, chanrec* channel, std::string partmessage)
{ {
if (user->fd > -1) if (user->fd > -1)
{ {
std::deque<std::string> params; std::deque<std::string> params;
params.push_back(channel->name); params.push_back(channel->name);
if (partmessage != "")
params.push_back(":"+partmessage);
DoOneToMany(user->nick,"PART",params); DoOneToMany(user->nick,"PART",params);
} }
} }