Add hooks for local and remote nick changes
This commit is contained in:
parent
6d16f66be6
commit
f32b9ebd63
1 changed files with 22 additions and 1 deletions
|
@ -79,6 +79,9 @@ static void perform_nick_collides(struct Client *, struct Client *,
|
||||||
static void perform_nickchange_collides(struct Client *, struct Client *,
|
static void perform_nickchange_collides(struct Client *, struct Client *,
|
||||||
struct Client *, int, const char **, time_t, const char *);
|
struct Client *, int, const char **, time_t, const char *);
|
||||||
|
|
||||||
|
static int h_local_nick_change;
|
||||||
|
static int h_remote_nick_change;
|
||||||
|
|
||||||
struct Message nick_msgtab = {
|
struct Message nick_msgtab = {
|
||||||
"NICK", 0, 0, 0, 0,
|
"NICK", 0, 0, 0, 0,
|
||||||
{{mr_nick, 0}, {m_nick, 0}, {mc_nick, 3}, {ms_nick, 0}, mg_ignore, {m_nick, 0}}
|
{{mr_nick, 0}, {m_nick, 0}, {mc_nick, 3}, {ms_nick, 0}, mg_ignore, {m_nick, 0}}
|
||||||
|
@ -99,10 +102,16 @@ struct Message save_msgtab = {
|
||||||
mapi_clist_av1 nick_clist[] = { &nick_msgtab, &uid_msgtab, &euid_msgtab,
|
mapi_clist_av1 nick_clist[] = { &nick_msgtab, &uid_msgtab, &euid_msgtab,
|
||||||
&save_msgtab, NULL };
|
&save_msgtab, NULL };
|
||||||
|
|
||||||
|
mapi_hlist_av1 nick_hlist[] = {
|
||||||
|
{ "local_nick_change", &h_local_nick_change },
|
||||||
|
{ "remote_nick_change", &h_remote_nick_change },
|
||||||
|
{ NULL, NULL }
|
||||||
|
};
|
||||||
|
|
||||||
static const char nick_desc[] =
|
static const char nick_desc[] =
|
||||||
"Provides the NICK client and server commands as well as the UID, EUID, and SAVE TS6 server commands";
|
"Provides the NICK client and server commands as well as the UID, EUID, and SAVE TS6 server commands";
|
||||||
|
|
||||||
DECLARE_MODULE_AV2(nick, NULL, NULL, nick_clist, NULL, NULL, NULL, NULL, nick_desc);
|
DECLARE_MODULE_AV2(nick, NULL, NULL, nick_clist, nick_hlist, NULL, NULL, NULL, nick_desc);
|
||||||
|
|
||||||
/* mr_nick()
|
/* mr_nick()
|
||||||
* parv[1] = nickname
|
* parv[1] = nickname
|
||||||
|
@ -615,6 +624,7 @@ change_local_nick(struct Client *client_p, struct Client *source_p,
|
||||||
struct Channel *chptr;
|
struct Channel *chptr;
|
||||||
char note[NICKLEN + 10];
|
char note[NICKLEN + 10];
|
||||||
int samenick;
|
int samenick;
|
||||||
|
hook_data hook_info;
|
||||||
|
|
||||||
if (dosend)
|
if (dosend)
|
||||||
{
|
{
|
||||||
|
@ -658,6 +668,11 @@ change_local_nick(struct Client *client_p, struct Client *source_p,
|
||||||
invalidate_bancache_user(source_p);
|
invalidate_bancache_user(source_p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hook_info.client = source_p;
|
||||||
|
hook_info.arg1 = source_p->name;
|
||||||
|
hook_info.arg2 = nick;
|
||||||
|
call_hook(h_local_nick_change, &hook_info);
|
||||||
|
|
||||||
sendto_realops_snomask(SNO_NCHANGE, L_ALL,
|
sendto_realops_snomask(SNO_NCHANGE, L_ALL,
|
||||||
"Nick change: From %s to %s [%s@%s]",
|
"Nick change: From %s to %s [%s@%s]",
|
||||||
source_p->name, nick, source_p->username, source_p->host);
|
source_p->name, nick, source_p->username, source_p->host);
|
||||||
|
@ -716,6 +731,7 @@ change_remote_nick(struct Client *client_p, struct Client *source_p,
|
||||||
{
|
{
|
||||||
struct nd_entry *nd;
|
struct nd_entry *nd;
|
||||||
int samenick = irccmp(source_p->name, nick) ? 0 : 1;
|
int samenick = irccmp(source_p->name, nick) ? 0 : 1;
|
||||||
|
hook_data hook_info;
|
||||||
|
|
||||||
/* client changing their nick - dont reset ts if its same */
|
/* client changing their nick - dont reset ts if its same */
|
||||||
if(!samenick)
|
if(!samenick)
|
||||||
|
@ -724,6 +740,11 @@ change_remote_nick(struct Client *client_p, struct Client *source_p,
|
||||||
monitor_signoff(source_p);
|
monitor_signoff(source_p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hook_info.client = source_p;
|
||||||
|
hook_info.arg1 = source_p->name;
|
||||||
|
hook_info.arg2 = nick;
|
||||||
|
call_hook(h_remote_nick_change, &hook_info);
|
||||||
|
|
||||||
sendto_common_channels_local(source_p, NOCAPS, NOCAPS, ":%s!%s@%s NICK :%s",
|
sendto_common_channels_local(source_p, NOCAPS, NOCAPS, ":%s!%s@%s NICK :%s",
|
||||||
source_p->name, source_p->username, source_p->host, nick);
|
source_p->name, source_p->username, source_p->host, nick);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue