]>
Commit | Line | Data |
---|---|---|
1fbf6db6 G |
1 | #include "stdinc.h" |
2 | #include "ircd.h" | |
3 | #include "client.h" | |
4 | #include "modules.h" | |
5 | #include "send.h" | |
6 | #include "numeric.h" | |
76db4b42 | 7 | #include "hash.h" |
1fbf6db6 G |
8 | |
9 | void mo_oaccept(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]); | |
10 | ||
11 | struct Message oaccept_msgtab = { | |
12 | "OACCEPT", 0, 0, 0, MFLG_SLOW, | |
13 | {mg_unreg, mg_not_oper, mg_ignore, mg_ignore, mg_ignore, {mo_oaccept, 2}} | |
14 | }; | |
15 | ||
16 | mapi_clist_av1 oaccept_clist[] = { &oaccept_msgtab, NULL }; | |
17 | ||
7bf7fc16 | 18 | DECLARE_MODULE_AV1(oaccept, NULL, NULL, oaccept_clist, NULL, NULL, "$Id $"); |
1fbf6db6 G |
19 | |
20 | void | |
21 | mo_oaccept(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) | |
22 | { | |
23 | struct Metadata *md; | |
bc4764ae | 24 | struct DictionaryIter iter; |
1fbf6db6 | 25 | struct Client *target_p; |
bc4764ae | 26 | char *text = rb_strdup(""); |
1fbf6db6 G |
27 | |
28 | if(!(target_p = find_client(parv[1]))) | |
29 | { | |
30 | sendto_one(source_p, form_str(ERR_NOSUCHNICK), parv[1]); | |
31 | return; | |
32 | } | |
33 | ||
bc4764ae G |
34 | rb_sprintf(text, "O%s", source_p->id); |
35 | ||
75a9b0c8 G |
36 | /* Don't allow someone to pointlessly fill up someone's metadata |
37 | * with identical OACCEPT entries. */ | |
bc4764ae G |
38 | DICTIONARY_FOREACH(md, &iter, target_p->user->metadata) |
39 | { | |
40 | if(!strcmp(md->value, "OACCEPT") && !strcmp(md->name, text)) | |
75a9b0c8 G |
41 | { |
42 | sendto_one_notice(source_p, ":You're already on %s's OACCEPT list", target_p->name); | |
43 | return; | |
44 | } | |
bc4764ae | 45 | } |
1fbf6db6 | 46 | |
bc4764ae | 47 | user_metadata_add(target_p, text, "OACCEPT", 1); |
1fbf6db6 G |
48 | |
49 | sendto_wallops_flags(UMODE_WALLOP, &me, | |
50 | "OACCEPT called for %s by %s!%s@%s", | |
51 | target_p->name, | |
52 | source_p->name, source_p->username, source_p->host); | |
18e4f177 G |
53 | sendto_server(NULL, NULL, NOCAPS, NOCAPS, |
54 | ":%s WALLOPS :OACCEPT called for %s by %s!%s@%s", | |
55 | me.name, target_p->name, source_p->name, source_p->username, | |
56 | source_p->host); | |
1fbf6db6 | 57 | } |