2
2
* assoc.c -- part of assoc.mod
3
3
* the assoc code, moved here mainly from botnet.c for module work
5
* $Id: assoc.c,v 1.19 2002/01/02 08:06:14 tothwolf Exp $
5
* $Id: assoc.c,v 1.28 2004/01/09 05:56:37 wcc Exp $
8
8
* Copyright (C) 1997 Robey Pointer
9
* Copyright (C) 1999, 2000, 2001, 2002 Eggheads Development Team
9
* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004 Eggheads Development Team
11
11
* This program is free software; you can redistribute it and/or
12
12
* modify it under the terms of the GNU General Public License
52
51
simple_sprintf(x, "assoc %D %s %s", chan, nick, buf);
53
52
for (idx2 = 0; idx2 < dcc_total; idx2++)
54
53
if ((dcc[idx2].type == &DCC_BOT) && (idx2 != idx) &&
55
(b_numver(idx2) >= NEAT_BOTNET) &&
56
!(bot_flags(dcc[idx2].user) & BOT_ISOLATE))
54
(b_numver(idx2) >= NEAT_BOTNET) &&
55
!(bot_flags(dcc[idx2].user) & BOT_ISOLATE))
57
56
botnet_send_zapf(idx2, botnetnick, dcc[idx2].nick, x);
78
77
if (!(bot_flags(dcc[idx].user) & BOT_ISOLATE)) {
79
78
for (a = assoc; a && a->name[0]; a = a->next) {
80
simple_sprintf(x, "assoc %D %s %s", (int) a->channel, botnetnick,
82
botnet_send_zapf(idx, botnetnick, dcc[idx].nick, x);
79
simple_sprintf(x, "assoc %D %s %s", (int) a->channel, botnetnick,
81
botnet_send_zapf(idx, botnetnick, dcc[idx].nick, x);
186
185
dprintf(idx, " %s %s\n", ASSOC_CHAN, ASSOC_NAME);
187
186
for (; a && a->name[0]; a = a->next)
188
dprintf(idx, "%c%5d %s\n", (a->channel < 100000) ? ' ' : '*',
189
a->channel % 100000, a->name);
187
dprintf(idx, "%c%5d %s\n", (a->channel < GLOBAL_CHANS) ? ' ' : '*',
188
a->channel % GLOBAL_CHANS, a->name);
199
198
putlog(LOG_CMDS, "*", "#%s# assoc", dcc[idx].nick);
201
} else if (!u || !(u->flags & USER_BOTMAST)) {
202
dprintf(idx, "%s", ASSOC_NOSUCHCMD);
200
} else if (!u || !(u->flags & USER_BOTMAST))
201
dprintf(idx, "%s", MISC_NOSUCHCMD);
204
203
num = newsplit(&par);
205
204
if (num[0] == '*') {
206
chan = 100000 + atoi(num + 1);
207
if ((chan < 100000) || (chan > 199999)) {
208
dprintf(idx, "%s\n", ASSOC_LCHAN_RANGE);
205
chan = GLOBAL_CHANS + atoi(num + 1);
206
if ((chan < GLOBAL_CHANS) || (chan > 199999)) {
207
dprintf(idx, "%s\n", ASSOC_LCHAN_RANGE);
212
211
chan = atoi(num);
214
dprintf(idx, "%s\n", ASSOC_PARTYLINE);
216
} else if ((chan < 1) || (chan > 99999)) {
217
dprintf(idx, "%s\n", ASSOC_CHAN_RANGE);
213
dprintf(idx, "%s\n", ASSOC_PARTYLINE);
215
} else if ((chan < 1) || (chan >= GLOBAL_CHANS)) {
216
dprintf(idx, "%s\n", ASSOC_CHAN_RANGE);
222
221
/* Remove an association */
223
222
if (get_assoc_name(chan) == NULL) {
224
dprintf(idx, ASSOC_NONAME_CHAN, (chan < 100000) ? "" : "*",
223
dprintf(idx, ASSOC_NONAME_CHAN, (chan < GLOBAL_CHANS) ? "" : "*",
224
chan % GLOBAL_CHANS);
228
227
kill_assoc(chan);
229
228
putlog(LOG_CMDS, "*", "#%s# assoc %d", dcc[idx].nick, chan);
230
dprintf(idx, ASSOC_REMNAME_CHAN, (chan < 100000) ? "" : "*",
229
dprintf(idx, ASSOC_REMNAME_CHAN, (chan < GLOBAL_CHANS) ? "" : "*",
230
chan % GLOBAL_CHANS);
232
231
chanout_but(-1, chan, ASSOC_REMOUT_CHAN, dcc[idx].nick);
234
botnet_send_assoc(-1, chan, dcc[idx].nick, "0");
232
if (chan < GLOBAL_CHANS)
233
botnet_send_assoc(-1, chan, dcc[idx].nick, "0");
237
236
if (strlen(par) > 20) {
245
244
add_assoc(par, chan);
246
245
putlog(LOG_CMDS, "*", "#%s# assoc %d %s", dcc[idx].nick, chan, par);
247
dprintf(idx, ASSOC_NEWNAME_CHAN, (chan < 100000) ? "" : "*",
249
chanout_but(-1, chan, ASSOC_NEWOUT_CHAN, dcc[idx].nick,
246
dprintf(idx, ASSOC_NEWNAME_CHAN, (chan < GLOBAL_CHANS) ? "" : "*",
247
chan % GLOBAL_CHANS, par);
248
chanout_but(-1, chan, ASSOC_NEWOUT_CHAN, dcc[idx].nick, par);
249
if (chan < GLOBAL_CHANS)
252
250
botnet_send_assoc(-1, chan, dcc[idx].nick, par);
257
static int tcl_killassoc STDVAR {
255
static int tcl_killassoc STDVAR
260
259
BADARGS(2, 2, " chan");
261
261
if (argv[1][0] == '&')
262
262
kill_all_assoc();
322
325
nick = newsplit(&par);
323
326
s1 = get_assoc_name(chan);
324
327
if (linking && ((s1 == NULL) || (s1[0] == 0) ||
325
(((int) get_user(find_entry_type("BOTFL"),
326
dcc[idx].user) & BOT_HUB)))) {
327
add_assoc(par, chan);
328
botnet_send_assoc(idx, chan, nick, par);
329
chanout_but(-1, chan, ASSOC_CHNAME_NAMED, nick, par);
328
(((int) get_user(find_entry_type("BOTFL"),
329
dcc[idx].user) & BOT_HUB)))) {
330
add_assoc(par, chan);
331
botnet_send_assoc(idx, chan, nick, par);
332
chanout_but(-1, chan, ASSOC_CHNAME_NAMED, nick, par);
330
333
} else if (par[0] == '0') {
332
chanout_but(-1, chan, ASSOC_CHNAME_REM, botnick, nick);
335
chanout_but(-1, chan, ASSOC_CHNAME_REM, botnick, nick);
333
336
} else if (get_assoc(par) != chan) {
334
/* New one i didn't know about -- pass it on */
335
s1 = get_assoc_name(chan);
336
add_assoc(par, chan);
337
chanout_but(-1, chan, ASSOC_CHNAME_NAMED2, botnick, nick, par);
337
/* New one i didn't know about -- pass it on */
338
s1 = get_assoc_name(chan);
339
add_assoc(par, chan);
340
chanout_but(-1, chan, ASSOC_CHNAME_NAMED2, botnick, nick, par);
343
/* A report on the module status.
345
346
static void assoc_report(int idx, int details)
348
int size = 0, count = 0;;
350
int size = 0, count = 0;
351
352
for (a = assoc; a; a = a->next) {
353
354
size += sizeof(assoc_t);
355
dprintf(idx, " %d assocs using %d bytes\n",
357
dprintf(idx, " %d current association%s\n", count,
358
(count != 1) ? "s" : "");
359
dprintf(idx, " Using %d byte%s of memory\n", size,
360
(size != 1) ? "s" : "");
360
static cmd_t mydcc[] =
362
{"assoc", "", cmd_assoc, NULL},
363
{NULL, NULL, NULL, NULL}
366
static cmd_t mybot[] =
368
{"assoc", "", (Function) zapf_assoc, NULL},
369
{NULL, NULL, NULL, NULL}
372
static cmd_t mylink[] =
374
{"*", "", (Function) link_assoc, "assoc"},
375
{NULL, NULL, NULL, NULL}
378
static tcl_cmds mytcl[] =
380
{"assoc", tcl_assoc},
381
{"killassoc", tcl_killassoc},
364
static cmd_t mydcc[] = {
365
{"assoc", "", cmd_assoc, NULL},
366
{NULL, NULL, NULL, NULL}
369
static cmd_t mybot[] = {
370
{"assoc", "", (Function) zapf_assoc, NULL},
371
{NULL, NULL, NULL, NULL}
374
static cmd_t mylink[] = {
375
{"*", "", (Function) link_assoc, "assoc"},
376
{NULL, NULL, NULL, NULL}
379
static tcl_cmds mytcl[] = {
380
{"assoc", tcl_assoc},
381
{"killassoc", tcl_killassoc},
385
385
static char *assoc_close()
398
398
EXPORT_SCOPE char *assoc_start();
400
static Function assoc_table[] =
400
static Function assoc_table[] = {
402
401
(Function) assoc_start,
403
402
(Function) assoc_close,
404
403
(Function) assoc_expmem,
405
404
(Function) assoc_report,
408
char *assoc_start(Function * global_funcs)
407
char *assoc_start(Function *global_funcs)
410
409
global = global_funcs;
412
411
module_register(MODULE_NAME, assoc_table, 2, 0);
413
412
if (!module_depend(MODULE_NAME, "eggdrop", 106, 0)) {
414
413
module_undepend(MODULE_NAME);
415
return "This module requires eggdrop1.6.0 or later";
414
return "This module requires Eggdrop 1.6.0 or later.";
418
417
add_builtins(H_dcc, mydcc);