]>
jfr.im git - irc/quakenet/newserv.git/blob - clonearmy/clonearmy.c
1 #include "../localuser/localuser.h"
2 #include "../localuser/localuserchannel.h"
3 #include "../core/schedule.h"
4 #include "../lib/irc_string.h"
6 #define HOMECHANNEL "#twilightzone"
7 #define NICK "Clonemaster"
10 nick
*clones
[MAXCLONES
];
14 void makenick(void *);
16 void clonehandler(nick
*np
, int message
, void **args
) {
21 for (i
=0;i
<nclones
;i
++) {
23 clones
[i
]=clones
[nclones
-1];
32 void spam(unsigned int lines
) {
34 unsigned int i
,j
,k
,l
,m
;
39 for (i
=0;i
<nclones
;i
++) {
40 cps
=clones
[i
]->channels
->content
;
41 for(j
=1;j
<clones
[i
]->channels
->cursi
;j
++) {
42 for (k
=0;k
<lines
;k
++) {
45 message
[l
]=m
?(m
-1)+'a':' ';
47 sendmessagetochannel(clones
[i
], cps
[j
], "%s", message
);
53 void join(char *chan
) {
57 if (!(cp
=findchannel(chan
)))
60 for(i
=0;i
<nclones
;i
++) {
61 localjoinchannel(clones
[i
], cp
);
65 void spawnclones(unsigned int count
) {
68 char nick
[11], ident
[11], host
[40];
71 for (i
=0;i
<count
;i
++) {
72 if (nclones
>= MAXCLONES
)
76 nick
[j
]=(rand()%26
)+'a';
77 ident
[j
]=(rand()%26
)+'a';
78 host
[j
]=(rand()%26
)+'a';
79 host
[j
+11]=(rand()%26
)+'a';
80 host
[j
+22]=(rand()%26
)+'a';
83 host
[10]=host
[21]='.';
84 host
[32]=nick
[10]=ident
[10]='\0';
86 np
=clones
[nclones
++]=registerlocaluser(nick
, ident
, host
, host
, "", 0, clonehandler
);
88 if ((cp
=findchannel(HOMECHANNEL
))) {
89 localjoinchannel(np
, cp
);
94 void masterhandler(nick
*np
, int message
, void **args
) {
100 scheduleoneshot(time(NULL
)+1, makenick
, NULL
);
106 if (!ircd_strncmp(msg
, "!spawn ",7)) {
107 spawnclones(strtoul(msg
+7,NULL
,10));
110 if (!ircd_strncmp(msg
,"!join ",6)) {
114 if (!ircd_strncmp(msg
,"!spam ", 6)) {
115 spam(strtoul(msg
+6, NULL
, 10));
121 void makenick(void *arg
) {
124 cmnick
=registerlocaluser(NICK
, "clone", "master", "Clone Master", "", 0, masterhandler
);
126 if ((cp
=findchannel(HOMECHANNEL
))) {
127 localjoinchannel(cmnick
, cp
);
129 localcreatechannel(cmnick
, HOMECHANNEL
);
134 scheduleoneshot(time(NULL
)+1, makenick
, NULL
);
141 deregisterlocaluser(cmnick
, NULL
);
144 for(i
=0;i
<nclones
;i
++) {
145 deregisterlocaluser(clones
[i
], NULL
);