]>
Commit | Line | Data |
---|---|---|
9e6feafe AC |
1 | /* |
2 | * +W snomask: Displays if a local user has done a WHOIS request on you. | |
3 | * derived from spy_whois_notice.c. | |
4 | * | |
5832fa36 JT |
5 | * If #define OPERONLY is removed, then any user can use this snomask |
6 | * (you need to put ~servnotice in oper_only_umodes for this to work). | |
9e6feafe AC |
7 | */ |
8 | ||
9 | #include "stdinc.h" | |
10 | #include "modules.h" | |
11 | #include "hook.h" | |
12 | #include "client.h" | |
13 | #include "ircd.h" | |
14 | #include "send.h" | |
d4f7eb4c | 15 | #include "s_newconf.h" |
9e6feafe AC |
16 | |
17 | /* undefine this to allow anyone to receive whois notifications */ | |
18 | #define OPERONLY | |
19 | ||
eeabf33a EM |
20 | static const char sno_desc[] = |
21 | "Adds server notice mask +W that allows " | |
22 | #ifdef OPERONLY | |
23 | "operators" | |
24 | #else | |
25 | "users" | |
26 | #endif | |
27 | " to receive notices for when a WHOIS has been done on them"; | |
28 | ||
9e6feafe AC |
29 | void show_whois(hook_data_client *); |
30 | ||
31 | mapi_hfn_list_av1 whois_hfnlist[] = { | |
32 | {"doing_whois", (hookfn) show_whois}, | |
3868ef9a | 33 | {"doing_whois_global", (hookfn) show_whois}, |
9e6feafe AC |
34 | {NULL, NULL} |
35 | }; | |
36 | ||
37 | static int | |
38 | init(void) | |
39 | { | |
40 | snomask_modes['W'] = find_snomask_slot(); | |
41 | ||
42 | return 0; | |
43 | } | |
44 | ||
45 | static void | |
46 | fini(void) | |
47 | { | |
340b2512 | 48 | snomask_modes['W'] = 0; |
9e6feafe AC |
49 | } |
50 | ||
84b4c058 | 51 | DECLARE_MODULE_AV2(sno_whois, init, fini, NULL, NULL, whois_hfnlist, NULL, NULL, sno_desc); |
9e6feafe AC |
52 | |
53 | void | |
54 | show_whois(hook_data_client *data) | |
55 | { | |
56 | struct Client *source_p = data->client; | |
57 | struct Client *target_p = data->target; | |
58 | ||
55abcbb2 | 59 | if(MyClient(target_p) && |
9e6feafe | 60 | #ifdef OPERONLY |
d4f7eb4c | 61 | IsOperGeneral(target_p) && |
9e6feafe AC |
62 | #endif |
63 | (source_p != target_p) && | |
64 | (target_p->snomask & snomask_modes['W'])) | |
65 | { | |
66 | sendto_one_notice(target_p, | |
67 | ":*** Notice -- %s (%s@%s) is doing a whois on you [%s]", | |
68 | source_p->name, | |
69 | source_p->username, source_p->host, | |
c88cdb00 | 70 | source_p->servptr->name); |
9e6feafe AC |
71 | } |
72 | } |