]>
Commit | Line | Data |
---|---|---|
94613c78 EK |
1 | #include <stdinc.h> |
2 | #include <modules.h> | |
3 | #include <messages.h> | |
4 | #include <send.h> | |
5 | ||
6 | static const char identified_desc[] = "Provides the IDENTIFIED server-to-server command"; | |
7 | ||
8 | static void m_identified(struct MsgBuf *, struct Client *, struct Client *, int, const char *[]); | |
9 | ||
10 | static struct Message identified_msgtab = { | |
11 | "IDENTIFIED", 0, 0, 0, 0, | |
12 | {mg_ignore, mg_ignore, mg_ignore, mg_ignore, {m_identified, 3}, mg_ignore} | |
13 | }; | |
14 | ||
15 | static mapi_clist_av1 identified_clist[] = { | |
16 | &identified_msgtab, | |
17 | NULL | |
18 | }; | |
19 | ||
20 | static void identified_nick_change(void *); | |
21 | static void identified_burst_client(void *); | |
22 | ||
23 | static mapi_hfn_list_av1 identified_hfnlist[] = { | |
24 | { "local_nick_change", identified_nick_change, HOOK_MONITOR }, | |
25 | { "remote_nick_change", identified_nick_change, HOOK_MONITOR }, | |
26 | { "burst_client", identified_burst_client }, | |
27 | { NULL, NULL } | |
28 | }; | |
29 | ||
30 | static void m_identified(struct MsgBuf *msgbuf, struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) | |
31 | { | |
32 | struct Client *target_p = find_person(parv[1]); | |
33 | const char *nick = parv[2]; | |
34 | ||
35 | if (target_p == NULL) | |
36 | return; | |
37 | ||
38 | if (irccmp(target_p->name, nick)) | |
39 | return; | |
40 | ||
41 | if (parc > 3 && irccmp(parv[3], "OFF") == 0) | |
42 | ClearIdentified(target_p); | |
43 | else | |
44 | SetIdentified(target_p); | |
45 | } | |
46 | ||
47 | static void identified_nick_change(void *data_) | |
48 | { | |
49 | hook_cdata *data = data_; | |
50 | const char *oldnick = data->arg1, *newnick = data->arg2; | |
51 | ||
52 | if (irccmp(oldnick, newnick) != 0) | |
53 | ClearIdentified(data->client); | |
54 | } | |
55 | ||
56 | static void identified_burst_client(void *data_) | |
57 | { | |
58 | hook_data_client *data = data_; | |
59 | ||
60 | if (IsIdentified(data->target)) | |
61 | sendto_one(data->client, ":%s ENCAP * IDENTIFIED %s :%s", me.id, use_id(data->target), data->target->name); | |
62 | } | |
63 | ||
64 | DECLARE_MODULE_AV2(identified, NULL, NULL, identified_clist, NULL, identified_hfnlist, NULL, NULL, identified_desc); |