]> jfr.im git - irc/rqf/shadowircd.git/blob - modules/core/m_metadata.c
Add some ircd-seven love to CREDITS.
[irc/rqf/shadowircd.git] / modules / core / m_metadata.c
1 #include "stdinc.h"
2
3 #include "send.h"
4 #include "channel.h"
5 #include "client.h"
6 #include "common.h"
7 #include "config.h"
8 #include "ircd.h"
9 #include "numeric.h"
10 #include "s_conf.h"
11 #include "s_newconf.h"
12 #include "s_serv.h"
13 #include "hash.h"
14 #include "msg.h"
15 #include "parse.h"
16 #include "modules.h"
17 #include "whowas.h"
18 #include "monitor.h"
19
20 static int me_metadata(struct Client *, struct Client *, int, const char **);
21
22 struct Message metadata_msgtab = {
23 "METADATA", 0, 0, 0, MFLG_SLOW,
24 {mg_ignore, mg_ignore, mg_ignore, mg_ignore, {me_metadata, 3}, mg_ignore}
25 };
26
27 mapi_clist_av1 metadata_clist[] = {
28 &metadata_msgtab, NULL
29 };
30
31 DECLARE_MODULE_AV1(metadata, NULL, NULL, metadata_clist, NULL, NULL, "$Revision$");
32
33 static int
34 me_metadata(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
35 {
36 if(parv[2][0] == '#')
37 {
38 struct Channel *chptr;
39
40 if((chptr = find_channel(parv[2])) == NULL)
41 return 0;
42
43 if(!strcmp(parv[1], "ADD") && parv[4] != NULL)
44 channel_metadata_add(chptr, parv[3], parv[4], 0);
45 if(!strcmp(parv[1], "DELETE") && parv[3] != NULL)
46 channel_metadata_delete(chptr, parv[3], 0);
47 }
48
49 else
50 {
51 struct Client *target_p;
52
53 if((target_p = find_id(parv[2])) == NULL)
54 return 0;
55
56 if(!target_p->user)
57 return 0;
58
59 if(!strcmp(parv[1], "ADD") && parv[4] != NULL)
60 user_metadata_add(target_p, parv[3], parv[4], 0);
61 if(!strcmp(parv[1], "DELETE") && parv[3] != NULL)
62 user_metadata_delete(target_p, parv[3], 0);
63 }
64 return 0;
65 }