/[cvs]/eggdrop1.9/src/cmds.c
ViewVC logotype

Annotation of /eggdrop1.9/src/cmds.c

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.18 - (hide annotations) (download) (as text)
Mon Dec 27 18:35:44 1999 UTC (19 years, 11 months ago) by fabian
Branch: MAIN
Changes since 1.17: +10 -1 lines
File MIME type: text/x-chdr
dw's strip patch

1 segfault 1.1 /*
2     * cmds.c -- handles:
3 fabian 1.15 * commands from a user via dcc
4     * (split in 2, this portion contains no-irc commands)
5     *
6 segfault 1.1 * dprintf'ized, 3nov1995
7 fabian 1.15 *
8 fabian 1.18 * $Id: cmds.c,v 1.17 1999/12/22 12:24:58 fabian Exp $
9 segfault 1.1 */
10 fabian 1.15 /*
11     * Copyright (C) 1997 Robey Pointer
12     * Copyright (C) 1999 Eggheads
13     *
14     * This program is free software; you can redistribute it and/or
15     * modify it under the terms of the GNU General Public License
16     * as published by the Free Software Foundation; either version 2
17     * of the License, or (at your option) any later version.
18     *
19     * This program is distributed in the hope that it will be useful,
20     * but WITHOUT ANY WARRANTY; without even the implied warranty of
21     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22     * GNU General Public License for more details.
23     *
24     * You should have received a copy of the GNU General Public License
25     * along with this program; if not, write to the Free Software
26     * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27 segfault 1.1 */
28    
29     #include "main.h"
30     #include "tandem.h"
31     #include "modules.h"
32     #include <ctype.h>
33    
34     extern struct chanset_t *chanset;
35     extern struct dcc_t *dcc;
36     extern struct userrec *userlist;
37     extern tcl_timer_t *timer, *utimer;
38     extern int dcc_total, remote_boots, backgrd, make_userfile, do_restart;
39     extern int conmask, require_p;
40     extern int must_be_owner;
41 fabian 1.17 extern int use_silence;
42 segfault 1.1 extern Tcl_Interp *interp;
43     extern char botnetnick[], origbotname[], ver[];
44     extern char network[], owner[], spaces[];
45     extern time_t now, online_since;
46 fabian 1.14 extern int otraffic_irc, otraffic_irc_today;
47     extern int itraffic_irc, itraffic_irc_today;
48     extern int otraffic_bn, otraffic_bn_today;
49     extern int itraffic_bn, itraffic_bn_today;
50     extern int otraffic_dcc, otraffic_dcc_today;
51     extern int itraffic_dcc, itraffic_dcc_today;
52     extern int otraffic_trans, otraffic_trans_today;
53     extern int itraffic_trans, itraffic_trans_today;
54     extern int otraffic_unknown, otraffic_unknown_today;
55     extern int itraffic_unknown, itraffic_unknown_today;
56     static char *btos(int);
57 segfault 1.1
58     /* add hostmask to a bot's record if possible */
59     static int add_bot_hostmask(int idx, char *nick)
60     {
61     struct chanset_t *chan;
62     memberlist *m;
63     char s[UHOSTLEN];
64    
65     for (chan = chanset; chan; chan = chan->next) {
66     if (channel_active(chan)) {
67     m = ismember(chan, nick);
68     if (m) {
69     struct userrec *u;
70    
71     simple_sprintf(s, "%s!%s", m->nick, m->userhost);
72     u = get_user_by_host(s);
73     if (u) {
74     dprintf(idx, "(Can't add userhost for %s because it matches %s)\n",
75     nick, u->handle);
76     return 0;
77     }
78     simple_sprintf(s, "*!%s", m->userhost);
79 fabian 1.8 dprintf(idx, "(Added hostmask for %s from %s)\n", nick, chan->dname);
80 segfault 1.1 addhost_by_handle(nick, s);
81     return 1;
82     }
83     }
84     }
85     return 0;
86     }
87    
88     static void tell_who(struct userrec *u, int idx, int chan)
89     {
90     int i, k, ok = 0, atr = u ? u->flags : 0, len;
91     char s[1024]; /* temp fix - 1.4 has a better one */
92    
93     if (chan == 0)
94     dprintf(idx, "Party line members: (* = owner, + = master, @ = op)\n");
95     else {
96     simple_sprintf(s, "assoc %d", chan);
97     if ((Tcl_Eval(interp, s) != TCL_OK) || !interp->result[0])
98     dprintf(idx,
99     "People on channel %s%d: (* = owner, + = master, @ = op)\n",
100     (chan < 100000) ? "" : "*", chan % 100000);
101     else
102     dprintf(idx,
103     "People on channel '%s' (%s%d): (* = owner, + = master, @ = op)\n",
104     interp->result, (chan < 100000) ? "" : "*", chan % 100000);
105     }
106     for (i = 0; i < dcc_total; i++)
107     if (dcc[i].type == &DCC_CHAT)
108     if (dcc[i].u.chat->channel == chan) {
109     spaces[len = HANDLEN - strlen(dcc[i].nick)] = 0;
110     if (atr & USER_OWNER) {
111     sprintf(s, " [%.2lu] %c%s%s %s",
112     dcc[i].sock, (geticon(i) == '-' ? ' ' : geticon(i)),
113     dcc[i].nick, spaces, dcc[i].host);
114     } else {
115     sprintf(s, " %c%s%s %s",
116     (geticon(i) == '-' ? ' ' : geticon(i)),
117     dcc[i].nick, spaces, dcc[i].host);
118     }
119     spaces[len] = ' ';
120     if (atr & USER_MASTER) {
121     if (dcc[i].u.chat->con_flags)
122     sprintf(&s[strlen(s)], " (con:%s)",
123     masktype(dcc[i].u.chat->con_flags));
124     }
125     if (now - dcc[i].timeval > 300) {
126     unsigned long days, hrs, mins;
127    
128     days = (now - dcc[i].timeval) / 86400;
129     hrs = ((now - dcc[i].timeval) - (days * 86400)) / 3600;
130     mins = ((now - dcc[i].timeval) - (hrs * 3600)) / 60;
131     if (days > 0)
132     sprintf(&s[strlen(s)], " (idle %lud%luh)", days, hrs);
133     else if (hrs > 0)
134     sprintf(&s[strlen(s)], " (idle %luh%lum)", hrs, mins);
135     else
136     sprintf(&s[strlen(s)], " (idle %lum)", mins);
137     }
138     dprintf(idx, "%s\n", s);
139     if (dcc[i].u.chat->away != NULL)
140     dprintf(idx, " AWAY: %s\n", dcc[i].u.chat->away);
141     }
142     for (i = 0; i < dcc_total; i++)
143     if (dcc[i].type == &DCC_BOT) {
144     if (!ok) {
145     ok = 1;
146     dprintf(idx, "Bots connected:\n");
147     }
148     strcpy(s, ctime(&dcc[i].timeval));
149     strcpy(s, &s[1]);
150     s[9] = 0;
151     strcpy(s, &s[7]);
152     s[2] = ' ';
153     strcpy(&s[7], &s[10]);
154     s[12] = 0;
155     spaces[len = HANDLEN - strlen(dcc[i].nick)] = 0;
156     if (atr & USER_OWNER) {
157     dprintf(idx, " [%.2lu] %s%c%s%s (%s) %s\n",
158     dcc[i].sock, dcc[i].status & STAT_CALLED ? "<-" : "->",
159     dcc[i].status & STAT_SHARE ? '+' : ' ',
160     dcc[i].nick, spaces, s, dcc[i].u.bot->version);
161     } else {
162     dprintf(idx, " %s%c%s%s (%s) %s\n",
163     dcc[i].status & STAT_CALLED ? "<-" : "->",
164     dcc[i].status & STAT_SHARE ? '+' : ' ',
165     dcc[i].nick, spaces, s, dcc[i].u.bot->version);
166     }
167     spaces[len] = ' ';
168     }
169     ok = 0;
170     for (i = 0; i < dcc_total; i++) {
171     if ((dcc[i].type == &DCC_CHAT) && (dcc[i].u.chat->channel != chan)) {
172     if (!ok) {
173     ok = 1;
174     dprintf(idx, "Other people on the bot:\n");
175     }
176     spaces[len = HANDLEN - strlen(dcc[i].nick)] = 0;
177     if (atr & USER_OWNER) {
178     sprintf(s, " [%.2lu] %c%s%s ",
179     dcc[i].sock,
180     (geticon(i) == '-' ? ' ' : geticon(i)), dcc[i].nick,
181     spaces);
182     } else {
183     sprintf(s, " %c%s%s ",
184     (geticon(i) == '-' ? ' ' : geticon(i)), dcc[i].nick,
185     spaces);
186     }
187     spaces[len] = ' ';
188     if (atr & USER_MASTER) {
189     if (dcc[i].u.chat->channel < 0)
190     strcat(s, "(-OFF-) ");
191     else if (dcc[i].u.chat->channel == 0)
192     strcat(s, "(party) ");
193     else
194     sprintf(&s[strlen(s)], "(%5d) ", dcc[i].u.chat->channel);
195     }
196     strcat(s, dcc[i].host);
197     if (atr & USER_MASTER) {
198     if (dcc[i].u.chat->con_flags)
199     sprintf(&s[strlen(s)], " (con:%s)",
200     masktype(dcc[i].u.chat->con_flags));
201     }
202     if (now - dcc[i].timeval > 300) {
203     k = (now - dcc[i].timeval) / 60;
204     if (k < 60)
205     sprintf(&s[strlen(s)], " (idle %dm)", k);
206     else
207     sprintf(&s[strlen(s)], " (idle %dh%dm)", k / 60, k % 60);
208     }
209     dprintf(idx, "%s\n", s);
210     if (dcc[i].u.chat->away != NULL)
211     dprintf(idx, " AWAY: %s\n", dcc[i].u.chat->away);
212     }
213     if ((atr & USER_MASTER) && (dcc[i].type->flags & DCT_SHOWWHO) &&
214     (dcc[i].type != &DCC_CHAT)) {
215     if (!ok) {
216     ok = 1;
217     dprintf(idx, "Other people on the bot:\n");
218     }
219     spaces[len = HANDLEN - strlen(dcc[i].nick)] = 0;
220     if (atr & USER_OWNER) {
221     sprintf(s, " [%.2lu] %c%s%s (files) %s",
222     dcc[i].sock, dcc[i].status & STAT_CHAT ? '+' : ' ',
223     dcc[i].nick, spaces, dcc[i].host);
224     } else {
225     sprintf(s, " %c%s%s (files) %s",
226     dcc[i].status & STAT_CHAT ? '+' : ' ',
227     dcc[i].nick, spaces, dcc[i].host);
228     }
229     spaces[len] = ' ';
230     dprintf(idx, "%s\n", s);
231     }
232     }
233     }
234    
235     static void cmd_botinfo(struct userrec *u, int idx, char *par)
236     {
237     char s[512], s2[32];
238     struct chanset_t *chan;
239     time_t now2;
240     int hr, min;
241    
242 fabian 1.12 Context;
243 segfault 1.1 chan = chanset;
244     now2 = now - online_since;
245     s2[0] = 0;
246     if (now2 > 86400) {
247     int days = now2 / 86400;
248    
249     /* days */
250     sprintf(s2, "%d day", days);
251     if (days >= 2)
252     strcat(s2, "s");
253     strcat(s2, ", ");
254     now2 -= days * 86400;
255     }
256     hr = (time_t) ((int) now2 / 3600);
257     now2 -= (hr * 3600);
258     min = (time_t) ((int) now2 / 60);
259     sprintf(&s2[strlen(s2)], "%02d:%02d", (int) hr, (int) min);
260     putlog(LOG_CMDS, "*", "#%s# botinfo", dcc[idx].nick);
261     simple_sprintf(s, "%d:%s@%s", dcc[idx].sock, dcc[idx].nick, botnetnick);
262     botnet_send_infoq(-1, s);
263     s[0] = 0;
264     if (module_find("server", 0, 0)) {
265     while (chan != NULL) {
266     if (!channel_secret(chan)) {
267 fabian 1.8 if ((strlen(s) + strlen(chan->dname) + strlen(network)
268 segfault 1.1 + strlen(botnetnick) + strlen(ver) + 1) >= 490) {
269     strcat(s,"++ ");
270     break; /* yeesh! */
271     }
272 fabian 1.8 strcat(s, chan->dname);
273 segfault 1.1 strcat(s, ", ");
274     }
275     chan = chan->next;
276     }
277    
278     if (s[0]) {
279     s[strlen(s) - 2] = 0;
280     dprintf(idx, "*** [%s] %s <%s> (%s) [UP %s]\n", botnetnick,
281     ver, network, s, s2);
282     } else
283     dprintf(idx, "*** [%s] %s <%s> (%s) [UP %s]\n", botnetnick,
284     ver, network, BOT_NOCHANNELS, s2);
285     } else
286     dprintf(idx, "*** [%s] %s <NO_IRC> [UP %s]\n", botnetnick, ver, s2);
287     }
288    
289     static void cmd_whom(struct userrec *u, int idx, char *par)
290     {
291     if (par[0] == '*') {
292     putlog(LOG_CMDS, "*", "#%s# whom %s", dcc[idx].nick, par);
293     answer_local_whom(idx, -1);
294     return;
295     } else if (dcc[idx].u.chat->channel < 0) {
296     dprintf(idx, "You have chat turned off.\n");
297     return;
298     }
299     putlog(LOG_CMDS, "*", "#%s# whom %s", dcc[idx].nick, par);
300     if (!par[0]) {
301     answer_local_whom(idx, dcc[idx].u.chat->channel);
302     } else {
303     int chan = -1;
304    
305     if ((par[0] < '0') || (par[0] > '9')) {
306     Tcl_SetVar(interp, "chan", par, 0);
307     if ((Tcl_VarEval(interp, "assoc ", "$chan", NULL) == TCL_OK) &&
308     interp->result[0]) {
309     chan = atoi(interp->result);
310     }
311     if (chan <= 0) {
312     dprintf(idx, "No such channel.\n");
313     return;
314     }
315     } else
316     chan = atoi(par);
317     if ((chan < 0) || (chan > 99999)) {
318     dprintf(idx, "Channel # out of range: must be 0-99999\n");
319     return;
320     }
321     answer_local_whom(idx, chan);
322     }
323     }
324    
325     static void cmd_me(struct userrec *u, int idx, char *par)
326     {
327     int i;
328    
329     if (dcc[idx].u.chat->channel < 0) {
330     dprintf(idx, "You have chat turned off.\n");
331     return;
332     }
333     if (!par[0]) {
334     dprintf(idx, "Usage: me <action>\n");
335     return;
336     }
337     if (dcc[idx].u.chat->away != NULL)
338     not_away(idx);
339     for (i = 0; i < dcc_total; i++)
340     if ((dcc[i].type->flags & DCT_CHAT) &&
341     (dcc[i].u.chat->channel == dcc[idx].u.chat->channel) &&
342     ((i != idx) || (dcc[i].status & STAT_ECHO)))
343     dprintf(i, "* %s %s\n", dcc[idx].nick, par);
344     botnet_send_act(idx, botnetnick, dcc[idx].nick,
345     dcc[idx].u.chat->channel, par);
346     check_tcl_act(dcc[idx].nick, dcc[idx].u.chat->channel, par);
347     }
348    
349     static void cmd_motd(struct userrec *u, int idx, char *par)
350     {
351     int i;
352    
353     if (par[0]) {
354     putlog(LOG_CMDS, "*", "#%s# motd %s", dcc[idx].nick, par);
355     if (!strcasecmp(par, botnetnick))
356     show_motd(idx);
357     else {
358     i = nextbot(par);
359     if (i < 0)
360     dprintf(idx, "That bot isn't connected.\n");
361     else {
362     char x[40];
363    
364     simple_sprintf(x, "%s%d:%s@%s",
365     (u->flags & USER_HIGHLITE) ?
366     ((dcc[idx].status & STAT_TELNET) ? "#" : "!") : "",
367     dcc[idx].sock, dcc[idx].nick, botnetnick);
368     botnet_send_motd(i, x, par);
369     }
370     }
371     } else {
372     putlog(LOG_CMDS, "*", "#%s# motd", dcc[idx].nick);
373     show_motd(idx);
374     }
375     }
376    
377     static void cmd_away(struct userrec *u, int idx, char *par)
378     {
379     if (strlen(par) > 60)
380     par[60] = 0;
381     set_away(idx, par);
382     }
383    
384     static void cmd_back(struct userrec *u, int idx, char *par)
385     {
386     not_away(idx);
387     }
388    
389     static void cmd_newpass(struct userrec *u, int idx, char *par)
390     {
391     char *new;
392    
393     if (!par[0]) {
394     dprintf(idx, "Usage: newpass <newpassword>\n");
395     return;
396     }
397     new = newsplit(&par);
398     if (strlen(new) > 16)
399     new[16] = 0;
400     if (strlen(new) < 6) {
401     dprintf(idx, "Please use at least 6 characters.\n");
402     return;
403     }
404     set_user(&USERENTRY_PASS, u, new);
405     putlog(LOG_CMDS, "*", "#%s# newpass...", dcc[idx].nick);
406     dprintf(idx, "Changed password to '%s'\n", new);
407     }
408    
409     static void cmd_bots(struct userrec *u, int idx, char *par)
410     {
411     putlog(LOG_CMDS, "*", "#%s# bots", dcc[idx].nick);
412     tell_bots(idx);
413     }
414    
415     static void cmd_bottree(struct userrec *u, int idx, char *par)
416     {
417     putlog(LOG_CMDS, "*", "#%s# bottree", dcc[idx].nick);
418     tell_bottree(idx, 0);
419     }
420    
421     static void cmd_vbottree(struct userrec *u, int idx, char *par)
422     {
423     putlog(LOG_CMDS, "*", "#%s# vbottree", dcc[idx].nick);
424     tell_bottree(idx, 1);
425     }
426    
427     static void cmd_rehelp(struct userrec *u, int idx, char *par)
428     {
429     putlog(LOG_CMDS, "*", "#%s# rehelp", dcc[idx].nick);
430     dprintf(idx, "Reload help cache...\n");
431     reload_help_data();
432     }
433    
434     static void cmd_help(struct userrec *u, int idx, char *par)
435     {
436 fabian 1.4 struct flag_record fr = {FR_GLOBAL | FR_CHAN, 0, 0, 0, 0, 0};
437 segfault 1.1
438     get_user_flagrec(u, &fr, dcc[idx].u.chat->con_chan);
439     if (par[0]) {
440     putlog(LOG_CMDS, "*", "#%s# help %s", dcc[idx].nick, par);
441     if (!strcmp(par, "all"))
442     tellallhelp(idx, "all", &fr);
443 fabian 1.4 else if (strchr(par, '*') || strchr(par, '?')) {
444     char *p = par;
445    
446     /* Check if the search pattern only consists of '*' and/or '?'
447     * If it does, show help for "all" instead of listing all help
448     * entries. */
449     for (p = par; *p && ((*p == '*') || (*p == '?')); p++);
450     if (*p)
451     tellwildhelp(idx, par, &fr);
452     else
453     tellallhelp(idx, "all", &fr);
454     } else
455 segfault 1.1 tellhelp(idx, par, &fr, 0);
456     } else {
457     putlog(LOG_CMDS, "*", "#%s# help", dcc[idx].nick);
458     if (glob_op(fr) || glob_botmast(fr) || chan_op(fr))
459     tellhelp(idx, "help", &fr, 0);
460     else
461     tellhelp(idx, "helpparty", &fr, 0);
462     }
463     }
464    
465     static void cmd_addlog(struct userrec *u, int idx, char *par)
466     {
467     if (!par[0]) {
468     dprintf(idx, "Usage: addlog <message>\n");
469     return;
470     }
471     dprintf(idx, "Placed entry in the log file.\n");
472     putlog(LOG_MISC, "*", "%s: %s", dcc[idx].nick, par);
473     }
474    
475     static void cmd_who(struct userrec *u, int idx, char *par)
476     {
477     int i;
478    
479     if (par[0]) {
480     if (dcc[idx].u.chat->channel < 0) {
481     dprintf(idx, "You have chat turned off.\n");
482     return;
483     }
484     putlog(LOG_CMDS, "*", "#%s# who %s", dcc[idx].nick, par);
485     if (!strcasecmp(par, botnetnick))
486     tell_who(u, idx, dcc[idx].u.chat->channel);
487     else {
488     i = nextbot(par);
489     if (i < 0) {
490     dprintf(idx, "That bot isn't connected.\n");
491     } else if (dcc[idx].u.chat->channel > 99999)
492     dprintf(idx, "You are on a local channel\n");
493     else {
494     char s[40];
495    
496     simple_sprintf(s, "%d:%s@%s", dcc[idx].sock,
497     dcc[idx].nick, botnetnick);
498     botnet_send_who(i, s, par, dcc[idx].u.chat->channel);
499     }
500     }
501     } else {
502     putlog(LOG_CMDS, "*", "#%s# who", dcc[idx].nick);
503     if (dcc[idx].u.chat->channel < 0)
504     tell_who(u, idx, 0);
505     else
506     tell_who(u, idx, dcc[idx].u.chat->channel);
507     }
508     }
509    
510     static void cmd_whois(struct userrec *u, int idx, char *par)
511     {
512     if (!par[0]) {
513     dprintf(idx, "Usage: whois <handle>\n");
514     return;
515     }
516     putlog(LOG_CMDS, "*", "#%s# whois %s", dcc[idx].nick, par);
517     tell_user_ident(idx, par, u ? (u->flags & USER_MASTER) : 0);
518     }
519    
520     static void cmd_match(struct userrec *u, int idx, char *par)
521     {
522     int start = 1, limit = 20;
523     char *s, *s1, *chname;
524    
525     if (!par[0]) {
526     dprintf(idx, "Usage: match <nick/host> [[skip] count]\n");
527     return;
528     }
529     putlog(LOG_CMDS, "*", "#%s# match %s", dcc[idx].nick, par);
530     s = newsplit(&par);
531     if (strchr(CHANMETA, par[0]) != NULL)
532     chname = newsplit(&par);
533     else
534     chname = "";
535     if (atoi(par) > 0) {
536     s1 = newsplit(&par);
537     if (atoi(par) > 0) {
538     start = atoi(s1);
539     limit = atoi(par);
540     } else
541     limit = atoi(s1);
542     }
543     tell_users_match(idx, s, start, limit, u ? (u->flags & USER_MASTER) : 0,
544     chname);
545     }
546    
547     static void cmd_uptime(struct userrec *u, int idx, char *par)
548     {
549     putlog(LOG_CMDS, "*", "#%s# uptime", dcc[idx].nick);
550     tell_verbose_uptime(idx);
551     }
552    
553     static void cmd_status(struct userrec *u, int idx, char *par)
554     {
555     int atr = u ? u->flags : 0;
556    
557     if (!strcasecmp(par, "all")) {
558     if (!(atr & USER_MASTER)) {
559     dprintf(idx, "You do not have Bot Master privileges.\n");
560     return;
561     }
562     putlog(LOG_CMDS, "*", "#%s# status all", dcc[idx].nick);
563     tell_verbose_status(idx);
564     tell_mem_status_dcc(idx);
565     dprintf(idx, "\n");
566     tell_settings(idx);
567     do_module_report(idx, 1, NULL);
568     } else {
569     putlog(LOG_CMDS, "*", "#%s# status", dcc[idx].nick);
570     tell_verbose_status(idx);
571     tell_mem_status_dcc(idx);
572     do_module_report(idx, 0, NULL);
573     }
574     }
575    
576     static void cmd_dccstat(struct userrec *u, int idx, char *par)
577     {
578     putlog(LOG_CMDS, "*", "#%s# dccstat", dcc[idx].nick);
579     tell_dcc(idx);
580     }
581    
582     static void cmd_boot(struct userrec *u, int idx, char *par)
583     {
584     int i, files = 0, ok = 0;
585     char *who;
586     struct userrec *u2;
587    
588     if (!par[0]) {
589     dprintf(idx, "Usage: boot nick[@bot]\n");
590     return;
591     }
592     who = newsplit(&par);
593     if (strchr(who, '@') != NULL) {
594     char whonick[512];
595    
596     splitc(whonick, who, '@');
597     whonick[20] = 0;
598     if (!strcasecmp(who, botnetnick)) {
599     cmd_boot(u, idx, whonick);
600     return;
601     }
602     if (remote_boots > 0) {
603     i = nextbot(who);
604     if (i < 0) {
605     dprintf(idx, "No such bot connected.\n");
606     return;
607     }
608     botnet_send_reject(i, dcc[idx].nick, botnetnick, whonick,
609     who, par[0] ? par : dcc[idx].nick);
610 fabian 1.7 putlog(LOG_BOTS, "*", "#%s# boot %s@%s (%s)", dcc[idx].nick, whonick,
611 segfault 1.1 who, par[0] ? par : dcc[idx].nick);
612     } else
613     dprintf(idx, "Remote boots are disabled here.\n");
614     return;
615     }
616     for (i = 0; i < dcc_total; i++)
617     if (!strcasecmp(dcc[i].nick, who) && !ok &&
618     (dcc[i].type->flags & DCT_CANBOOT)) {
619     u2 = get_user_by_handle(userlist, dcc[i].nick);
620     if (u2 && (u2->flags & USER_OWNER) &&
621     strcasecmp(dcc[idx].nick, who)) {
622     dprintf(idx, "Can't boot the bot owner.\n");
623     return;
624     }
625     if (u2 && (u2->flags & USER_MASTER) &&
626     !(u && (u->flags & USER_MASTER))) {
627     dprintf(idx, "Can't boot a bot master.\n");
628     return;
629     }
630     files = (dcc[i].type->flags & DCT_FILES);
631     if (files)
632     dprintf(idx, "Booted %s from the file section.\n", dcc[i].nick);
633     else
634     dprintf(idx, "Booted %s from the bot.\n", dcc[i].nick);
635     putlog(LOG_CMDS, "*", "#%s# boot %s %s", dcc[idx].nick, who, par);
636     do_boot(i, dcc[idx].nick, par);
637     ok = 1;
638     }
639     if (!ok)
640     dprintf(idx, "Who? No such person on the party line.\n");
641     }
642    
643     static void cmd_console(struct userrec *u, int idx, char *par)
644     {
645     char *nick, s[2], s1[512];
646     int dest = 0, i, ok = 0, pls, md;
647 fabian 1.8 struct flag_record fr = {FR_GLOBAL | FR_CHAN, 0, 0, 0, 0, 0};
648 segfault 1.1 module_entry *me;
649    
650     if (!par[0]) {
651     dprintf(idx, "Your console is %s: %s (%s)\n",
652     dcc[idx].u.chat->con_chan,
653     masktype(dcc[idx].u.chat->con_flags),
654     maskname(dcc[idx].u.chat->con_flags));
655     return;
656     }
657     get_user_flagrec(u, &fr, dcc[idx].u.chat->con_chan);
658     strcpy(s1, par);
659     nick = newsplit(&par);
660 fabian 1.6 /* don't remove '+' as someone couldn't have '+' in CHANMETA cause
661     * he doesn't use br0ken IRCnet ++rtc */
662     if (nick[0] && !strchr(CHANMETA "+-*", nick[0]) && glob_master(fr)) {
663 segfault 1.1 for (i = 0; i < dcc_total; i++)
664     if (!strcasecmp(nick, dcc[i].nick) &&
665     (dcc[i].type == &DCC_CHAT) && (!ok)) {
666     ok = 1;
667     dest = i;
668     }
669     if (!ok) {
670     dprintf(idx, "No such user on the party line!\n");
671     return;
672     }
673     nick[0] = 0;
674     } else
675     dest = idx;
676     if (!nick[0])
677     nick = newsplit(&par);
678 fabian 1.10 /* ugly hack for modeless channels -- rtc */
679 fabian 1.8 if ((nick [0] == '+' && findchan_by_dname(nick)) ||
680 fabian 1.6 (nick [0] != '+' && strchr(CHANMETA "*", nick[0]))) {
681 fabian 1.8 if (strcmp(nick, "*") && !findchan_by_dname(nick)) {
682 segfault 1.1 dprintf(idx, "Invalid console channel: %s\n", nick);
683     return;
684     }
685     get_user_flagrec(u, &fr, nick);
686     if (!chan_op(fr) && !(glob_op(fr) && !chan_deop(fr))) {
687     dprintf(idx, "You don't have op or master access to channel %s\n",
688     nick);
689     return;
690     }
691 fabian 1.8 strncpy(dcc[dest].u.chat->con_chan, nick, 81);
692 segfault 1.1 dcc[dest].u.chat->con_chan[80] = 0;
693     nick[0] = 0;
694     if ((dest == idx) && !glob_master(fr) && !chan_master(fr))
695     /* consoling to another channel for self */
696     dcc[dest].u.chat->con_flags &= ~(LOG_MISC | LOG_CMDS | LOG_WALL);
697     }
698     if (!nick[0])
699     nick = newsplit(&par);
700     pls = 1;
701     if (nick[0]) {
702     if ((nick[0] != '+') && (nick[0] != '-'))
703     dcc[dest].u.chat->con_flags = 0;
704     for (; *nick; nick++) {
705     if (*nick == '+')
706     pls = 1;
707     else if (*nick == '-')
708     pls = 0;
709     else {
710     s[0] = *nick;
711     s[1] = 0;
712     md = logmodes(s);
713     if ((dest == idx) && !glob_master(fr) && pls) {
714     if (chan_master(fr))
715     md &= ~(LOG_FILES | LOG_LEV1 | LOG_LEV2 | LOG_LEV3 |
716     LOG_LEV4 | LOG_LEV5 | LOG_LEV6 | LOG_LEV7 |
717     LOG_LEV8 | LOG_DEBUG);
718     else
719     md &= ~(LOG_MISC | LOG_CMDS | LOG_FILES | LOG_LEV1 |
720     LOG_LEV2 | LOG_LEV3 | LOG_LEV4 | LOG_LEV5 |
721     LOG_LEV6 | LOG_LEV7 | LOG_LEV8 | LOG_WALL |
722     LOG_DEBUG);
723     }
724     if (!glob_owner(fr) && pls)
725     md &= ~(LOG_RAW | LOG_SRVOUT | LOG_BOTNET | LOG_BOTSHARE);
726     if (!glob_botmast(fr) && pls)
727     md &= ~LOG_BOTS;
728     if (pls)
729     dcc[dest].u.chat->con_flags |= md;
730     else
731     dcc[dest].u.chat->con_flags &= ~md;
732     }
733     }
734     }
735     putlog(LOG_CMDS, "*", "#%s# console %s", dcc[idx].nick, s1);
736     if (dest == idx) {
737     dprintf(idx, "Set your console to %s: %s (%s)\n",
738     dcc[idx].u.chat->con_chan,
739     masktype(dcc[idx].u.chat->con_flags),
740     maskname(dcc[idx].u.chat->con_flags));
741     } else {
742     dprintf(idx, "Set console of %s to %s: %s (%s)\n", dcc[dest].nick,
743     dcc[dest].u.chat->con_chan,
744     masktype(dcc[dest].u.chat->con_flags),
745     maskname(dcc[dest].u.chat->con_flags));
746     dprintf(dest, "%s set your console to %s: %s (%s)\n", dcc[idx].nick,
747     dcc[dest].u.chat->con_chan,
748     masktype(dcc[dest].u.chat->con_flags),
749     maskname(dcc[dest].u.chat->con_flags));
750     }
751     /* new style autosave -- drummer,07/25/1999*/
752 fabian 1.2 if ((me = module_find("console", 1, 1))) {
753 segfault 1.1 Function *func = me->funcs;
754 fabian 1.3 (func[CONSOLE_DOSTORE]) (dest);
755 segfault 1.1 }
756     }
757    
758     static void cmd_pls_bot(struct userrec *u, int idx, char *par)
759     {
760     char *handle, *addr, *p, *q, *host;
761     struct userrec *u1;
762     struct bot_addr *bi;
763    
764     if (!par[0])
765     dprintf(idx, "Usage: +bot <handle> <address[:telnet-port[/relay-port]]> [host]\n");
766     else {
767     handle = newsplit(&par);
768     addr = newsplit(&par);
769     if (strlen(handle) > HANDLEN)
770     handle[HANDLEN] = 0; /* max len = XX .. for the moment :) */
771     if (get_user_by_handle(userlist, handle))
772     dprintf(idx, "Someone already exists by that name.\n");
773 fabian 1.6 else if (strchr(BADHANDCHARS, handle[0]) != NULL)
774 segfault 1.1 dprintf(idx, "You can't start a botnick with '%c'.\n", handle[0]);
775     else {
776     if (strlen(addr) > 60)
777     addr[60] = 0;
778     putlog(LOG_CMDS, "*", "#%s# +bot %s %s", dcc[idx].nick, handle, addr);
779     userlist = adduser(userlist, handle, "none", "-", USER_BOT);
780     u1 = get_user_by_handle(userlist, handle);
781     bi = user_malloc(sizeof(struct bot_addr));
782    
783     q = strchr(addr, ':');
784     if (!q) {
785     bi->address = user_malloc(strlen(addr) + 1);
786     strcpy(bi->address, addr);
787     bi->telnet_port = 3333;
788     bi->relay_port = 3333;
789     } else {
790     bi->address = user_malloc(q - addr + 1);
791     strncpy(bi->address, addr, q - addr);
792     bi->address[q - addr] = 0;
793     p = q + 1;
794     bi->telnet_port = atoi(p);
795     q = strchr(p, '/');
796     if (!q) {
797     bi->relay_port = bi->telnet_port;
798     } else {
799     bi->relay_port = atoi(q + 1);
800     }
801     }
802     set_user(&USERENTRY_BOTADDR, u1, bi);
803     dprintf(idx, "Added bot '%s' with address '%s' and no password.\n",
804     handle, addr);
805     host = newsplit(&par);
806     if (host[0]) {
807     addhost_by_handle(handle, host);
808     } else if (!add_bot_hostmask(idx, handle))
809     dprintf(idx, "You'll want to add a hostmask if this bot will ever %s",
810     "be on any channels that I'm on.\n");
811     }
812     }
813     }
814    
815     static void cmd_chnick(struct userrec *u, int idx, char *par)
816     {
817 fabian 1.2 char hand[HANDLEN + 1], newhand[HANDLEN + 1];
818 segfault 1.1 int i, atr = u ? u->flags : 0, atr2;
819     struct userrec *u2;
820    
821 fabian 1.2 strncpy(hand, newsplit(&par), sizeof(hand));
822 fabian 1.5 hand[HANDLEN] = 0;
823 fabian 1.2 strncpy(newhand, newsplit(&par), sizeof(newhand));
824 fabian 1.5 newhand[HANDLEN] = 0;
825 fabian 1.2
826     if (!hand[0] || !newhand[0]) {
827 segfault 1.1 dprintf(idx, "Usage: chnick <oldnick> <newnick>\n");
828 fabian 1.2 return;
829     }
830     for (i = 0; i < strlen(newhand); i++)
831     if ((newhand[i] <= 32) || (newhand[i] >= 127) || (newhand[i] == '@'))
832     newhand[i] = '?';
833 fabian 1.6 if (strchr(BADHANDCHARS, newhand[0]) != NULL)
834 fabian 1.2 dprintf(idx, "Bizarre quantum forces prevent nicknames from starting with %c\n",
835     newhand[0]);
836     else if (get_user_by_handle(userlist, newhand) &&
837     strcasecmp(hand, newhand))
838     dprintf(idx, "Somebody is already using %s.\n", newhand);
839 segfault 1.1 else {
840 fabian 1.2 u2 = get_user_by_handle(userlist, hand);
841     atr2 = u2 ? u2->flags : 0;
842     if ((atr & USER_BOTMAST) && !(atr & USER_MASTER) &&
843     !(atr2 & USER_BOT))
844     dprintf(idx, "You can't change nick for non-bots.\n");
845     else if ((bot_flags(u2) & BOT_SHARE) && !(atr & USER_OWNER))
846     dprintf(idx, "You can't change shared bot's nick.\n");
847     else if ((atr2 & USER_OWNER) && !(atr & USER_OWNER) &&
848     strcasecmp(dcc[idx].nick, hand))
849     dprintf(idx, "Can't change the bot owner's handle.\n");
850     else if (isowner(hand) && strcasecmp(dcc[idx].nick, hand))
851     dprintf(idx, "Can't change the permanent bot owner's handle.\n");
852 fabian 1.6 else if (!strcasecmp(newhand, botnetnick) && (!(atr2 & USER_BOT) ||
853     nextbot(hand) != -1))
854     dprintf(idx, "Hey! That's MY name!\n");
855 fabian 1.2 else if (change_handle(u2, newhand)) {
856     putlog(LOG_CMDS, "*", "#%s# chnick %s %s", dcc[idx].nick,
857     hand, newhand);
858     dprintf(idx, "Changed.\n");
859     } else
860     dprintf(idx, "Failed.\n");
861 segfault 1.1 }
862     }
863    
864     static void cmd_nick(struct userrec *u, int idx, char *par)
865     {
866 fabian 1.2 char oldnick[HANDLEN + 1], newnick[HANDLEN + 1];
867     int i;
868    
869 fabian 1.6 strncpy(newnick, newsplit(&par), HANDLEN);
870 fabian 1.5 newnick[HANDLEN] = 0;
871 segfault 1.1
872 fabian 1.2 if (!newnick[0]) {
873 segfault 1.1 dprintf(idx, "Usage: nick <new-handle>\n");
874     return;
875     }
876 fabian 1.2 for (i = 0; i < strlen(newnick); i++)
877 segfault 1.1 if ((newnick[i] <= 32) || (newnick[i] >= 127) || (newnick[i] == '@'))
878     newnick[i] = '?';
879 fabian 1.6 if (strchr(BADHANDCHARS, newnick[0]) != NULL) {
880 segfault 1.1 dprintf(idx, "Bizarre quantum forces prevent nicknames from starting with '%c'\n",
881     newnick[0]);
882     } else if (get_user_by_handle(userlist, newnick) &&
883     strcasecmp(dcc[idx].nick, newnick)) {
884     dprintf(idx, "Somebody is already using %s.\n", newnick);
885 fabian 1.2 } else if (!strcasecmp(newnick, botnetnick)) {
886     dprintf(idx, "Hey! That's MY name!\n");
887 segfault 1.1 } else {
888 fabian 1.6 strncpy(oldnick, dcc[idx].nick, HANDLEN);
889     oldnick[HANDLEN] = 0;
890 segfault 1.1 if (change_handle(u, newnick)) {
891     putlog(LOG_CMDS, "*", "#%s# nick %s", oldnick, newnick);
892     dprintf(idx, "Okay, changed.\n");
893     } else
894     dprintf(idx, "Failed.\n");
895     }
896     }
897    
898     static void cmd_chpass(struct userrec *u, int idx, char *par)
899     {
900     char *handle, *new;
901     int atr = u ? u->flags : 0, l;
902    
903     if (!par[0])
904     dprintf(idx, "Usage: chpass <handle> [password]\n");
905     else {
906     handle = newsplit(&par);
907     u = get_user_by_handle(userlist, handle);
908     if (!u)
909     dprintf(idx, "No such user.\n");
910     else if ((atr & USER_BOTMAST) && !(atr & USER_MASTER) &&
911     !(u->flags & USER_BOT))
912     dprintf(idx, "You can't change password for non-bots.\n");
913     else if ((bot_flags(u) & BOT_SHARE) && !(atr & USER_OWNER))
914     dprintf(idx, "You can't change shared bot's password.\n");
915     else if ((u->flags & USER_OWNER) && !(atr & USER_OWNER) &&
916     strcasecmp(handle, dcc[idx].nick))
917     dprintf(idx, "Can't change the bot owner's password.\n");
918 fabian 1.2 else if (isowner(handle) && strcasecmp(dcc[idx].nick, handle))
919     dprintf(idx, "Can't change the permanent bot owner's handle.\n");
920 segfault 1.1 else if (!par[0]) {
921     putlog(LOG_CMDS, "*", "#%s# chpass %s [nothing]", dcc[idx].nick,
922     handle);
923     set_user(&USERENTRY_PASS, u, NULL);
924     dprintf(idx, "Removed password.\n");
925     } else {
926     l = strlen(new = newsplit(&par));
927     if (l > 16)
928     new[16] = 0;
929     if (l < 6)
930     dprintf(idx, "Please use at least 6 characters.\n");
931     else {
932     set_user(&USERENTRY_PASS, u, new);
933     putlog(LOG_CMDS, "*", "#%s# chpass %s [something]", dcc[idx].nick,
934     handle);
935     dprintf(idx, "Changed password.\n");
936     }
937     }
938     }
939     }
940    
941     static void cmd_chaddr(struct userrec *u, int idx, char *par)
942     {
943     char *handle, *addr, *p, *q;
944     struct bot_addr *bi;
945     struct userrec *u1;
946    
947     if (!par[0]) {
948     dprintf(idx, "Usage: chaddr <botname> <address:botport#/userport#>\n");
949     return;
950     }
951     handle = newsplit(&par);
952     addr = newsplit(&par);
953 fabian 1.6 if (strlen(addr) > UHOSTMAX)
954     addr[UHOSTMAX] = 0;
955 segfault 1.1 u1 = get_user_by_handle(userlist, handle);
956     if (!u1 || !(u1->flags & USER_BOT)) {
957     dprintf(idx, "Useful only for tandem bots.\n");
958     return;
959     }
960     if ((bot_flags(u1) & BOT_SHARE) && (!u || !u->flags & USER_OWNER)) {
961     dprintf(idx, "You can't change shared bot's address.\n");
962     return;
963     }
964     putlog(LOG_CMDS, "*", "#%s# chaddr %s %s", dcc[idx].nick, handle, addr);
965     dprintf(idx, "Changed bot's address.\n");
966     bi = user_malloc(sizeof(struct bot_addr));
967    
968     q = strchr(addr, ':');
969     if (!q) {
970     bi->address = user_malloc(strlen(addr) + 1);
971     strcpy(bi->address, addr);
972     bi->telnet_port = 3333;
973     bi->relay_port = 3333;
974     } else {
975     bi->address = user_malloc(q - addr + 1);
976     strncpy(bi->address, addr, q - addr);
977     bi->address[q - addr] = 0;
978     p = q + 1;
979     bi->telnet_port = atoi(p);
980     q = strchr(p, '/');
981     if (!q) {
982     bi->relay_port = bi->telnet_port;
983     } else {
984     bi->relay_port = atoi(q + 1);
985     }
986     }
987     set_user(&USERENTRY_BOTADDR, u1, bi);
988     }
989    
990     static void cmd_comment(struct userrec *u, int idx, char *par)
991     {
992     char *handle;
993     struct userrec *u1;
994    
995     if (!par[0]) {
996     dprintf(idx, "Usage: comment <handle> <newcomment>\n");
997     return;
998     }
999     handle = newsplit(&par);
1000     u1 = get_user_by_handle(userlist, handle);
1001     if (!u1) {
1002     dprintf(idx, "No such user!\n");
1003     return;
1004     }
1005     if ((u1->flags & USER_OWNER) && !(u && (u->flags & USER_OWNER)) &&
1006     strcasecmp(handle, dcc[idx].nick)) {
1007     dprintf(idx, "Can't change comment on the bot owner.\n");
1008     return;
1009     }
1010     putlog(LOG_CMDS, "*", "#%s# comment %s %s", dcc[idx].nick, handle, par);
1011     if (!strcasecmp(par, "none")) {
1012     dprintf(idx, "Okay, comment blanked.\n");
1013     set_user(&USERENTRY_COMMENT, u1, NULL);
1014     return;
1015     }
1016     dprintf(idx, "Changed comment.\n");
1017     set_user(&USERENTRY_COMMENT, u1, par);
1018     }
1019    
1020     static void cmd_restart(struct userrec *u, int idx, char *par)
1021     {
1022     putlog(LOG_CMDS, "*", "#%s# restart", dcc[idx].nick);
1023     if (!backgrd) {
1024     dprintf(idx, "You can not .restart a bot when running -n (due to tcl)\n");
1025     return;
1026     }
1027     dprintf(idx, "Restarting.\n");
1028     if (make_userfile) {
1029     putlog(LOG_MISC, "*",
1030     "Uh, guess you don't need to create a new userfile.");
1031     make_userfile = 0;
1032     }
1033     write_userfile(-1);
1034     putlog(LOG_MISC, "*", "Restarting ...");
1035     wipe_timers(interp, &utimer);
1036     wipe_timers(interp, &timer);
1037     do_restart = idx;
1038     }
1039    
1040     static void cmd_rehash(struct userrec *u, int idx, char *par)
1041     {
1042     putlog(LOG_CMDS, "*", "#%s# rehash", dcc[idx].nick);
1043     dprintf(idx, "Rehashing.\n");
1044     if (make_userfile) {
1045     putlog(LOG_MISC, "*",
1046     "Uh, guess you don't need to create a new userfile.");
1047     make_userfile = 0;
1048     }
1049     write_userfile(-1);
1050     putlog(LOG_MISC, "*", "Rehashing ...");
1051     do_restart = -2;
1052     }
1053    
1054     static void cmd_reload(struct userrec *u, int idx, char *par)
1055     {
1056     putlog(LOG_CMDS, "*", "#%s# reload", dcc[idx].nick);
1057     dprintf(idx, "Reloading user file...\n");
1058     reload();
1059     }
1060    
1061     /* this get replaced in server.so with a version that handles the server */
1062     void cmd_die(struct userrec *u, int idx, char *par)
1063     {
1064     char s[1024];
1065    
1066     putlog(LOG_CMDS, "*", "#%s# die %s", dcc[idx].nick, par);
1067     if (par[0]) {
1068     simple_sprintf(s, "BOT SHUTDOWN (%s: %s)", dcc[idx].nick, par);
1069     } else {
1070     simple_sprintf(s, "BOT SHUTDOWN (authorized by %s)", dcc[idx].nick);
1071     }
1072     chatout("*** %s\n", s);
1073     botnet_send_chat(-1, botnetnick, s);
1074     botnet_send_bye();
1075     write_userfile(-1);
1076     simple_sprintf(s, "DIE BY %s!%s (%s)", dcc[idx].nick,
1077     dcc[idx].host, par[0] ? par : "request");
1078     fatal(s, 0);
1079     }
1080    
1081     static void cmd_debug(struct userrec *u, int idx, char *par)
1082     {
1083     if (!strcasecmp(par, "help")) {
1084     putlog(LOG_CMDS, "*", "#%s# debug help", dcc[idx].nick);
1085     debug_help(idx);
1086     } else {
1087     putlog(LOG_CMDS, "*", "#%s# debug", dcc[idx].nick);
1088     debug_mem_to_dcc(idx);
1089     }
1090     }
1091    
1092     static void cmd_simul(struct userrec *u, int idx, char *par)
1093     {
1094     char *nick;
1095     int i, ok = 0;
1096    
1097     nick = newsplit(&par);
1098     if (!par[0]) {
1099     dprintf(idx, "Usage: simul <nick> <text>\n");
1100     return;
1101     }
1102     if (isowner(nick)) {
1103     dprintf(idx, "Unable to '.simul' permanent owners.\n");
1104     return;
1105     }
1106     for (i = 0; i < dcc_total; i++)
1107     if (!strcasecmp(nick, dcc[i].nick) && !ok &&
1108     (dcc[i].type->flags & DCT_SIMUL)) {
1109     putlog(LOG_CMDS, "*", "#%s# simul %s %s", dcc[idx].nick, nick, par);
1110     if (dcc[i].type && dcc[i].type->activity) {
1111     dcc[i].type->activity(i, par, strlen(par));
1112     ok = 1;
1113     }
1114     }
1115     if (!ok)
1116     dprintf(idx, "No such user on the party line.\n");
1117     }
1118    
1119     static void cmd_link(struct userrec *u, int idx, char *par)
1120     {
1121     char *s;
1122     int i;
1123    
1124     if (!par[0]) {
1125     dprintf(idx, "Usage: link [some-bot] <new-bot>\n");
1126     return;
1127     }
1128     putlog(LOG_CMDS, "*", "#%s# link %s", dcc[idx].nick, par);
1129     s = newsplit(&par);
1130     if (!par[0] || !strcasecmp(par, botnetnick))
1131     botlink(dcc[idx].nick, idx, s);
1132     else {
1133     char x[40];
1134    
1135     i = nextbot(s);
1136     if (i < 0) {
1137     dprintf(idx, "No such bot online.\n");
1138     return;
1139     }
1140     simple_sprintf(x, "%d:%s@%s", dcc[idx].sock, dcc[idx].nick, botnetnick);
1141     botnet_send_link(i, x, s, par);
1142     }
1143     }
1144    
1145     static void cmd_unlink(struct userrec *u, int idx, char *par)
1146     {
1147     int i;
1148     char *bot;
1149    
1150     if (!par[0]) {
1151     dprintf(idx, "Usage: unlink <bot> [reason]\n");
1152     return;
1153     }
1154     putlog(LOG_CMDS, "*", "#%s# unlink %s", dcc[idx].nick, par);
1155     bot = newsplit(&par);
1156     i = nextbot(bot);
1157     if (i < 0) {
1158     botunlink(idx, bot, par);
1159     return;
1160     }
1161     /* if we're directly connected to that bot, just do it
1162     * (is nike gunna sue?) */
1163     if (!strcasecmp(dcc[i].nick, bot))
1164     botunlink(idx, bot, par);
1165     else {
1166     char x[40];
1167    
1168     simple_sprintf(x, "%d:%s@%s", dcc[idx].sock, dcc[idx].nick, botnetnick);
1169     botnet_send_unlink(i, x, lastbot(bot), bot, par);
1170     }
1171     }
1172    
1173     static void cmd_relay(struct userrec *u, int idx, char *par)
1174     {
1175     if (!par[0]) {
1176     dprintf(idx, "Usage: relay <bot>\n");
1177     return;
1178     }
1179     putlog(LOG_CMDS, "*", "#%s# relay %s", dcc[idx].nick, par);
1180     tandem_relay(idx, par, 0);
1181     }
1182    
1183     static void cmd_save(struct userrec *u, int idx, char *par)
1184     {
1185     putlog(LOG_CMDS, "*", "#%s# save", dcc[idx].nick);
1186     dprintf(idx, "Saving user file...\n");
1187     write_userfile(-1);
1188     }
1189    
1190     static void cmd_backup(struct userrec *u, int idx, char *par)
1191     {
1192     putlog(LOG_CMDS, "*", "#%s# backup", dcc[idx].nick);
1193     dprintf(idx, "Backing up the user file...\n");
1194     backup_userfile();
1195     }
1196    
1197     static void cmd_trace(struct userrec *u, int idx, char *par)
1198     {
1199     int i;
1200     char x[NOTENAMELEN + 11], y[11];
1201    
1202     if (!par[0]) {
1203     dprintf(idx, "Usage: trace <botname>\n");
1204     return;
1205     }
1206     if (!strcasecmp(par, botnetnick)) {
1207     dprintf(idx, "That's me! Hiya! :)\n");
1208     return;
1209     }
1210     i = nextbot(par);
1211     if (i < 0) {
1212     dprintf(idx, "Unreachable bot.\n");
1213     return;
1214     }
1215     putlog(LOG_CMDS, "*", "#%s# trace %s", dcc[idx].nick, par);
1216     simple_sprintf(x, "%d:%s@%s", dcc[idx].sock, dcc[idx].nick, botnetnick);
1217     simple_sprintf(y, ":%d", now);
1218     botnet_send_trace(i, x, par, y);
1219     }
1220    
1221     static void cmd_binds(struct userrec *u, int idx, char *par)
1222     {
1223     putlog(LOG_CMDS, "*", "#%s# binds %s", dcc[idx].nick, par);
1224     tell_binds(idx, par);
1225     }
1226    
1227     static void cmd_banner(struct userrec *u, int idx, char *par)
1228     {
1229     char s[1024];
1230     int i;
1231    
1232     if (!par[0]) {
1233     dprintf(idx, "Usage: banner <message>\n");
1234     return;
1235     }
1236     simple_sprintf(s, "\007\007### Botwide:[%s] %s\n", dcc[idx].nick, par);
1237     for (i = 0; i < dcc_total; i++)
1238     if (dcc[i].type->flags & DCT_MASTER)
1239     dprintf(i, "%s", s);
1240     }
1241    
1242     /* after messing with someone's user flags, make sure the dcc-chat flags
1243     * are set correctly */
1244     int check_dcc_attrs(struct userrec *u, int oatr)
1245     {
1246     int i, stat;
1247     char *p, *q, s[121];
1248    
1249     /* if it matches someone in the owner list, make sure he/she has +n */
1250     if (!u)
1251     return 0;
1252     /* make sure default owners are +n */
1253     if (owner[0]) {
1254     q = owner;
1255     p = strchr(q, ',');
1256     while (p) {
1257     strncpy(s, q, p - q);
1258     s[p - q] = 0;
1259     rmspace(s);
1260     if (!strcasecmp(u->handle, s))
1261     u->flags = sanity_check(u->flags | USER_OWNER);
1262     q = p + 1;
1263     p = strchr(q, ',');
1264     }
1265     strcpy(s, q);
1266     rmspace(s);
1267     if (!strcasecmp(u->handle, s))
1268     u->flags = sanity_check(u->flags | USER_OWNER);
1269     }
1270     for (i = 0; i < dcc_total; i++) {
1271     if ((dcc[i].type->flags & DCT_MASTER) &&
1272     (!strcasecmp(u->handle, dcc[i].nick))) {
1273     stat = dcc[i].status;
1274     if ((dcc[i].type == &DCC_CHAT) &&
1275     ((u->flags & (USER_OP | USER_MASTER | USER_OWNER |
1276     USER_BOTMAST))
1277     != (oatr & (USER_OP | USER_MASTER | USER_OWNER |
1278     USER_BOTMAST)))) {
1279     botnet_send_join_idx(i, -1);
1280     }
1281     if ((oatr & USER_MASTER) && !(u->flags & USER_MASTER)) {
1282     struct flag_record fr =
1283     {FR_CHAN | FR_ANYWH, 0, 0, 0, 0, 0};
1284    
1285     dcc[i].u.chat->con_flags &= ~(LOG_MISC | LOG_CMDS | LOG_RAW |
1286     LOG_FILES | LOG_LEV1 | LOG_LEV2 |
1287     LOG_LEV3 | LOG_LEV4 | LOG_LEV5 |
1288     LOG_LEV6 | LOG_LEV7 | LOG_LEV8 |
1289     LOG_WALL | LOG_DEBUG);
1290     get_user_flagrec(u, &fr, NULL);
1291     if (!chan_master(fr))
1292     dcc[i].u.chat->con_flags |= (LOG_MISC | LOG_CMDS);
1293     dprintf(i, "*** POOF! ***\n");
1294     dprintf(i, "You are no longer a master on this bot.\n");
1295     }
1296     if (!(oatr & USER_MASTER) && (u->flags & USER_MASTER)) {
1297     dcc[i].u.chat->con_flags |= conmask;
1298     dprintf(i, "*** POOF! ***\n");
1299     dprintf(i, "You are now a master on this bot.\n");
1300     }
1301     if (!(oatr & USER_BOTMAST) && (u->flags & USER_BOTMAST)) {
1302     dprintf(i, "### POOF! ###\n");
1303     dprintf(i, "You are now a botnet master on this bot.\n");
1304     }
1305     if ((oatr & USER_BOTMAST) && !(u->flags & USER_BOTMAST)) {
1306     dprintf(i, "### POOF! ###\n");
1307     dprintf(i, "You are no longer a botnet master on this bot.\n");
1308     }
1309     if (!(oatr & USER_OWNER) && (u->flags & USER_OWNER)) {
1310     dprintf(i, "@@@ POOF! @@@\n");
1311     dprintf(i, "You are now an OWNER of this bot.\n");
1312     }
1313     if ((oatr & USER_OWNER) && !(u->flags & USER_OWNER)) {
1314     dprintf(i, "@@@ POOF! @@@\n");
1315     dprintf(i, "You are no longer an owner of this bot.\n");
1316     }
1317     if ((stat & STAT_PARTY) && (u->flags & USER_OP))
1318     stat &= ~STAT_PARTY;
1319     if (!(stat & STAT_PARTY) && !(u->flags & USER_OP) &&
1320     !(u->flags & USER_MASTER))
1321     stat |= STAT_PARTY;
1322     if ((stat & STAT_CHAT) && !(u->flags & USER_PARTY) &&
1323     !(u->flags & USER_MASTER) &&
1324     (!(u->flags & USER_OP) || require_p))
1325     stat &= ~STAT_CHAT;
1326     if ((dcc[i].type->flags & DCT_FILES) && !(stat & STAT_CHAT) &&
1327     ((u->flags & USER_MASTER) || (u->flags & USER_PARTY) ||
1328     ((u->flags & USER_OP) && !require_p)))
1329     stat |= STAT_CHAT;
1330     dcc[i].status = stat;
1331     /* check if they no longer have access to wherever they are */
1332     /* DON'T kick someone off the party line just cuz they lost +p
1333     * (pinvite script removes +p after 5 mins automatically) */
1334     if ((dcc[i].type->flags & DCT_FILES) && !(u->flags & USER_XFER) &&
1335     !(u->flags & USER_MASTER)) {
1336     dprintf(i, "-+- POOF! -+-\n");
1337     dprintf(i, "You no longer have file area access.\n\n");
1338     putlog(LOG_MISC, "*", "DCC user [%s]%s removed from file system",
1339     dcc[i].nick, dcc[i].host);
1340     if (dcc[i].status & STAT_CHAT) {
1341     struct chat_info *ci;
1342    
1343     ci = dcc[i].u.file->chat;
1344     nfree(dcc[i].u.file);
1345     dcc[i].u.chat = ci;
1346     dcc[i].status &= (~STAT_CHAT);
1347     dcc[i].type = &DCC_CHAT;
1348     if (dcc[i].u.chat->channel >= 0) {
1349     chanout_but(-1, dcc[i].u.chat->channel,
1350     "*** %s has returned.\n", dcc[i].nick);
1351 fabian 1.12 Context;
1352 segfault 1.1 if (dcc[i].u.chat->channel < 100000)
1353     botnet_send_join_idx(i, -1);
1354     }
1355     } else {
1356     killsock(dcc[i].sock);
1357 fabian 1.16 lostdcc(i);
1358 segfault 1.1 }
1359     }
1360     }
1361     if ((dcc[i].type == &DCC_BOT) && !strcasecmp(u->handle, dcc[i].nick)) {
1362     if ((dcc[i].status & STAT_LEAF) && !(u->flags & BOT_LEAF))
1363     dcc[i].status &= ~(STAT_LEAF | STAT_WARNED);
1364     if (!(dcc[i].status & STAT_LEAF) && (u->flags & BOT_LEAF))
1365     dcc[i].status |= STAT_LEAF;
1366     }
1367     }
1368     return u->flags;
1369     }
1370    
1371     int check_dcc_chanattrs(struct userrec *u, char *chname, int chflags,
1372     int ochatr)
1373     {
1374     int i, found = 0, atr = u ? u->flags : 0;
1375     struct chanset_t *chan;
1376    
1377     if (!u)
1378     return 0;
1379     chan = chanset;
1380     for (i = 0; i < dcc_total; i++) {
1381     if ((dcc[i].type->flags & DCT_MASTER) &&
1382     !strcasecmp(u->handle, dcc[i].nick)) {
1383     if ((dcc[i].type == &DCC_CHAT) &&
1384     ((chflags & (USER_OP | USER_MASTER | USER_OWNER))
1385     != (ochatr & (USER_OP | USER_MASTER | USER_OWNER))))
1386     botnet_send_join_idx(i, -1);
1387     if ((ochatr & USER_MASTER) && !(chflags & USER_MASTER)) {
1388     if (!(atr & USER_MASTER))
1389     dcc[i].u.chat->con_flags &= ~(LOG_MISC | LOG_CMDS);
1390     dprintf(i, "*** POOF! ***\n");
1391     dprintf(i, "You are no longer a master on %s.\n", chname);
1392     }
1393     if (!(ochatr & USER_MASTER) && (chflags & USER_MASTER)) {
1394     dcc[i].u.chat->con_flags |= conmask;
1395     if (!(atr & USER_MASTER))
1396     dcc[i].u.chat->con_flags &=
1397     ~(LOG_LEV1 | LOG_LEV2 | LOG_LEV3 | LOG_LEV4 |
1398     LOG_LEV5 | LOG_LEV6 | LOG_LEV7 | LOG_LEV8 |
1399     LOG_RAW | LOG_DEBUG | LOG_WALL | LOG_FILES | LOG_SRVOUT);
1400     dprintf(i, "*** POOF! ***\n");
1401     dprintf(i, "You are now a master on %s.\n", chname);
1402     }
1403     if (!(ochatr & USER_OWNER) && (chflags & USER_OWNER)) {
1404     dprintf(i, "@@@ POOF! @@@\n");
1405     dprintf(i, "You are now an OWNER of %s.\n", chname);
1406     }
1407     if ((ochatr & USER_OWNER) && !(chflags & USER_OWNER)) {
1408     dprintf(i, "@@@ POOF! @@@\n");
1409     dprintf(i, "You are no longer an owner of %s.\n", chname);
1410     }
1411     if (((ochatr & (USER_OP | USER_MASTER | USER_OWNER)) &&
1412     (!(chflags & (USER_OP | USER_MASTER | USER_OWNER)))) ||
1413     ((chflags & (USER_OP | USER_MASTER | USER_OWNER)) &&
1414     (!(ochatr & (USER_OP | USER_MASTER | USER_OWNER))))) {
1415 fabian 1.11 struct flag_record fr = {FR_CHAN, 0, 0, 0, 0, 0};
1416 segfault 1.1
1417     while (chan && !found) {
1418 fabian 1.8 get_user_flagrec(u, &fr, chan->dname);
1419 segfault 1.1 if (fr.chan & (USER_OP | USER_MASTER | USER_OWNER))
1420     found = 1;
1421     else
1422     chan = chan->next;
1423     }
1424     if (!chan)
1425     chan = chanset;
1426     if (chan)
1427 fabian 1.8 strcpy(dcc[i].u.chat->con_chan, chan->dname);
1428 segfault 1.1 else
1429     strcpy(dcc[i].u.chat->con_chan, "*");
1430     }
1431     }
1432     }
1433     return chflags;
1434     }
1435    
1436     static void cmd_chattr(struct userrec *u, int idx, char *par)
1437     {
1438 fabian 1.6 char *hand, *arg = NULL, *tmpchg = NULL, *chg = NULL, work[1024];
1439 segfault 1.1 struct chanset_t *chan = NULL;
1440     struct userrec *u2;
1441 fabian 1.2 struct flag_record pls = {0, 0, 0, 0, 0, 0},
1442     mns = {0, 0, 0, 0, 0, 0},
1443     user = {0, 0, 0, 0, 0, 0};
1444 segfault 1.1 module_entry *me;
1445     int fl = -1, of = 0, ocf = 0;
1446    
1447     if (!par[0]) {
1448     dprintf(idx, "Usage: chattr <handle> [changes] [channel]\n");
1449     return;
1450     }
1451     hand = newsplit(&par);
1452     u2 = get_user_by_handle(userlist, hand);
1453 fabian 1.6 if (!u2) {
1454 segfault 1.1 dprintf(idx, "No such user!\n");
1455     return;
1456     }
1457 fabian 1.6
1458     /* Parse args */
1459     if (par[0]) {
1460 fabian 1.8 arg = newsplit(&par);
1461 fabian 1.6 if (par[0]) {
1462     /* .chattr <handle> <changes> <channel> */
1463     chg = arg;
1464 fabian 1.8 arg = newsplit(&par);
1465     chan = findchan_by_dname(arg);
1466 fabian 1.6 } else {
1467 fabian 1.8 chan = findchan_by_dname(arg);
1468 fabian 1.10 /* ugly hack for modeless channels -- rtc */
1469 fabian 1.6 if (!(arg[0] == '+' && chan) &&
1470     !(arg[0] != '+' && strchr (CHANMETA, arg[0]))) {
1471     /* .chattr <handle> <changes> */
1472     chg = arg;
1473     chan = NULL; /* uh, !strchr (CHANMETA, channel[0]) && channel found?? */
1474     arg = NULL;
1475     }
1476     /* .chattr <handle> <channel>: nothing to do... */
1477     }
1478     }
1479     /* arg: pointer to channel name, NULL if none specified
1480     * chan: pointer to channel structure, NULL if none found or none specified
1481     * chg: pointer to changes, NULL if none specified
1482     */
1483 fabian 1.13 Assert(!(!arg && chan));
1484 fabian 1.6 if (arg && !chan) {
1485     dprintf(idx, "No channel record for %s.\n", arg);
1486     return;
1487 segfault 1.1 }
1488 fabian 1.6 if (chg) {
1489     if (!arg && strpbrk(chg, "&|")) {
1490     /* .chattr <handle> *[&|]*: use console channel if found... */
1491     if (!strcmp ((arg = dcc[idx].u.chat->con_chan), "*"))
1492     arg = NULL;
1493     else
1494 fabian 1.8 chan = findchan_by_dname(arg);
1495 fabian 1.6 if (arg && !chan) {
1496     dprintf (idx, "Invalid console channel %s.\n", arg);
1497     return;
1498     }
1499     } else if (arg && !strpbrk(chg, "&|")) {
1500 fabian 1.12 Context;
1501 fabian 1.6 tmpchg = nmalloc(strlen(chg) + 2);
1502 fabian 1.11 strcpy(tmpchg, "|");
1503     strcat(tmpchg, chg);
1504 fabian 1.6 chg = tmpchg;
1505 segfault 1.1 }
1506     }
1507 fabian 1.6 par = arg;
1508 segfault 1.1 user.match = FR_GLOBAL;
1509     if (chan)
1510     user.match |= FR_CHAN;
1511 fabian 1.8 get_user_flagrec(u, &user, chan ? chan->dname : 0);
1512 segfault 1.1 if (!chan && !glob_botmast(user)) {
1513     dprintf(idx, "You do not have Bot Master privileges.\n");
1514 fabian 1.6 if (tmpchg)
1515     nfree(tmpchg);
1516 segfault 1.1 return;
1517     }
1518     if (chan && !glob_master(user) && !chan_master(user)) {
1519     dprintf(idx, "You do not have channel master privileges for channel %s\n",
1520     par);
1521 fabian 1.6 if (tmpchg)
1522     nfree(tmpchg);
1523 segfault 1.1 return;
1524     }
1525     user.match &= fl;
1526     if (chg) {
1527     pls.match = user.match;
1528     break_down_flags(chg, &pls, &mns);
1529     /* no-one can change these flags on-the-fly */
1530 fabian 1.6 pls.global &= ~(USER_BOT);
1531     mns.global &= ~(USER_BOT);
1532 segfault 1.1
1533     if (chan) {
1534     pls.chan &= ~(BOT_SHARE);
1535     mns.chan &= ~(BOT_SHARE);
1536     }
1537     if (!glob_owner(user)) {
1538 fabian 1.6 pls.global &= ~(USER_OWNER | USER_MASTER | USER_BOTMAST | USER_UNSHARED);
1539     mns.global &= ~(USER_OWNER | USER_MASTER | USER_BOTMAST | USER_UNSHARED);
1540 segfault 1.1
1541     if (chan) {
1542     pls.chan &= ~USER_OWNER;
1543     mns.chan &= ~USER_OWNER;
1544     }
1545     if (!glob_master(user)) {
1546 fabian 1.6 pls.global &= USER_PARTY | USER_XFER;
1547     mns.global &= USER_PARTY | USER_XFER;
1548 segfault 1.1
1549     if (!glob_botmast(user)) {
1550     pls.global = 0;
1551     mns.global = 0;
1552     }
1553     }
1554     }
1555     if (chan && !chan_owner(user) && !glob_owner(user)) {
1556     pls.chan &= ~USER_MASTER;
1557     mns.chan &= ~USER_MASTER;
1558     if (!chan_master(user) && !glob_master(user)) {
1559     pls.chan = 0;
1560     mns.chan = 0;
1561     }
1562     }
1563     get_user_flagrec(u2, &user, par);
1564     if (user.match & FR_GLOBAL) {
1565     of = user.global;
1566     user.global = sanity_check((user.global |pls.global) &~mns.global);
1567    
1568     user.udef_global = (user.udef_global | pls.udef_global)
1569     & ~mns.udef_global;
1570     }
1571     if (chan) {
1572     ocf = user.chan;
1573     user.chan = chan_sanity_check((user.chan | pls.chan) & ~mns.chan,
1574     user.global);
1575    
1576     user.udef_chan = (user.udef_chan | pls.udef_chan) & ~mns.udef_chan;
1577     }
1578     set_user_flagrec(u2, &user, par);
1579     }
1580     if (chan)
1581     putlog(LOG_CMDS, "*", "#%s# (%s) chattr %s %s",
1582 fabian 1.8 dcc[idx].nick, chan ? chan->dname : "*", hand, chg ? chg : "");
1583 segfault 1.1 else
1584     putlog(LOG_CMDS, "*", "#%s# chattr %s %s", dcc[idx].nick, hand,
1585     chg ? chg : "");
1586     /* get current flags and display them */
1587     if (user.match & FR_GLOBAL) {
1588     user.match = FR_GLOBAL;
1589     if (chg)
1590     check_dcc_attrs(u2, of);
1591     get_user_flagrec(u2, &user, NULL);
1592     build_flags(work, &user, NULL);
1593     if (work[0] != '-')
1594     dprintf(idx, "Global flags for %s are now +%s\n", hand, work);
1595     else
1596     dprintf(idx, "No global flags for %s.\n", hand);
1597     }
1598     if (chan) {
1599     user.match = FR_CHAN;
1600     get_user_flagrec(u2, &user, par);
1601     user.chan &= ~BOT_SHARE;
1602     if (chg)
1603 fabian 1.8 check_dcc_chanattrs(u2, chan->dname, user.chan, ocf);
1604 segfault 1.1 build_flags(work, &user, NULL);
1605     if (work[0] != '-')
1606     dprintf(idx, "Channel flags for %s on %s are now +%s\n", hand,
1607 fabian 1.8 chan->dname, work);
1608 segfault 1.1 else
1609 fabian 1.8 dprintf(idx, "No flags for %s on %s.\n", hand, chan->dname);
1610 fabian 1.6 if (chg && (me = module_find("irc", 0, 0))) {
1611 segfault 1.1 Function *func = me->funcs;
1612    
1613     if (chan)
1614 fabian 1.2 (func[IRC_RECHECK_CHANNEL]) (chan, 0);
1615 segfault 1.1 }
1616     }
1617 fabian 1.6 if (tmpchg)
1618     nfree(tmpchg);
1619 segfault 1.1 }
1620    
1621     static void cmd_botattr(struct userrec *u, int idx, char *par)
1622     {
1623 fabian 1.6 char *hand, *chg = NULL, *arg = NULL, *tmpchg = NULL, work[1024];
1624 segfault 1.1 struct chanset_t *chan = NULL;
1625     struct userrec *u2;
1626 fabian 1.8 struct flag_record pls = {0, 0, 0, 0, 0, 0},
1627     mns = {0, 0, 0, 0, 0, 0},
1628     user = {0, 0, 0, 0, 0, 0};
1629 segfault 1.1 int idx2;
1630    
1631     if (!par[0]) {
1632     dprintf(idx, "Usage: botattr <handle> [changes] [channel]\n");
1633     return;
1634     }
1635     hand = newsplit(&par);
1636     u2 = get_user_by_handle(userlist, hand);
1637 fabian 1.6 if (!u2 || !(u2->flags & USER_BOT)) {
1638 segfault 1.1 dprintf(idx, "No such bot!\n");
1639     return;
1640     }
1641     for (idx2 = 0; idx2 < dcc_total; idx2++)
1642     if (!strcasecmp(dcc[idx2].nick, hand))
1643     break;
1644     if (idx2 != dcc_total) {
1645 fabian 1.6 dprintf(idx, "You may not change the attributes of a directly linked bot.\n");
1646 segfault 1.1 return;
1647     }
1648 fabian 1.6 /* Parse args */
1649     if (par[0]) {
1650 fabian 1.10 arg = newsplit(&par);
1651 fabian 1.6 if (par[0]) {
1652     /* .botattr <handle> <changes> <channel> */
1653     chg = arg;
1654 fabian 1.10 arg = newsplit(&par);
1655 fabian 1.8 chan = findchan_by_dname(arg);
1656 fabian 1.6 } else {
1657 fabian 1.8 chan = findchan_by_dname(arg);
1658 fabian 1.10 /* ugly hack for modeless channels -- rtc */
1659 fabian 1.6 if (!(arg[0] == '+' && chan) &&
1660     !(arg[0] != '+' && strchr (CHANMETA, arg[0]))) {
1661     /* .botattr <handle> <changes> */
1662     chg = arg;
1663     chan = NULL; /* uh, !strchr (CHANMETA, channel[0]) && channel found?? */
1664     arg = NULL;
1665     }
1666     /* .botattr <handle> <channel>: nothing to do... */
1667     }
1668     }
1669     /* arg: pointer to channel name, NULL if none specified
1670     * chan: pointer to channel structure, NULL if none found or none specified
1671     * chg: pointer to changes, NULL if none specified
1672     */
1673 fabian 1.13 Assert(!(!arg && chan));
1674 fabian 1.6 if (arg && !chan) {
1675     dprintf(idx, "No channel record for %s.\n", arg);
1676     return;
1677 segfault 1.1 }
1678 fabian 1.6 if (chg) {
1679     if (!arg && strpbrk(chg, "&|")) {
1680     /* botattr <handle> *[&|]*: use console channel if found... */
1681     if (!strcmp ((arg = dcc[idx].u.chat->con_chan), "*"))
1682     arg = NULL;
1683     else
1684 fabian 1.8 chan = findchan_by_dname(arg);
1685 fabian 1.6 if (arg && !chan) {
1686     dprintf (idx, "Invalid console channel %s.\n", arg);
1687     return;
1688     }
1689     } else if (arg && !strpbrk(chg, "&|")) {
1690 fabian 1.12 Context;
1691 fabian 1.6 tmpchg = nmalloc(strlen(chg) + 2);
1692     strcpy (tmpchg, "|");
1693     strcat (tmpchg, chg);
1694     chg = tmpchg;
1695     }
1696 segfault 1.1 }
1697 fabian 1.6 par = arg;
1698    
1699 segfault 1.1 user.match = FR_GLOBAL;
1700 fabian 1.8 get_user_flagrec(u, &user, chan ? chan->dname : 0);
1701 segfault 1.1 if (!glob_botmast(user)) {
1702     dprintf(idx, "You do not have Bot Master privileges.\n");
1703 fabian 1.6 if (tmpchg)
1704     nfree(tmpchg);
1705 segfault 1.1 return;
1706     }
1707     if (chg) {