summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDukePyrolator <DukePyrolator@5417fbe8-f217-4b02-8779-1006273d7864>2009-10-07 10:33:28 +0000
committerDukePyrolator <DukePyrolator@5417fbe8-f217-4b02-8779-1006273d7864>2009-10-07 10:33:28 +0000
commitdd3cce64c3a5627f0a3b73ce835a2bd593bb64e9 (patch)
treede380580ba040f2bf1773151dd88a4b2870047ce
parentfb5356ccbcb96f0c71d650876bf4d7571e8e0ffc (diff)
added a new event OnUserQuit, changed OnPartChannel and OnUserKicked to send the part/kick message and fixed OnUserNickChange
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@2539 5417fbe8-f217-4b02-8779-1006273d7864
-rw-r--r--include/modules.h18
-rw-r--r--src/channels.c6
-rw-r--r--src/users.c5
3 files changed, 19 insertions, 10 deletions
diff --git a/include/modules.h b/include/modules.h
index 576df6ebc..77986102e 100644
--- a/include/modules.h
+++ b/include/modules.h
@@ -507,10 +507,10 @@ class CoreExport Module
/** Called when the ircd notifies that a user has been kicked from a channel.
* @param c The channel the user has been kicked from.
* @param target The user that has been kicked.
+ * @param source The nick of the sender.
* @param kickmsg The reason for the kick.
- * NOTE: We may want to add a second User arg for sender in the future.
*/
- virtual void OnUserKicked(Channel *c, User *target, const std::string &kickmsg) { }
+ virtual void OnUserKicked(Channel *c, User *target, const std::string &source, const std::string &kickmsg) { }
/** Called when Services' configuration has been loaded.
* @param startup True if Services is starting for the first time, false otherwise.
@@ -625,7 +625,7 @@ class CoreExport Module
* @param ci The channel
* @param reason The reason
*/
- virtual void OnBotKick(User *u, ChannelInfo *ci, const char *reason) { }
+ virtual void OnBotKick(User *u, ChannelInfo *ci, const std::string &reason) { }
/** Called before a user parts a channel
* @param u The user
@@ -637,7 +637,7 @@ class CoreExport Module
* @param u The user
* @param c The channel
*/
- virtual void OnPartChannel(User *u, Channel *c) { }
+ virtual void OnPartChannel(User *u, Channel *c, const std::string &msg) { }
/** Called before a user joins a channel
* @param u The user
@@ -716,8 +716,14 @@ class CoreExport Module
*/
virtual void OnServerQuit(Server *server) { }
+ /** Called on a QUIT
+ * @param u The user
+ * @param msg The quit message
+ */
+ virtual void OnUserQuit(User *u, const std::string &msg) { }
+
/** Called when a user disconnects
- * @param nick The name of the user
+ * @param u The user
*/
virtual void OnUserLogoff(User *u) { }
@@ -938,7 +944,7 @@ enum Implementation
I_OnDeleteHostCore, I_OnFindHostCore, I_OnInsertHostCore,
/* Users */
- I_OnUserConnect, I_OnUserNickChange, I_OnUserLogoff, I_OnPreJoinChannel, I_OnJoinChannel,
+ I_OnUserConnect, I_OnUserNickChange, I_OnUserQuit, I_OnUserLogoff, I_OnPreJoinChannel, I_OnJoinChannel,
I_OnPrePartChannel, I_OnPartChannel,
/* OperServ */
diff --git a/src/channels.c b/src/channels.c
index 45e196ea3..f41219109 100644
--- a/src/channels.c
+++ b/src/channels.c
@@ -551,7 +551,7 @@ void do_join(const char *source, int ac, const char **av)
channame = sstrdup(c->chan->name);
FOREACH_MOD(I_OnPrePartChannel, OnPrePartChannel(user, c->chan));
chan_deluser(user, c->chan);
- FOREACH_MOD(I_OnPartChannel, OnPartChannel(user, c->chan));
+ FOREACH_MOD(I_OnPartChannel, OnPartChannel(user, c->chan, ""));
delete [] channame;
delete c;
c = nextc;
@@ -640,7 +640,7 @@ void do_kick(const char *source, int ac, const char **av)
c = c->next);
if (c)
{
- FOREACH_MOD(I_OnUserKicked, OnUserKicked(c->chan, user, merge_args(ac - 2, av + 2)));
+ FOREACH_MOD(I_OnUserKicked, OnUserKicked(c->chan, user, source, merge_args(ac - 2, av + 2)));
chan_deluser(user, c->chan);
if (c->next)
c->next->prev = c->prev;
@@ -698,7 +698,7 @@ void do_part(const char *source, int ac, const char **av)
chan_deluser(user, c->chan);
- FOREACH_MOD(I_OnPartChannel, OnPartChannel(user, c->chan));
+ FOREACH_MOD(I_OnPartChannel, OnPartChannel(user, c->chan, av[1] ? av[1] : ""));
if (c->next)
c->next->prev = c->prev;
diff --git a/src/users.c b/src/users.c
index 08c4d81f8..55981d995 100644
--- a/src/users.c
+++ b/src/users.c
@@ -577,6 +577,7 @@ User *do_nick(const char *source, const char *nick, const char *username, const
int status = 0; /* Status to apply */
char mask[USERMAX + HOSTMAX + 2];
char *logrealname;
+ std::string oldnick; /* stores the old nick of the user, so we can pass it to OnUserNickChange */
if (!*source) {
char ipbuf[16];
@@ -766,8 +767,9 @@ User *do_nick(const char *source, const char *nick, const char *username, const
cancel_user(user);
}
+ oldnick = user->nick;
user->SetNewNick(nick);
- FOREACH_MOD(I_OnUserNickChange, OnUserNickChange(user, source));
+ FOREACH_MOD(I_OnUserNickChange, OnUserNickChange(user, oldnick.c_str()));
if ((old_na ? old_na->nc : NULL) == user->nc)
nc_changed = 0;
@@ -895,6 +897,7 @@ void do_quit(const char *source, int ac, const char **av)
if (LimitSessions && !is_ulined(user->server->name)) {
del_session(user->host);
}
+ FOREACH_MOD(I_OnUserQuit, OnUserQuit(user, *av[0] ? av[0] : ""));
delete user;
}