]>
Commit | Line | Data |
---|---|---|
1 | #include "stdinc.h" | |
2 | #include "ircd.h" | |
3 | #include "client.h" | |
4 | #include "modules.h" | |
5 | #include "send.h" | |
6 | #include "numeric.h" | |
7 | #include "hash.h" | |
8 | ||
9 | static int 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 | ||
18 | DECLARE_MODULE_AV1(oaccept, NULL, NULL, oaccept_clist, NULL, NULL, "$Id $"); | |
19 | ||
20 | static int | |
21 | mo_oaccept(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) | |
22 | { | |
23 | struct Metadata *md; | |
24 | struct DictionaryIter iter; | |
25 | struct Client *target_p; | |
26 | char text[10]; | |
27 | ||
28 | if(!(target_p = find_client(parv[1]))) | |
29 | { | |
30 | sendto_one(source_p, form_str(ERR_NOSUCHNICK), parv[1]); | |
31 | return 0; | |
32 | } | |
33 | ||
34 | rb_snprintf(text, sizeof(text), "O%s", source_p->id); | |
35 | ||
36 | /* Provide a nice error message if you try to OACCEPT someone | |
37 | * who you've already OACCEPTed. */ | |
38 | DICTIONARY_FOREACH(md, &iter, target_p->user->metadata) | |
39 | { | |
40 | if(!strcmp(md->value, "OACCEPT") && !strcmp(md->name, text)) | |
41 | { | |
42 | sendto_one_notice(source_p, ":You're already on %s's OACCEPT list", target_p->name); | |
43 | return 0; | |
44 | } | |
45 | } | |
46 | ||
47 | user_metadata_add(target_p, text, "OACCEPT", 1); | |
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); | |
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); | |
57 | return 0; | |
58 | } |