forked from atheme/atheme-contrib-modules
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcs_babbler.c
98 lines (84 loc) · 2.31 KB
/
cs_babbler.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/*
* Copyright (c) 2008 William Pitcock
* Rights to this code are as documented in doc/LICENSE.
*
* Because sometimes premadonna assholes with large ignore lists
* piss entire channels the hell off...
*
* So what does this do?
* =====================
*
* It repeats everything someone says and to be extra annoying, highlights
* the person who has public ignore notification spam.
*
* It was written for the purpose of mockery of someone on #atheme-project
* who makes claims like "I have the whole channel on ignore", etc.
*
* Pro tip: we don't care about your ignore list.
*
* How do I use it? I have an asshole on my channel too!
* =====================================================
*
* Load the module, set these options:
*
* - babbler:enable to actually enable babbler
* - babbler:nicks, the actual ignore list of the asshole
* - babbler:target, the nick of the person who needs to be pwnt
* - babbler:source, the nick of a psuedoclient to send the message
* from.
*
* Will you make it PM them instead?
* =================================
*
* Absolutely not. Then it could be used for spambots, etc. That's a really
* bad idea.
*/
#include "atheme-compat.h"
DECLARE_MODULE_V1
(
"contrib/cs_babbler", false, _modinit, _moddeinit,
PACKAGE_STRING,
"William Pitcock <nenolod -at- nenolod.net>"
);
static void
on_channel_message(hook_cmessage_data_t *data)
{
if (data != NULL && data->msg != NULL)
{
mychan_t *mc = mychan_from(data->c);
metadata_t *md;
if (!mc)
return;
if (!metadata_find(mc, "babbler:enable"))
return;
if (!(md = metadata_find(mc, "babbler:nicks")))
return;
if (strstr(md->value, data->u->nick))
{
char *source = NULL;
char *target;
if (!(md = metadata_find(mc, "babbler:target")))
return;
target = md->value;
if (!(md = metadata_find(mc, "babbler:source")))
source = chansvs.nick;
else
source = md->value;
msg(source, data->c->name, "%s: <%s> %s", target, data->u->nick, data->msg);
}
}
}
void _modinit(module_t *m)
{
hook_add_event("channel_message");
hook_add_channel_message(on_channel_message);
}
void _moddeinit(module_unload_intent_t intent)
{
hook_del_channel_message(on_channel_message);
}
/* vim:cinoptions=>s,e0,n0,f0,{0,}0,^0,=s,ps,t0,c3,+s,(2s,us,)20,*30,gs,hs
* vim:ts=8
* vim:sw=8
* vim:noexpandtab
*/