]> jfr.im git - irc/quakenet/newserv.git/blame - rannounce/rannounce.c
sync Z
[irc/quakenet/newserv.git] / rannounce / rannounce.c
CommitLineData
c86edd1d
Q
1
2#include "../nick/nick.h"
3#include "../localuser/localuserchannel.h"
4ad1cf7a 4#include "../lib/irc_string.h"
c86edd1d
Q
5
6nick *rannouncenick;
7
8void rannouncehandler(nick *me, int type, void **args);
9
10void _init() {
11 channel *cp;
12 rannouncenick=registerlocaluser("R","relay","quakenet.org","Relay announcer",NULL,0,rannouncehandler);
13
14 if ((cp=findchannel("#twilightzone"))) {
15 localjoinchannel(rannouncenick, cp);
16 } else {
17 localcreatechannel(rannouncenick, "#twilightzone");
18 }
19
20 if ((cp=findchannel("#qnet.queue"))) {
21 localjoinchannel(rannouncenick, cp);
22 } else {
23 localcreatechannel(rannouncenick, "#qnet.queue");
24 }
25
26 if ((cp=findchannel("#qrequest"))) {
27 localjoinchannel(rannouncenick, cp);
28 } else {
29 localcreatechannel(rannouncenick, "#qrequest");
30 }
31}
32
33void _fini() {
34 deregisterlocaluser(rannouncenick,NULL);
35}
36
37void rannouncehandler(nick *me, int type, void **args) {
38 nick *np;
39 char *text;
40 channel *cp;
41 int items;
42
43 if (type==LU_PRIVMSG) {
44 np=args[0];
45 text=args[1];
46
47 if (IsOper(np) && !ircd_strncmp(text,"announce ",9)) {
48 text+=9;
49 items=strtoul(text,NULL,10);
50
51 if (items) {
52 if ((cp=findchannel("#twilightzone"))) {
53 sendmessagetochannel(me, cp, "%d item%s in queue - https://www.quakenet.org/secure/queue/",items,items==1?"":"s");
54 }
55 if ((cp=findchannel("#qnet.queue"))) {
56 sendmessagetochannel(me, cp, "%d item%s in queue - https://www.quakenet.org/secure/queue/",items,items==1?"":"s");
57 }
58 if ((cp=findchannel("#qrequest"))) {
59 sendmessagetochannel(me, cp, "%d item%s in queue",items,items==1?"":"s");
60 }
61 }
62 }
63 } else if (type==LU_KILLED) {
64 rannouncenick=NULL;
65 }
66}
67