]> jfr.im git - solanum.git/blame - extensions/sno_whois.c
Merge pull request #302 from edk0/sasl-usercloak
[solanum.git] / extensions / sno_whois.c
CommitLineData
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"
15
16/* undefine this to allow anyone to receive whois notifications */
17#define OPERONLY
18
eeabf33a
EM
19static const char sno_desc[] =
20 "Adds server notice mask +W that allows "
21#ifdef OPERONLY
22 "operators"
23#else
24 "users"
25#endif
26 " to receive notices for when a WHOIS has been done on them";
27
9e6feafe
AC
28void show_whois(hook_data_client *);
29
30mapi_hfn_list_av1 whois_hfnlist[] = {
31 {"doing_whois", (hookfn) show_whois},
3868ef9a 32 {"doing_whois_global", (hookfn) show_whois},
9e6feafe
AC
33 {NULL, NULL}
34};
35
36static int
37init(void)
38{
39 snomask_modes['W'] = find_snomask_slot();
40
41 return 0;
42}
43
44static void
45fini(void)
46{
340b2512 47 snomask_modes['W'] = 0;
9e6feafe
AC
48}
49
84b4c058 50DECLARE_MODULE_AV2(sno_whois, init, fini, NULL, NULL, whois_hfnlist, NULL, NULL, sno_desc);
9e6feafe
AC
51
52void
53show_whois(hook_data_client *data)
54{
55 struct Client *source_p = data->client;
56 struct Client *target_p = data->target;
57
55abcbb2 58 if(MyClient(target_p) &&
9e6feafe
AC
59#ifdef OPERONLY
60 IsOper(target_p) &&
61#endif
62 (source_p != target_p) &&
63 (target_p->snomask & snomask_modes['W']))
64 {
65 sendto_one_notice(target_p,
66 ":*** Notice -- %s (%s@%s) is doing a whois on you [%s]",
67 source_p->name,
68 source_p->username, source_p->host,
c88cdb00 69 source_p->servptr->name);
9e6feafe
AC
70 }
71}