/[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.15 - (hide annotations) (download) (as text)
Tue Dec 21 17:35:09 1999 UTC (19 years, 11 months ago) by fabian
Branch: MAIN
Changes since 1.14: +22 -9 lines
File MIME type: text/x-chdr
Tothwolf's id-header

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     * $Id$
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     extern Tcl_Interp *interp;
42     extern char botnetnick[], origbotname[], ver[];
43     extern char network[], owner[], spaces[];
44     extern time_t now, online_since;
45 fabian 1.14 extern int otraffic_irc, otraffic_irc_today;
46     extern int itraffic_irc, itraffic_irc_today;
47     extern int otraffic_bn, otraffic_bn_today;
48     extern int itraffic_bn, itraffic_bn_today;
49     extern int otraffic_dcc, otraffic_dcc_today;
50     extern int itraffic_dcc, itraffic_dcc_today;
51     extern int otraffic_trans, otraffic_trans_today;
52     extern int itraffic_trans, itraffic_trans_today;
53     extern int otraffic_unknown, otraffic_unknown_today;
54     extern int itraffic_unknown, itraffic_unknown_today;
55     static char *btos(int);
56 segfault 1.1
57     /* add hostmask to a bot's record if possible */
58     static int add_bot_hostmask(int idx, char *nick)
59     {
60     struct chanset_t *chan;
61     memberlist *m;
62     char s[UHOSTLEN];
63    
64     for (chan = chanset; chan; chan = chan->next) {
65     if (channel_active(chan)) {
66     m = ismember(chan, nick);
67     if (m) {
68     struct userrec *u;
69    
70     simple_sprintf(s, "%s!%s", m->nick, m->userhost);
71     u = get_user_by_host(s);
72     if (u) {
73     dprintf(idx, "(Can't add userhost for %s because it matches %s)\n",
74     nick, u->handle);
75     return 0;
76     }
77     simple_sprintf(s, "*!%s", m->userhost);
78 fabian 1.8 dprintf(idx, "(Added hostmask for %s from %s)\n", nick, chan->dname);
79 segfault 1.1 addhost_by_handle(nick, s);
80     return 1;
81     }
82     }
83     }
84     return 0;
85     }
86    
87     static void tell_who(struct userrec *u, int idx, int chan)
88     {
89     int i, k, ok = 0, atr = u ? u->flags : 0, len;
90     char s[1024]; /* temp fix - 1.4 has a better one */
91    
92     if (chan == 0)
93     dprintf(idx, "Party line members: (* = owner, + = master, @ = op)\n");
94     else {
95     simple_sprintf(s, "assoc %d", chan);
96     if ((Tcl_Eval(interp, s) != TCL_OK) || !interp->result[0])
97     dprintf(idx,
98     "People on channel %s%d: (* = owner, + = master, @ = op)\n",
99     (chan < 100000) ? "" : "*", chan % 100000);
100     else
101     dprintf(idx,
102     "People on channel '%s' (%s%d): (* = owner, + = master, @ = op)\n",
103     interp->result, (chan < 100000) ? "" : "*", chan % 100000);
104     }
105     for (i = 0; i < dcc_total; i++)
106     if (dcc[i].type == &DCC_CHAT)
107     if (dcc[i].u.chat->channel == chan) {
108     spaces[len = HANDLEN - strlen(dcc[i].nick)] = 0;
109     if (atr & USER_OWNER) {
110     sprintf(s, " [%.2lu] %c%s%s %s",
111     dcc[i].sock, (geticon(i) == '-' ? ' ' : geticon(i)),
112     dcc[i].nick, spaces, dcc[i].host);
113     } else {
114     sprintf(s, " %c%s%s %s",
115     (geticon(i) == '-' ? ' ' : geticon(i)),
116     dcc[i].nick, spaces, dcc[i].host);
117     }
118     spaces[len] = ' ';
119     if (atr & USER_MASTER) {
120     if (dcc[i].u.chat->con_flags)
121     sprintf(&s[strlen(s)], " (con:%s)",
122     masktype(dcc[i].u.chat->con_flags));
123     }
124     if (now - dcc[i].timeval > 300) {
125     unsigned long days, hrs, mins;
126    
127     days = (now - dcc[i].timeval) / 86400;
128     hrs = ((now - dcc[i].timeval) - (days * 86400)) / 3600;
129     mins = ((now - dcc[i].timeval) - (hrs * 3600)) / 60;
130     if (days > 0)
131     sprintf(&s[strlen(s)], " (idle %lud%luh)", days, hrs);
132     else if (hrs > 0)
133     sprintf(&s[strlen(s)], " (idle %luh%lum)", hrs, mins);
134     else
135     sprintf(&s[strlen(s)], " (idle %lum)", mins);
136     }
137     dprintf(idx, "%s\n", s);
138     if (dcc[i].u.chat->away != NULL)
139     dprintf(idx, " AWAY: %s\n", dcc[i].u.chat->away);
140     }
141     for (i = 0; i < dcc_total; i++)
142     if (dcc[i].type == &DCC_BOT) {
143     if (!ok) {
144     ok = 1;
145     dprintf(idx, "Bots connected:\n");
146     }
147     strcpy(s, ctime(&dcc[i].timeval));
148     strcpy(s, &s[1]);
149     s[9] = 0;
150     strcpy(s, &s[7]);
151     s[2] = ' ';
152     strcpy(&s[7], &s[10]);
153     s[12] = 0;
154     spaces[len = HANDLEN - strlen(dcc[i].nick)] = 0;
155     if (atr & USER_OWNER) {
156     dprintf(idx, " [%.2lu] %s%c%s%s (%s) %s\n",
157     dcc[i].sock, dcc[i].status & STAT_CALLED ? "<-" : "->",
158     dcc[i].status & STAT_SHARE ? '+' : ' ',
159     dcc[i].nick, spaces, s, dcc[i].u.bot->version);
160     } else {
161     dprintf(idx, " %s%c%s%s (%s) %s\n",
162     dcc[i].status & STAT_CALLED ? "<-" : "->",
163     dcc[i].status & STAT_SHARE ? '+' : ' ',
164     dcc[i].nick, spaces, s, dcc[i].u.bot->version);
165     }
166     spaces[len] = ' ';
167     }
168     ok = 0;
169     for (i = 0; i < dcc_total; i++) {
170     if ((dcc[i].type == &DCC_CHAT) && (dcc[i].u.chat->channel != chan)) {
171     if (!ok) {
172     ok = 1;
173     dprintf(idx, "Other people on the bot:\n");
174     }
175     spaces[len = HANDLEN - strlen(dcc[i].nick)] = 0;
176     if (atr & USER_OWNER) {
177     sprintf(s, " [%.2lu] %c%s%s ",
178     dcc[i].sock,
179     (geticon(i) == '-' ? ' ' : geticon(i)), dcc[i].nick,
180     spaces);
181     } else {
182     sprintf(s, " %c%s%s ",
183     (geticon(i) == '-' ? ' ' : geticon(i)), dcc[i].nick,
184     spaces);
185     }
186     spaces[len] = ' ';
187     if (atr & USER_MASTER) {
188     if (dcc[i].u.chat->channel < 0)
189     strcat(s, "(-OFF-) ");
190     else if (dcc[i].u.chat->channel == 0)
191     strcat(s, "(party) ");
192     else
193     sprintf(&s[strlen(s)], "(%5d) ", dcc[i].u.chat->channel);
194     }
195     strcat(s, dcc[i].host);
196     if (atr & USER_MASTER) {
197     if (dcc[i].u.chat->con_flags)
198     sprintf(&s[strlen(s)], " (con:%s)",
199     masktype(dcc[i].u.chat->con_flags));
200     }
201     if (now - dcc[i].timeval > 300) {
202     k = (now - dcc[i].timeval) / 60;
203     if (k < 60)
204     sprintf(&s[strlen(s)], " (idle %dm)", k);
205     else
206     sprintf(&s[strlen(s)], " (idle %dh%dm)", k / 60, k % 60);
207     }
208     dprintf(idx, "%s\n", s);
209     if (dcc[i].u.chat->away != NULL)
210     dprintf(idx, " AWAY: %s\n", dcc[i].u.chat->away);
211     }
212     if ((atr & USER_MASTER) && (dcc[i].type->flags & DCT_SHOWWHO) &&
213     (dcc[i].type != &DCC_CHAT)) {
214     if (!ok) {
215     ok = 1;
216     dprintf(idx, "Other people on the bot:\n");
217     }
218     spaces[len = HANDLEN - strlen(dcc[i].nick)] = 0;
219     if (atr & USER_OWNER) {
220     sprintf(s, " [%.2lu] %c%s%s (files) %s",
221     dcc[i].sock, dcc[i].status & STAT_CHAT ? '+' : ' ',
222     dcc[i].nick, spaces, dcc[i].host);
223     } else {
224     sprintf(s, " %c%s%s (files) %s",
225     dcc[i].status & STAT_CHAT ? '+' : ' ',
226     dcc[i].nick, spaces, dcc[i].host);
227     }
228     spaces[len] = ' ';
229     dprintf(idx, "%s\n", s);
230     }
231     }
232     }
233    
234     static void cmd_botinfo(struct userrec *u, int idx, char *par)
235     {
236     char s[512], s2[32];
237     struct chanset_t *chan;
238     time_t now2;
239     int hr, min;
240    
241 fabian 1.12 Context;
242 segfault 1.1 chan = chanset;
243     now2 = now - online_since;
244     s2[0] = 0;
245     if (now2 > 86400) {
246     int days = now2 / 86400;
247    
248     /* days */
249     sprintf(s2, "%d day", days);
250     if (days >= 2)
251     strcat(s2, "s");
252     strcat(s2, ", ");
253     now2 -= days * 86400;
254     }
255     hr = (time_t) ((int) now2 / 3600);
256     now2 -= (hr * 3600);
257     min = (time_t) ((int) now2 / 60);
258     sprintf(&s2[strlen(s2)], "%02d:%02d", (int) hr, (int) min);
259     putlog(LOG_CMDS, "*", "#%s# botinfo", dcc[idx].nick);
260     simple_sprintf(s, "%d:%s@%s", dcc[idx].sock, dcc[idx].nick, botnetnick);
261     botnet_send_infoq(-1, s);
262     s[0] = 0;
263     if (module_find("server", 0, 0)) {
264     while (chan != NULL) {
265     if (!channel_secret(chan)) {
266 fabian 1.8 if ((strlen(s) + strlen(chan->dname) + strlen(network)
267 segfault 1.1 + strlen(botnetnick) + strlen(ver) + 1) >= 490) {
268     strcat(s,"++ ");
269     break; /* yeesh! */
270     }
271 fabian 1.8 strcat(s, chan->dname);
272 segfault 1.1 strcat(s, ", ");
273     }
274     chan = chan->next;
275     }
276    
277     if (s[0]) {
278     s[strlen(s) - 2] = 0;
279     dprintf(idx, "*** [%s] %s <%s> (%s) [UP %s]\n", botnetnick,
280     ver, network, s, s2);
281     } else
282     dprintf(idx, "*** [%s] %s <%s> (%s) [UP %s]\n", botnetnick,
283     ver, network, BOT_NOCHANNELS, s2);
284     } else
285     dprintf(idx, "*** [%s] %s <NO_IRC> [UP %s]\n", botnetnick, ver, s2);
286     }
287    
288     static void cmd_whom(struct userrec *u, int idx, char *par)
289     {
290     if (par[0] == '*') {
291     putlog(LOG_CMDS, "*", "#%s# whom %s", dcc[idx].nick, par);
292     answer_local_whom(idx, -1);
293     return;
294     } else if (dcc[idx].u.chat->channel < 0) {
295     dprintf(idx, "You have chat turned off.\n");
296     return;
297     }
298     putlog(LOG_CMDS, "*", "#%s# whom %s", dcc[idx].nick, par);
299     if (!par[0]) {
300     answer_local_whom(idx, dcc[idx].u.chat->channel);
301     } else {
302     int chan = -1;
303    
304     if ((par[0] < '0') || (par[0] > '9')) {
305     Tcl_SetVar(interp, "chan", par, 0);
306     if ((Tcl_VarEval(interp, "assoc ", "$chan", NULL) == TCL_OK) &&
307     interp->result[0]) {
308     chan = atoi(interp->result);
309     }
310     if (chan <= 0) {
311     dprintf(idx, "No such channel.\n");
312     return;
313     }
314     } else
315     chan = atoi(par);
316     if ((chan < 0) || (chan > 99999)) {
317     dprintf(idx, "Channel # out of range: must be 0-99999\n");
318     return;
319     }
320     answer_local_whom(idx, chan);
321     }
322     }
323    
324     static void cmd_me(struct userrec *u, int idx, char *par)
325     {
326     int i;
327    
328     if (dcc[idx].u.chat->channel < 0) {
329     dprintf(idx, "You have chat turned off.\n");
330     return;
331     }
332     if (!par[0]) {
333     dprintf(idx, "Usage: me <action>\n");
334     return;
335     }
336     if (dcc[idx].u.chat->away != NULL)
337     not_away(idx);
338     for (i = 0; i < dcc_total; i++)
339     if ((dcc[i].type->flags & DCT_CHAT) &&
340     (dcc[i].u.chat->channel == dcc[idx].u.chat->channel) &&
341     ((i != idx) || (dcc[i].status & STAT_ECHO)))
342     dprintf(i, "* %s %s\n", dcc[idx].nick, par);
343     botnet_send_act(idx, botnetnick, dcc[idx].nick,
344     dcc[idx].u.chat->channel, par);
345     check_tcl_act(dcc[idx].nick, dcc[idx].u.chat->channel, par);
346     }
347    
348     static void cmd_motd(struct userrec *u, int idx, char *par)
349     {
350     int i;
351    
352     if (par[0]) {
353     putlog(LOG_CMDS, "*", "#%s# motd %s", dcc[idx].nick, par);
354     if (!strcasecmp(par, botnetnick))
355     show_motd(idx);
356     else {
357     i = nextbot(par);
358     if (i < 0)
359     dprintf(idx, "That bot isn't connected.\n");
360     else {
361     char x[40];
362    
363     simple_sprintf(x, "%s%d:%s@%s",
364     (u->flags & USER_HIGHLITE) ?
365     ((dcc[idx].status & STAT_TELNET) ? "#" : "!") : "",
366     dcc[idx].sock, dcc[idx].nick, botnetnick);
367     botnet_send_motd(i, x, par);
368     }
369     }
370     } else {
371     putlog(LOG_CMDS, "*", "#%s# motd", dcc[idx].nick);
372     show_motd(idx);
373     }
374     }
375    
376     static void cmd_away(struct userrec *u, int idx, char *par)
377     {
378     if (strlen(par) > 60)
379     par[60] = 0;
380     set_away(idx, par);
381     }
382    
383     static void cmd_back(struct userrec *u, int idx, char *par)
384     {
385     not_away(idx);
386     }
387    
388     static void cmd_newpass(struct userrec *u, int idx, char *par)
389     {
390     char *new;
391    
392     if (!par[0]) {
393     dprintf(idx, "Usage: newpass <newpassword>\n");
394     return;
395     }
396     new = newsplit(&par);
397     if (strlen(new) > 16)
398     new[16] = 0;
399     if (strlen(new) < 6) {
400     dprintf(idx, "Please use at least 6 characters.\n");
401     return;
402     }
403     set_user(&USERENTRY_PASS, u, new);
404     putlog(LOG_CMDS, "*", "#%s# newpass...", dcc[idx].nick);
405     dprintf(idx, "Changed password to '%s'\n", new);
406     }
407    
408     static void cmd_bots(struct userrec *u, int idx, char *par)
409     {
410     putlog(LOG_CMDS, "*", "#%s# bots", dcc[idx].nick);
411     tell_bots(idx);
412     }
413    
414     static void cmd_bottree(struct userrec *u, int idx, char *par)
415     {
416     putlog(LOG_CMDS, "*", "#%s# bottree", dcc[idx].nick);
417     tell_bottree(idx, 0);
418     }
419    
420     static void cmd_vbottree(struct userrec *u, int idx, char *par)
421     {
422     putlog(LOG_CMDS, "*", "#%s# vbottree", dcc[idx].nick);
423     tell_bottree(idx, 1);
424     }
425    
426     static void cmd_rehelp(struct userrec *u, int idx, char *par)
427     {
428     putlog(LOG_CMDS, "*", "#%s# rehelp", dcc[idx].nick);
429     dprintf(idx, "Reload help cache...\n");
430     reload_help_data();
431     }
432    
433     static void cmd_help(struct userrec *u, int idx, char *par)
434     {
435 fabian 1.4 struct flag_record fr = {FR_GLOBAL | FR_CHAN, 0, 0, 0, 0, 0};
436 segfault 1.1
437     get_user_flagrec(u, &fr, dcc[idx].u.chat->con_chan);
438     if (par[0]) {
439     putlog(LOG_CMDS, "*", "#%s# help %s", dcc[idx].nick, par);
440     if (!strcmp(par, "all"))
441     tellallhelp(idx, "all", &fr);
442 fabian 1.4 else if (strchr(par, '*') || strchr(par, '?')) {
443     char *p = par;
444    
445     /* Check if the search pattern only consists of '*' and/or '?'
446     * If it does, show help for "all" instead of listing all help
447     * entries. */
448     for (p = par; *p && ((*p == '*') || (*p == '?')); p++);
449     if (*p)
450     tellwildhelp(idx, par, &fr);
451     else
452     tellallhelp(idx, "all", &fr);
453     } else
454 segfault 1.1 tellhelp(idx, par, &fr, 0);
455     } else {
456     putlog(LOG_CMDS, "*", "#%s# help", dcc[idx].nick);
457     if (glob_op(fr) || glob_botmast(fr) || chan_op(fr))
458     tellhelp(idx, "help", &fr, 0);
459     else
460     tellhelp(idx, "helpparty", &fr, 0);
461     }
462     }
463    
464     static void cmd_addlog(struct userrec *u, int idx, char *par)
465     {
466     if (!par[0]) {
467     dprintf(idx, "Usage: addlog <message>\n");
468     return;
469     }
470     dprintf(idx, "Placed entry in the log file.\n");
471     putlog(LOG_MISC, "*", "%s: %s", dcc[idx].nick, par);
472     }
473    
474     static void cmd_who(struct userrec *u, int idx, char *par)
475     {
476     int i;
477    
478     if (par[0]) {
479     if (dcc[idx].u.chat->channel < 0) {
480     dprintf(idx, "You have chat turned off.\n");
481     return;
482     }
483     putlog(LOG_CMDS, "*", "#%s# who %s", dcc[idx].nick, par);
484     if (!strcasecmp(par, botnetnick))
485     tell_who(u, idx, dcc[idx].u.chat->channel);
486     else {
487     i = nextbot(par);
488     if (i < 0) {
489     dprintf(idx, "That bot isn't connected.\n");
490     } else if (dcc[idx].u.chat->channel > 99999)
491     dprintf(idx, "You are on a local channel\n");
492     else {
493     char s[40];
494    
495     simple_sprintf(s, "%d:%s@%s", dcc[idx].sock,
496     dcc[idx].nick, botnetnick);
497     botnet_send_who(i, s, par, dcc[idx].u.chat->channel);
498     }
499     }
500     } else {
501     putlog(LOG_CMDS, "*", "#%s# who", dcc[idx].nick);
502     if (dcc[idx].u.chat->channel < 0)
503     tell_who(u, idx, 0);
504     else
505     tell_who(u, idx, dcc[idx].u.chat->channel);
506     }
507     }
508    
509     static void cmd_whois(struct userrec *u, int idx, char *par)
510     {
511     if (!par[0]) {
512     dprintf(idx, "Usage: whois <handle>\n");
513     return;
514     }
515     putlog(LOG_CMDS, "*", "#%s# whois %s", dcc[idx].nick, par);
516     tell_user_ident(idx, par, u ? (u->flags & USER_MASTER) : 0);
517     }
518    
519     static void cmd_match(struct userrec *u, int idx, char *par)
520     {
521     int start = 1, limit = 20;
522     char *s, *s1, *chname;
523    
524     if (!par[0]) {
525     dprintf(idx, "Usage: match <nick/host> [[skip] count]\n");
526     return;
527     }
528     putlog(LOG_CMDS, "*", "#%s# match %s", dcc[idx].nick, par);
529     s = newsplit(&par);
530     if (strchr(CHANMETA, par[0]) != NULL)
531     chname = newsplit(&par);
532     else
533     chname = "";
534     if (atoi(par) > 0) {
535     s1 = newsplit(&par);
536     if (atoi(par) > 0) {
537     start = atoi(s1);
538     limit = atoi(par);
539     } else
540     limit = atoi(s1);
541     }
542     tell_users_match(idx, s, start, limit, u ? (u->flags & USER_MASTER) : 0,
543     chname);
544     }
545    
546     static void cmd_uptime(struct userrec *u, int idx, char *par)
547     {
548     putlog(LOG_CMDS, "*", "#%s# uptime", dcc[idx].nick);
549     tell_verbose_uptime(idx);
550     }
551    
552     static void cmd_status(struct userrec *u, int idx, char *par)
553     {
554     int atr = u ? u->flags : 0;
555    
556     if (!strcasecmp(par, "all")) {
557     if (!(atr & USER_MASTER)) {
558     dprintf(idx, "You do not have Bot Master privileges.\n");
559     return;
560     }
561     putlog(LOG_CMDS, "*", "#%s# status all", dcc[idx].nick);
562     tell_verbose_status(idx);
563     tell_mem_status_dcc(idx);
564     dprintf(idx, "\n");
565     tell_settings(idx);
566     do_module_report(idx, 1, NULL);
567     } else {
568     putlog(LOG_CMDS, "*", "#%s# status", dcc[idx].nick);
569     tell_verbose_status(idx);
570     tell_mem_status_dcc(idx);
571     do_module_report(idx, 0, NULL);
572     }
573     }
574    
575     static void cmd_dccstat(struct userrec *u, int idx, char *par)
576     {
577     putlog(LOG_CMDS, "*", "#%s# dccstat", dcc[idx].nick);
578     tell_dcc(idx);
579     }
580    
581     static void cmd_boot(struct userrec *u, int idx, char *par)
582     {
583     int i, files = 0, ok = 0;
584     char *who;
585     struct userrec *u2;
586    
587     if (!par[0]) {
588     dprintf(idx, "Usage: boot nick[@bot]\n");
589     return;
590     }
591     who = newsplit(&par);
592     if (strchr(who, '@') != NULL) {
593     char whonick[512];
594    
595     splitc(whonick, who, '@');
596     whonick[20] = 0;
597     if (!strcasecmp(who, botnetnick)) {
598     cmd_boot(u, idx, whonick);
599     return;
600     }
601     if (remote_boots > 0) {
602     i = nextbot(who);
603     if (i < 0) {
604     dprintf(idx, "No such bot connected.\n");
605     return;
606     }
607     botnet_send_reject(i, dcc[idx].nick, botnetnick, whonick,
608     who, par[0] ? par : dcc[idx].nick);
609 fabian 1.7 putlog(LOG_BOTS, "*", "#%s# boot %s@%s (%s)", dcc[idx].nick, whonick,
610 segfault 1.1 who, par[0] ? par : dcc[idx].nick);
611     } else
612     dprintf(idx, "Remote boots are disabled here.\n");
613     return;
614     }
615     for (i = 0; i < dcc_total; i++)
616     if (!strcasecmp(dcc[i].nick, who) && !ok &&
617     (dcc[i].type->flags & DCT_CANBOOT)) {
618     u2 = get_user_by_handle(userlist, dcc[i].nick);
619     if (u2 && (u2->flags & USER_OWNER) &&
620     strcasecmp(dcc[idx].nick, who)) {
621     dprintf(idx, "Can't boot the bot owner.\n");
622     return;
623     }
624     if (u2 && (u2->flags & USER_MASTER) &&
625     !(u && (u->flags & USER_MASTER))) {
626     dprintf(idx, "Can't boot a bot master.\n");
627     return;
628     }
629     files = (dcc[i].type->flags & DCT_FILES);
630     if (files)
631     dprintf(idx, "Booted %s from the file section.\n", dcc[i].nick);
632     else
633     dprintf(idx, "Booted %s from the bot.\n", dcc[i].nick);
634     putlog(LOG_CMDS, "*", "#%s# boot %s %s", dcc[idx].nick, who, par);
635     do_boot(i, dcc[idx].nick, par);
636     ok = 1;
637     }
638     if (!ok)
639     dprintf(idx, "Who? No such person on the party line.\n");
640     }
641    
642     static void cmd_console(struct userrec *u, int idx, char *par)
643     {
644     char *nick, s[2], s1[512];
645     int dest = 0, i, ok = 0, pls, md;
646 fabian 1.8 struct flag_record fr = {FR_GLOBAL | FR_CHAN, 0, 0, 0, 0, 0};
647 segfault 1.1 module_entry *me;
648    
649     if (!par[0]) {
650     dprintf(idx, "Your console is %s: %s (%s)\n",
651     dcc[idx].u.chat->con_chan,
652     masktype(dcc[idx].u.chat->con_flags),
653     maskname(dcc[idx].u.chat->con_flags));
654     return;
655     }
656     get_user_flagrec(u, &fr, dcc[idx].u.chat->con_chan);
657     strcpy(s1, par);
658     nick = newsplit(&par);
659 fabian 1.6 /* don't remove '+' as someone couldn't have '+' in CHANMETA cause
660     * he doesn't use br0ken IRCnet ++rtc */
661     if (nick[0] && !strchr(CHANMETA "+-*", nick[0]) && glob_master(fr)) {
662 segfault 1.1 for (i = 0; i < dcc_total; i++)
663     if (!strcasecmp(nick, dcc[i].nick) &&
664     (dcc[i].type == &DCC_CHAT) && (!ok)) {
665     ok = 1;
666     dest = i;
667     }
668     if (!ok) {
669     dprintf(idx, "No such user on the party line!\n");
670     return;
671     }
672     nick[0] = 0;
673     } else
674     dest = idx;
675     if (!nick[0])
676     nick = newsplit(&par);
677 fabian 1.10 /* ugly hack for modeless channels -- rtc */
678 fabian 1.8 if ((nick [0] == '+' && findchan_by_dname(nick)) ||
679 fabian 1.6 (nick [0] != '+' && strchr(CHANMETA "*", nick[0]))) {
680 fabian 1.8 if (strcmp(nick, "*") && !findchan_by_dname(nick)) {
681 segfault 1.1 dprintf(idx, "Invalid console channel: %s\n", nick);
682     return;
683     }
684     get_user_flagrec(u, &fr, nick);
685     if (!chan_op(fr) && !(glob_op(fr) && !chan_deop(fr))) {
686     dprintf(idx, "You don't have op or master access to channel %s\n",
687     nick);
688     return;
689     }
690 fabian 1.8 strncpy(dcc[dest].u.chat->con_chan, nick, 81);
691 segfault 1.1 dcc[dest].u.chat->con_chan[80] = 0;
692     nick[0] = 0;
693     if ((dest == idx) && !glob_master(fr) && !chan_master(fr))
694     /* consoling to another channel for self */
695     dcc[dest].u.chat->con_flags &= ~(LOG_MISC | LOG_CMDS | LOG_WALL);
696     }
697     if (!nick[0])
698     nick = newsplit(&par);
699     pls = 1;
700     if (nick[0]) {
701     if ((nick[0] != '+') && (nick[0] != '-'))
702     dcc[dest].u.chat->con_flags = 0;
703     for (; *nick; nick++) {
704     if (*nick == '+')
705     pls = 1;
706     else if (*nick == '-')
707     pls = 0;
708     else {
709     s[0] = *nick;
710     s[1] = 0;
711     md = logmodes(s);
712     if ((dest == idx) && !glob_master(fr) && pls) {
713     if (chan_master(fr))
714     md &= ~(LOG_FILES | LOG_LEV1 | LOG_LEV2 | LOG_LEV3 |
715     LOG_LEV4 | LOG_LEV5 | LOG_LEV6 | LOG_LEV7 |
716     LOG_LEV8 | LOG_DEBUG);
717     else
718     md &= ~(LOG_MISC | LOG_CMDS | LOG_FILES | LOG_LEV1 |
719     LOG_LEV2 | LOG_LEV3 | LOG_LEV4 | LOG_LEV5 |
720     LOG_LEV6 | LOG_LEV7 | LOG_LEV8 | LOG_WALL |
721     LOG_DEBUG);
722     }
723     if (!glob_owner(fr) && pls)
724     md &= ~(LOG_RAW | LOG_SRVOUT | LOG_BOTNET | LOG_BOTSHARE);
725     if (!glob_botmast(fr) && pls)
726     md &= ~LOG_BOTS;
727     if (pls)
728     dcc[dest].u.chat->con_flags |= md;
729     else
730     dcc[dest].u.chat->con_flags &= ~md;
731     }
732     }
733     }
734     putlog(LOG_CMDS, "*", "#%s# console %s", dcc[idx].nick, s1);
735     if (dest == idx) {
736     dprintf(idx, "Set your console to %s: %s (%s)\n",
737     dcc[idx].u.chat->con_chan,
738     masktype(dcc[idx].u.chat->con_flags),
739     maskname(dcc[idx].u.chat->con_flags));
740     } else {
741     dprintf(idx, "Set console of %s to %s: %s (%s)\n", dcc[dest].nick,
742     dcc[dest].u.chat->con_chan,
743     masktype(dcc[dest].u.chat->con_flags),
744     maskname(dcc[dest].u.chat->con_flags));
745     dprintf(dest, "%s set your console to %s: %s (%s)\n", dcc[idx].nick,
746     dcc[dest].u.chat->con_chan,
747     masktype(dcc[dest].u.chat->con_flags),
748     maskname(dcc[dest].u.chat->con_flags));
749     }
750     /* new style autosave -- drummer,07/25/1999*/
751 fabian 1.2 if ((me = module_find("console", 1, 1))) {
752 segfault 1.1 Function *func = me->funcs;
753 fabian 1.3 (func[CONSOLE_DOSTORE]) (dest);
754 segfault 1.1 }
755     }
756    
757     static void cmd_pls_bot(struct userrec *u, int idx, char *par)
758     {
759     char *handle, *addr, *p, *q, *host;
760     struct userrec *u1;
761     struct bot_addr *bi;
762    
763     if (!par[0])
764     dprintf(idx, "Usage: +bot <handle> <address[:telnet-port[/relay-port]]> [host]\n");
765     else {
766     handle = newsplit(&par);
767     addr = newsplit(&par);
768     if (strlen(handle) > HANDLEN)
769     handle[HANDLEN] = 0; /* max len = XX .. for the moment :) */
770     if (get_user_by_handle(userlist, handle))
771     dprintf(idx, "Someone already exists by that name.\n");
772 fabian 1.6 else if (strchr(BADHANDCHARS, handle[0]) != NULL)
773 segfault 1.1 dprintf(idx, "You can't start a botnick with '%c'.\n", handle[0]);
774     else {
775     if (strlen(addr) > 60)
776     addr[60] = 0;
777     putlog(LOG_CMDS, "*", "#%s# +bot %s %s", dcc[idx].nick, handle, addr);
778     userlist = adduser(userlist, handle, "none", "-", USER_BOT);
779     u1 = get_user_by_handle(userlist, handle);
780     bi = user_malloc(sizeof(struct bot_addr));
781    
782     q = strchr(addr, ':');
783     if (!q) {
784     bi->address = user_malloc(strlen(addr) + 1);
785     strcpy(bi->address, addr);
786     bi->telnet_port = 3333;
787     bi->relay_port = 3333;
788     } else {
789     bi->address = user_malloc(q - addr + 1);
790     strncpy(bi->address, addr, q - addr);
791     bi->address[q - addr] = 0;
792     p = q + 1;
793     bi->telnet_port = atoi(p);
794     q = strchr(p, '/');
795     if (!q) {
796     bi->relay_port = bi->telnet_port;
797     } else {
798     bi->relay_port = atoi(q + 1);
799     }
800     }
801     set_user(&USERENTRY_BOTADDR, u1, bi);
802     dprintf(idx, "Added bot '%s' with address '%s' and no password.\n",
803     handle, addr);
804     host = newsplit(&par);
805     if (host[0]) {
806     addhost_by_handle(handle, host);
807     } else if (!add_bot_hostmask(idx, handle))
808     dprintf(idx, "You'll want to add a hostmask if this bot will ever %s",
809     "be on any channels that I'm on.\n");
810     }
811     }
812     }
813    
814     static void cmd_chnick(struct userrec *u, int idx, char *par)
815     {
816 fabian 1.2 char hand[HANDLEN + 1], newhand[HANDLEN + 1];
817 segfault 1.1 int i, atr = u ? u->flags : 0, atr2;
818     struct userrec *u2;
819    
820 fabian 1.2 strncpy(hand, newsplit(&par), sizeof(hand));
821 fabian 1.5 hand[HANDLEN] = 0;
822 fabian 1.2 strncpy(newhand, newsplit(&par), sizeof(newhand));
823 fabian 1.5 newhand[HANDLEN] = 0;
824 fabian 1.2
825     if (!hand[0] || !newhand[0]) {
826 segfault 1.1 dprintf(idx, "Usage: chnick <oldnick> <newnick>\n");
827 fabian 1.2 return;
828     }
829     for (i = 0; i < strlen(newhand); i++)
830     if ((newhand[i] <= 32) || (newhand[i] >= 127) || (newhand[i] == '@'))
831     newhand[i] = '?';
832 fabian 1.6 if (strchr(BADHANDCHARS, newhand[0]) != NULL)
833 fabian 1.2 dprintf(idx, "Bizarre quantum forces prevent nicknames from starting with %c\n",
834     newhand[0]);
835     else if (get_user_by_handle(userlist, newhand) &&
836     strcasecmp(hand, newhand))
837     dprintf(idx, "Somebody is already using %s.\n", newhand);
838 segfault 1.1 else {
839 fabian 1.2 u2 = get_user_by_handle(userlist, hand);
840     atr2 = u2 ? u2->flags : 0;
841     if ((atr & USER_BOTMAST) && !(atr & USER_MASTER) &&
842     !(atr2 & USER_BOT))
843     dprintf(idx, "You can't change nick for non-bots.\n");
844     else if ((bot_flags(u2) & BOT_SHARE) && !(atr & USER_OWNER))
845     dprintf(idx, "You can't change shared bot's nick.\n");
846     else if ((atr2 & USER_OWNER) && !(atr & USER_OWNER) &&
847     strcasecmp(dcc[idx].nick, hand))
848     dprintf(idx, "Can't change the bot owner's handle.\n");
849     else if (isowner(hand) && strcasecmp(dcc[idx].nick, hand))
850     dprintf(idx, "Can't change the permanent bot owner's handle.\n");
851 fabian 1.6 else if (!strcasecmp(newhand, botnetnick) && (!(atr2 & USER_BOT) ||
852     nextbot(hand) != -1))
853     dprintf(idx, "Hey! That's MY name!\n");
854 fabian 1.2 else if (change_handle(u2, newhand)) {
855     putlog(LOG_CMDS, "*", "#%s# chnick %s %s", dcc[idx].nick,
856     hand, newhand);
857     dprintf(idx, "Changed.\n");
858     } else
859     dprintf(idx, "Failed.\n");
860 segfault 1.1 }
861     }
862    
863     static void cmd_nick(struct userrec *u, int idx, char *par)
864     {
865 fabian 1.2 char oldnick[HANDLEN + 1], newnick[HANDLEN + 1];
866     int i;
867    
868 fabian 1.6 strncpy(newnick, newsplit(&par), HANDLEN);
869 fabian 1.5 newnick[HANDLEN] = 0;
870 segfault 1.1
871 fabian 1.2 if (!newnick[0]) {
872 segfault 1.1 dprintf(idx, "Usage: nick <new-handle>\n");
873     return;
874     }
875 fabian 1.2 for (i = 0; i < strlen(newnick); i++)
876 segfault 1.1 if ((newnick[i] <= 32) || (newnick[i] >= 127) || (newnick[i] == '@'))
877     newnick[i] = '?';
878 fabian 1.6 if (strchr(BADHANDCHARS, newnick[0]) != NULL) {
879 segfault 1.1 dprintf(idx, "Bizarre quantum forces prevent nicknames from starting with '%c'\n",
880     newnick[0]);
881     } else if (get_user_by_handle(userlist, newnick) &&
882     strcasecmp(dcc[idx].nick, newnick)) {
883     dprintf(idx, "Somebody is already using %s.\n", newnick);
884 fabian 1.2 } else if (!strcasecmp(newnick, botnetnick)) {
885     dprintf(idx, "Hey! That's MY name!\n");
886 segfault 1.1 } else {
887 fabian 1.6 strncpy(oldnick, dcc[idx].nick, HANDLEN);
888     oldnick[HANDLEN] = 0;
889 segfault 1.1 if (change_handle(u, newnick)) {
890     putlog(LOG_CMDS, "*", "#%s# nick %s", oldnick, newnick);
891     dprintf(idx, "Okay, changed.\n");
892     } else
893     dprintf(idx, "Failed.\n");
894     }
895     }
896    
897     static void cmd_chpass(struct userrec *u, int idx, char *par)
898     {
899     char *handle, *new;
900     int atr = u ? u->flags : 0, l;
901    
902     if (!par[0])
903     dprintf(idx, "Usage: chpass <handle> [password]\n");
904     else {
905     handle = newsplit(&par);
906     u = get_user_by_handle(userlist, handle);
907     if (!u)
908     dprintf(idx, "No such user.\n");
909     else if ((atr & USER_BOTMAST) && !(atr & USER_MASTER) &&
910     !(u->flags & USER_BOT))
911     dprintf(idx, "You can't change password for non-bots.\n");
912     else if ((bot_flags(u) & BOT_SHARE) && !(atr & USER_OWNER))
913     dprintf(idx, "You can't change shared bot's password.\n");
914     else if ((u->flags & USER_OWNER) && !(atr & USER_OWNER) &&
915     strcasecmp(handle, dcc[idx].nick))
916     dprintf(idx, "Can't change the bot owner's password.\n");
917 fabian 1.2 else if (isowner(handle) && strcasecmp(dcc[idx].nick, handle))
918     dprintf(idx, "Can't change the permanent bot owner's handle.\n");
919 segfault 1.1 else if (!par[0]) {
920     putlog(LOG_CMDS, "*", "#%s# chpass %s [nothing]", dcc[idx].nick,
921     handle);
922     set_user(&USERENTRY_PASS, u, NULL);
923     dprintf(idx, "Removed password.\n");
924     } else {
925     l = strlen(new = newsplit(&par));
926     if (l > 16)
927     new[16] = 0;
928     if (l < 6)
929     dprintf(idx, "Please use at least 6 characters.\n");
930     else {
931     set_user(&USERENTRY_PASS, u, new);
932     putlog(LOG_CMDS, "*", "#%s# chpass %s [something]", dcc[idx].nick,
933     handle);
934     dprintf(idx, "Changed password.\n");
935     }
936     }
937     }
938     }
939    
940     static void cmd_chaddr(struct userrec *u, int idx, char *par)
941     {
942     char *handle, *addr, *p, *q;
943     struct bot_addr *bi;
944     struct userrec *u1;
945    
946     if (!par[0]) {
947     dprintf(idx, "Usage: chaddr <botname> <address:botport#/userport#>\n");
948     return;
949     }
950     handle = newsplit(&par);
951     addr = newsplit(&par);
952 fabian 1.6 if (strlen(addr) > UHOSTMAX)
953     addr[UHOSTMAX] = 0;
954 segfault 1.1 u1 = get_user_by_handle(userlist, handle);
955     if (!u1 || !(u1->flags & USER_BOT)) {
956     dprintf(idx, "Useful only for tandem bots.\n");
957     return;
958     }
959     if ((bot_flags(u1) & BOT_SHARE) && (!u || !u->flags & USER_OWNER)) {
960     dprintf(idx, "You can't change shared bot's address.\n");
961     return;
962     }
963     putlog(LOG_CMDS, "*", "#%s# chaddr %s %s", dcc[idx].nick, handle, addr);
964     dprintf(idx, "Changed bot's address.\n");
965     bi = user_malloc(sizeof(struct bot_addr));
966    
967     q = strchr(addr, ':');
968     if (!q) {
969     bi->address = user_malloc(strlen(addr) + 1);
970     strcpy(bi->address, addr);
971     bi->telnet_port = 3333;
972     bi->relay_port = 3333;
973     } else {
974     bi->address = user_malloc(q - addr + 1);
975     strncpy(bi->address, addr, q - addr);
976     bi->address[q - addr] = 0;
977     p = q + 1;
978     bi->telnet_port = atoi(p);
979     q = strchr(p, '/');
980     if (!q) {
981     bi->relay_port = bi->telnet_port;
982     } else {
983     bi->relay_port = atoi(q + 1);
984     }
985     }
986     set_user(&USERENTRY_BOTADDR, u1, bi);
987     }
988    
989     static void cmd_comment(struct userrec *u, int idx, char *par)
990     {
991     char *handle;
992     struct userrec *u1;
993    
994     if (!par[0]) {
995     dprintf(idx, "Usage: comment <handle> <newcomment>\n");
996     return;
997     }
998     handle = newsplit(&par);
999     u1 = get_user_by_handle(userlist, handle);
1000     if (!u1) {
1001     dprintf(idx, "No such user!\n");
1002     return;
1003     }
1004     if ((u1->flags & USER_OWNER) && !(u && (u->flags & USER_OWNER)) &&
1005     strcasecmp(handle, dcc[idx].nick)) {
1006     dprintf(idx, "Can't change comment on the bot owner.\n");
1007     return;
1008     }
1009     putlog(LOG_CMDS, "*", "#%s# comment %s %s", dcc[idx].nick, handle, par);
1010     if (!strcasecmp(par, "none")) {
1011     dprintf(idx, "Okay, comment blanked.\n");
1012     set_user(&USERENTRY_COMMENT, u1, NULL);
1013     return;
1014     }
1015     dprintf(idx, "Changed comment.\n");
1016     set_user(&USERENTRY_COMMENT, u1, par);
1017     }
1018    
1019     static void cmd_restart(struct userrec *u, int idx, char *par)
1020     {
1021     putlog(LOG_CMDS, "*", "#%s# restart", dcc[idx].nick);
1022     if (!backgrd) {
1023     dprintf(idx, "You can not .restart a bot when running -n (due to tcl)\n");
1024     return;
1025     }
1026     dprintf(idx, "Restarting.\n");
1027     if (make_userfile) {
1028     putlog(LOG_MISC, "*",
1029     "Uh, guess you don't need to create a new userfile.");
1030     make_userfile = 0;
1031     }
1032     write_userfile(-1);
1033     putlog(LOG_MISC, "*", "Restarting ...");
1034     wipe_timers(interp, &utimer);
1035     wipe_timers(interp, &timer);
1036     do_restart = idx;
1037     }
1038    
1039     static void cmd_rehash(struct userrec *u, int idx, char *par)
1040     {
1041     putlog(LOG_CMDS, "*", "#%s# rehash", dcc[idx].nick);
1042     dprintf(idx, "Rehashing.\n");
1043     if (make_userfile) {
1044     putlog(LOG_MISC, "*",
1045     "Uh, guess you don't need to create a new userfile.");
1046     make_userfile = 0;
1047     }
1048     write_userfile(-1);
1049     putlog(LOG_MISC, "*", "Rehashing ...");
1050     do_restart = -2;
1051     }
1052    
1053     static void cmd_reload(struct userrec *u, int idx, char *par)
1054     {
1055     putlog(LOG_CMDS, "*", "#%s# reload", dcc[idx].nick);
1056     dprintf(idx, "Reloading user file...\n");
1057     reload();
1058     }
1059    
1060     /* this get replaced in server.so with a version that handles the server */
1061     void cmd_die(struct userrec *u, int idx, char *par)
1062     {
1063     char s[1024];
1064    
1065     putlog(LOG_CMDS, "*", "#%s# die %s", dcc[idx].nick, par);
1066     if (par[0]) {
1067     simple_sprintf(s, "BOT SHUTDOWN (%s: %s)", dcc[idx].nick, par);
1068     } else {
1069     simple_sprintf(s, "BOT SHUTDOWN (authorized by %s)", dcc[idx].nick);
1070     }
1071     chatout("*** %s\n", s);
1072     botnet_send_chat(-1, botnetnick, s);
1073     botnet_send_bye();
1074     write_userfile(-1);
1075     simple_sprintf(s, "DIE BY %s!%s (%s)", dcc[idx].nick,
1076     dcc[idx].host, par[0] ? par : "request");
1077     fatal(s, 0);
1078     }
1079    
1080     static void cmd_debug(struct userrec *u, int idx, char *par)
1081     {
1082     if (!strcasecmp(par, "help")) {
1083     putlog(LOG_CMDS, "*", "#%s# debug help", dcc[idx].nick);
1084     debug_help(idx);
1085     } else {
1086     putlog(LOG_CMDS, "*", "#%s# debug", dcc[idx].nick);
1087     debug_mem_to_dcc(idx);
1088     }
1089     }
1090    
1091     static void cmd_simul(struct userrec *u, int idx, char *par)
1092     {
1093     char *nick;
1094     int i, ok = 0;
1095    
1096     nick = newsplit(&par);
1097     if (!par[0]) {
1098     dprintf(idx, "Usage: simul <nick> <text>\n");
1099     return;
1100     }
1101     if (isowner(nick)) {
1102     dprintf(idx, "Unable to '.simul' permanent owners.\n");
1103     return;
1104     }
1105     for (i = 0; i < dcc_total; i++)
1106     if (!strcasecmp(nick, dcc[i].nick) && !ok &&
1107     (dcc[i].type->flags & DCT_SIMUL)) {
1108     putlog(LOG_CMDS, "*", "#%s# simul %s %s", dcc[idx].nick, nick, par);
1109     if (dcc[i].type && dcc[i].type->activity) {
1110     dcc[i].type->activity(i, par, strlen(par));
1111     ok = 1;
1112     }
1113     }
1114     if (!ok)
1115     dprintf(idx, "No such user on the party line.\n");
1116     }
1117    
1118     static void cmd_link(struct userrec *u, int idx, char *par)
1119     {
1120     char *s;
1121     int i;
1122    
1123     if (!par[0]) {
1124     dprintf(idx, "Usage: link [some-bot] <new-bot>\n");
1125     return;
1126     }
1127     putlog(LOG_CMDS, "*", "#%s# link %s", dcc[idx].nick, par);
1128     s = newsplit(&par);
1129     if (!par[0] || !strcasecmp(par, botnetnick))
1130     botlink(dcc[idx].nick, idx, s);
1131     else {
1132     char x[40];
1133    
1134     i = nextbot(s);
1135     if (i < 0) {
1136     dprintf(idx, "No such bot online.\n");
1137     return;
1138     }
1139     simple_sprintf(x, "%d:%s@%s", dcc[idx].sock, dcc[idx].nick, botnetnick);
1140     botnet_send_link(i, x, s, par);
1141     }
1142     }
1143    
1144     static void cmd_unlink(struct userrec *u, int idx, char *par)
1145     {
1146     int i;
1147     char *bot;
1148    
1149     if (!par[0]) {
1150     dprintf(idx, "Usage: unlink <bot> [reason]\n");
1151     return;
1152     }
1153     putlog(LOG_CMDS, "*", "#%s# unlink %s", dcc[idx].nick, par);
1154     bot = newsplit(&par);
1155     i = nextbot(bot);
1156     if (i < 0) {
1157     botunlink(idx, bot, par);
1158     return;
1159     }
1160     /* if we're directly connected to that bot, just do it
1161     * (is nike gunna sue?) */
1162     if (!strcasecmp(dcc[i].nick, bot))
1163     botunlink(idx, bot, par);
1164     else {
1165     char x[40];
1166    
1167     simple_sprintf(x, "%d:%s@%s", dcc[idx].sock, dcc[idx].nick, botnetnick);
1168     botnet_send_unlink(i, x, lastbot(bot), bot, par);
1169     }
1170     }
1171    
1172     static void cmd_relay(struct userrec *u, int idx, char *par)
1173     {
1174     if (!par[0]) {
1175     dprintf(idx, "Usage: relay <bot>\n");
1176     return;
1177     }
1178     putlog(LOG_CMDS, "*", "#%s# relay %s", dcc[idx].nick, par);
1179     tandem_relay(idx, par, 0);
1180     }
1181    
1182     static void cmd_save(struct userrec *u, int idx, char *par)
1183     {
1184     putlog(LOG_CMDS, "*", "#%s# save", dcc[idx].nick);
1185     dprintf(idx, "Saving user file...\n");
1186     write_userfile(-1);
1187     }
1188    
1189     static void cmd_backup(struct userrec *u, int idx, char *par)
1190     {
1191     putlog(LOG_CMDS, "*", "#%s# backup", dcc[idx].nick);
1192     dprintf(idx, "Backing up the user file...\n");
1193     backup_userfile();
1194     }
1195    
1196     static void cmd_trace(struct userrec *u, int idx, char *par)
1197     {
1198     int i;
1199     char x[NOTENAMELEN + 11], y[11];
1200    
1201     if (!par[0]) {
1202     dprintf(idx, "Usage: trace <botname>\n");
1203     return;
1204     }
1205     if (!strcasecmp(par, botnetnick)) {
1206     dprintf(idx, "That's me! Hiya! :)\n");
1207     return;
1208     }
1209     i = nextbot(par);
1210     if (i < 0) {
1211     dprintf(idx, "Unreachable bot.\n");
1212     return;
1213     }
1214     putlog(LOG_CMDS, "*", "#%s# trace %s", dcc[idx].nick, par);
1215     simple_sprintf(x, "%d:%s@%s", dcc[idx].sock, dcc[idx].nick, botnetnick);
1216     simple_sprintf(y, ":%d", now);
1217     botnet_send_trace(i, x, par, y);
1218     }
1219    
1220     static void cmd_binds(struct userrec *u, int idx, char *par)
1221     {
1222     putlog(LOG_CMDS, "*", "#%s# binds %s", dcc[idx].nick, par);
1223     tell_binds(idx, par);
1224     }
1225    
1226     static void cmd_banner(struct userrec *u, int idx, char *par)
1227     {
1228     char s[1024];
1229     int i;
1230    
1231     if (!par[0]) {
1232     dprintf(idx, "Usage: banner <message>\n");
1233     return;
1234     }
1235     simple_sprintf(s, "\007\007### Botwide:[%s] %s\n", dcc[idx].nick, par);
1236     for (i = 0; i < dcc_total; i++)
1237     if (dcc[i].type->flags & DCT_MASTER)
1238     dprintf(i, "%s", s);
1239     }
1240    
1241     /* after messing with someone's user flags, make sure the dcc-chat flags
1242     * are set correctly */
1243     int check_dcc_attrs(struct userrec *u, int oatr)
1244     {
1245     int i, stat;
1246     char *p, *q, s[121];
1247    
1248     /* if it matches someone in the owner list, make sure he/she has +n */
1249     if (!u)
1250     return 0;
1251     /* make sure default owners are +n */
1252     if (owner[0]) {
1253     q = owner;
1254     p = strchr(q, ',');
1255     while (p) {
1256     strncpy(s, q, p - q);
1257     s[p - q] = 0;
1258     rmspace(s);
1259     if (!strcasecmp(u->handle, s))
1260     u->flags = sanity_check(u->flags | USER_OWNER);
1261     q = p + 1;
1262     p = strchr(q, ',');
1263     }
1264     strcpy(s, q);
1265     rmspace(s);
1266     if (!strcasecmp(u->handle, s))
1267     u->flags = sanity_check(u->flags | USER_OWNER);
1268     }
1269     for (i = 0; i < dcc_total; i++) {
1270     if ((dcc[i].type->flags & DCT_MASTER) &&
1271     (!strcasecmp(u->handle, dcc[i].nick))) {
1272     stat = dcc[i].status;
1273     if ((dcc[i].type == &DCC_CHAT) &&
1274     ((u->flags & (USER_OP | USER_MASTER | USER_OWNER |
1275     USER_BOTMAST))
1276     != (oatr & (USER_OP | USER_MASTER | USER_OWNER |
1277     USER_BOTMAST)))) {
1278     botnet_send_join_idx(i, -1);
1279     }
1280     if ((oatr & USER_MASTER) && !(u->flags & USER_MASTER)) {
1281     struct flag_record fr =
1282     {FR_CHAN | FR_ANYWH, 0, 0, 0, 0, 0};
1283    
1284     dcc[i].u.chat->con_flags &= ~(LOG_MISC | LOG_CMDS | LOG_RAW |
1285     LOG_FILES | LOG_LEV1 | LOG_LEV2 |
1286     LOG_LEV3 | LOG_LEV4 | LOG_LEV5 |
1287     LOG_LEV6 | LOG_LEV7 | LOG_LEV8 |
1288     LOG_WALL | LOG_DEBUG);
1289     get_user_flagrec(u, &fr, NULL);
1290     if (!chan_master(fr))
1291     dcc[i].u.chat->con_flags |= (LOG_MISC | LOG_CMDS);
1292     dprintf(i, "*** POOF! ***\n");
1293     dprintf(i, "You are no longer a master on this bot.\n");
1294     }
1295     if (!(oatr & USER_MASTER) && (u->flags & USER_MASTER)) {
1296     dcc[i].u.chat->con_flags |= conmask;
1297     dprintf(i, "*** POOF! ***\n");
1298     dprintf(i, "You are now a master on this bot.\n");
1299     }
1300     if (!(oatr & USER_BOTMAST) && (u->flags & USER_BOTMAST)) {
1301     dprintf(i, "### POOF! ###\n");
1302     dprintf(i, "You are now a botnet master on this bot.\n");
1303     }
1304     if ((oatr & USER_BOTMAST) && !(u->flags & USER_BOTMAST)) {
1305     dprintf(i, "### POOF! ###\n");
1306     dprintf(i, "You are no longer a botnet master on this bot.\n");
1307     }
1308     if (!(oatr & USER_OWNER) && (u->flags & USER_OWNER)) {
1309     dprintf(i, "@@@ POOF! @@@\n");
1310     dprintf(i, "You are now an OWNER of this bot.\n");
1311     }
1312     if ((oatr & USER_OWNER) && !(u->flags & USER_OWNER)) {
1313     dprintf(i, "@@@ POOF! @@@\n");
1314     dprintf(i, "You are no longer an owner of this bot.\n");
1315     }
1316     if ((stat & STAT_PARTY) && (u->flags & USER_OP))
1317     stat &= ~STAT_PARTY;
1318     if (!(stat & STAT_PARTY) && !(u->flags & USER_OP) &&
1319     !(u->flags & USER_MASTER))
1320     stat |= STAT_PARTY;
1321     if ((stat & STAT_CHAT) && !(u->flags & USER_PARTY) &&
1322     !(u->flags & USER_MASTER) &&
1323     (!(u->flags & USER_OP) || require_p))
1324     stat &= ~STAT_CHAT;
1325     if ((dcc[i].type->flags & DCT_FILES) && !(stat & STAT_CHAT) &&
1326     ((u->flags & USER_MASTER) || (u->flags & USER_PARTY) ||
1327     ((u->flags & USER_OP) && !require_p)))
1328     stat |= STAT_CHAT;
1329     dcc[i].status = stat;
1330     /* check if they no longer have access to wherever they are */
1331     /* DON'T kick someone off the party line just cuz they lost +p
1332     * (pinvite script removes +p after 5 mins automatically) */
1333     if ((dcc[i].type->flags & DCT_FILES) && !(u->flags & USER_XFER) &&
1334     !(u->flags & USER_MASTER)) {
1335     dprintf(i, "-+- POOF! -+-\n");
1336     dprintf(i, "You no longer have file area access.\n\n");
1337     putlog(LOG_MISC, "*", "DCC user [%s]%s removed from file system",
1338     dcc[i].nick, dcc[i].host);
1339     if (dcc[i].status & STAT_CHAT) {
1340     struct chat_info *ci;
1341    
1342     ci = dcc[i].u.file->chat;
1343     nfree(dcc[i].u.file);
1344     dcc[i].u.chat = ci;
1345     dcc[i].status &= (~STAT_CHAT);
1346     dcc[i].type = &DCC_CHAT;
1347     if (dcc[i].u.chat->channel >= 0) {
1348     chanout_but(-1, dcc[i].u.chat->channel,
1349     "*** %s has returned.\n", dcc[i].nick);
1350 fabian 1.12 Context;
1351 segfault 1.1 if (dcc[i].u.chat->channel < 100000)
1352     botnet_send_join_idx(i, -1);
1353     }
1354     } else {
1355     killsock(dcc[i].sock);
1356     dcc[i].sock = (long) dcc[i].type;
1357     dcc[i].type = &DCC_LOST;
1358     }
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