]> jfr.im git - solanum.git/blame - extensions/sno_whois.c
[svn] - rework spy_whois_notice as a snomask-implementing module, snomask +W.
[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 *
5 * If #define OPERONLY is removed, then any user can use this snomask.
6 *
7 * $Id: sno_whois.c 3468 2007-05-24 03:58:27Z nenolod $
8 */
9
10#include "stdinc.h"
11#include "modules.h"
12#include "hook.h"
13#include "client.h"
14#include "ircd.h"
15#include "send.h"
16
17/* undefine this to allow anyone to receive whois notifications */
18#define OPERONLY
19
20void show_whois(hook_data_client *);
21
22mapi_hfn_list_av1 whois_hfnlist[] = {
23 {"doing_whois", (hookfn) show_whois},
24 {NULL, NULL}
25};
26
27static int
28init(void)
29{
30 snomask_modes['W'] = find_snomask_slot();
31
32 return 0;
33}
34
35static void
36fini(void)
37{
38 snomask_modes['W'] = find_snomask_slot();
39}
40
41DECLARE_MODULE_AV1(sno_whois, init, fini, NULL, NULL, whois_hfnlist, "$Revision: 3468 $");
42
43void
44show_whois(hook_data_client *data)
45{
46 struct Client *source_p = data->client;
47 struct Client *target_p = data->target;
48
49 /* source being MyConnect() is implicit here from m_whois.c --fl */
50 if(MyClient(target_p) &&
51#ifdef OPERONLY
52 IsOper(target_p) &&
53#endif
54 (source_p != target_p) &&
55 (target_p->snomask & snomask_modes['W']))
56 {
57 sendto_one_notice(target_p,
58 ":*** Notice -- %s (%s@%s) is doing a whois on you [%s]",
59 source_p->name,
60 source_p->username, source_p->host,
61 source_p->user->server);
62 }
63}