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

Contents of /eggdrop1.9/src/core_party.c

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


Revision 1.40 - (show annotations) (download) (as text)
Sun Sep 26 09:42:09 2004 UTC (15 years ago) by stdarg
Branch: MAIN
Changes since 1.39: +17 -12 lines
File MIME type: text/x-chdr
* module_load checks modname_LTX_start in addition to start.
* add linked list info to xml nodes
* there were some memory errors somewhere... no idea where... so for now I've changed it back to the old config api and commented out the help system

1 /* core_party.c: core partyline commands
2 *
3 * Copyright (C) 2003, 2004 Eggheads Development Team
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 */
19
20 #ifndef lint
21 static const char rcsid[] = "$Id: core_party.c,v 1.39 2004/07/17 20:59:38 darko Exp $";
22 #endif
23
24 #ifdef HAVE_CONFIG_H
25 # include <config.h>
26 #endif
27
28 #include <ctype.h>
29 #include <unistd.h>
30 #include <string.h>
31 #include <stdlib.h>
32
33 #ifdef HAVE_UNAME
34 # include <sys/utsname.h>
35 #endif
36
37 #include <eggdrop/eggdrop.h>
38
39 #include "core_config.h"
40 #include "core_binds.h"
41 #include "logfile.h"
42 #include "terminal.h" /* TERMINAL_NICK */
43 #include "main.h" /* SHUTDOWN_*, core_shutdown, core_restart */
44
45 /* from main.c */
46 extern char pid_file[];
47
48 static int party_join(partymember_t *p, const char *nick, user_t *u, const char *cmd, const char *text)
49 {
50 if (!text || !*text) {
51 partymember_printf(p, _("Syntax: join <channel>"));
52 return(0);
53 }
54 partychan_join_name(text, p);
55 return(0);
56 }
57
58 static int party_part(partymember_t *p, const char *nick, user_t *u, const char *cmd, const char *text)
59 {
60 partychan_t *chan;
61
62 if (!text || !*text) chan = partychan_get_default(p);
63 else chan = partychan_lookup_name(text);
64 partychan_part(chan, p, "parting");
65 return(0);
66 }
67
68 static int party_quit(partymember_t *p, const char *nick, user_t *u, const char *cmd, const char *text)
69 {
70 if (0 == strcmp (p->nick, TERMINAL_NICK)) {
71 partymember_printf (p, "You can't leave the partyline in terminal mode.");
72 return -1;
73 }
74
75 partymember_printf(p, "Goodbye!");
76 if (!text || !*text) partymember_delete(p, "Quit");
77 else partymember_delete(p, text);
78 return(0);
79 }
80
81 static int party_whisper(partymember_t *p, const char *nick, user_t *u, const char *cmd, const char *text)
82 {
83 char *who;
84 const char *next;
85 partymember_t *dest;
86
87 egg_get_arg(text, &next, &who);
88 if (!who || !next || !*who || !*next) {
89 partymember_printf(p, _("Syntax: whisper <partylineuser> <msg>"));
90 goto done;
91 }
92
93 dest = partymember_lookup_nick(who);
94 if (!dest) {
95 partymember_printf(p, _("No such user '%s'."), who);
96 goto done;
97 }
98
99 partymember_msg(dest, p, next, -1);
100 done:
101 if (who) free(who);
102 return(0);
103 }
104
105 static void *lookup_setting(partymember_t *p, const char *path)
106 {
107 void *root;
108
109 root = config_get_root("eggdrop");
110 root = config_exists(root, path, 0, NULL);
111 if (!root) partymember_printf(p, _("That setting does not exist."));
112 return(root);
113 }
114
115 static int party_get(partymember_t *p, const char *nick, user_t *u, const char *cmd, const char *text)
116 {
117 void *root;
118 char *str = NULL;
119
120 if (!text || !*text) {
121 partymember_printf(p, _("Syntax: get <path>"));
122 return(0);
123 }
124
125 root = lookup_setting(p, text);
126 if (!root) return(0);
127
128 config_get_str(&str, root, NULL);
129 if (str) partymember_printf(p, "Current value: '%s'", str);
130 else partymember_printf(p, _("Current value: null (unset)"));
131 return(0);
132 }
133
134 static int party_set(partymember_t *p, const char *nick, user_t *u, const char *cmd, const char *text)
135 {
136 void *root;
137 char *path, *str;
138 const char *next;
139
140 egg_get_arg(text, &next, &path);
141 if (!path) {
142 partymember_printf(p, _("Syntax: set <path> [new value]"));
143 return(0);
144 }
145 if (!next) {
146 free(path);
147 return party_get(p, nick, u, cmd, text);
148 }
149
150 root = lookup_setting(p, path);
151 free(path);
152 if (!root) return(0);
153
154 config_get_str(&str, root, NULL);
155 partymember_printf(p, _("Old value: '%s'"), str);
156 config_set_str(next, root, NULL);
157 config_get_str(&str, root, NULL);
158 if (str) partymember_printf(p, _("New value: '%s'"), str);
159 else partymember_printf(p, _("New value: null (unset)"));
160 return(0);
161 }
162
163 static int party_unset(partymember_t *p, const char *nick, user_t *u, const char *cmd, const char *text)
164 {
165 void *root;
166 char *str;
167
168 if (!text || !*text) {
169 partymember_printf(p, _("Syntax: unset <path>"));
170 return(0);
171 }
172
173 root = lookup_setting(p, text);
174 if (!root) return(0);
175
176 config_get_str(&str, root, NULL);
177 if (str) partymember_printf(p, _("Old value: '%s'"), str);
178 else partymember_printf(p, _("Old value: null (unset)"));
179 config_set_str(NULL, root, NULL);
180 config_get_str(&str, root, NULL);
181 if (str) partymember_printf(p, _("New value: '%s'"), str);
182 else partymember_printf(p, _("New value: null (unset)"));
183 return(0);
184 }
185
186 static int party_status(partymember_t *p, const char *nick, user_t *u, const char *cmd, const char *text)
187 {
188 #ifdef HAVE_UNAME
189 struct utsname un;
190 #endif
191
192 partymember_printf(p, _("I am %1$s, running Eggdrop %2$s."), core_config.botname, VERSION);
193 partymember_printf(p, _("Owner: %s"), core_config.owner);
194 if (core_config.admin) partymember_printf(p, _("Admin: %s"), core_config.admin);
195 #ifdef HAVE_UNAME
196 if (!uname(&un)) partymember_printf(p, _("OS: %1$s %2$s"), un.sysname, un.release);
197 #endif
198 partymember_printf(p, _("Help path: %s (%d entries, %d sections)"),
199 core_config.help_path, 0, 0);
200 partymember_printf(p, "");
201 check_bind_status(p, text);
202 return(0);
203 }
204
205 static int party_save(partymember_t *p, const char *nick, user_t *u, const char *cmd, const char *text)
206 {
207 putlog(LOG_MISC, "*", _("Saving user file..."));
208 user_save(core_config.userfile);
209 putlog(LOG_MISC, "*", _("Saving config file..."));
210 core_config_save();
211 return(1);
212 }
213
214 static int party_newpass(partymember_t *p, const char *nick, user_t *u, const char *cmd, const char *text)
215 {
216 if (!text || strlen(text) < 6) {
217 partymember_printf(p, _("Please use at least 6 characters."));
218 return(0);
219 }
220 user_set_pass(p->user, text);
221 partymember_printf(p, _("Changed password to '%s'."), text);
222 return(0);
223 }
224
225 static int intsorter(const void *left, const void *right)
226 {
227 return(*(int *)left - *(int *)right);
228 }
229
230 static int party_who(partymember_t *p, const char *nick, user_t *u, const char *cmd, const char *text)
231 {
232 partymember_t *who;
233 int *pids, len, i, width = 0;
234
235 partymember_printf(p, _("Partyline members:"));
236 partymember_who(&pids, &len);
237 qsort(pids, len, sizeof(int), intsorter);
238 if (len > 0) {
239 i = pids[len-1];
240 if (!i) i++;
241 while (i != 0) {
242 i /= 10;
243 width++;
244 }
245 }
246 for (i = 0; i < len; i++) {
247 who = partymember_lookup_pid(pids[i]);
248 partymember_printf(p, " [%*d] %s (%s@%s)", width, who->pid, who->nick, who->ident, who->host);
249 }
250 free(pids);
251 return(0);
252 }
253
254 static int party_whois(partymember_t *p, const char *nick, user_t *u, const char *cmd, const char *text)
255 {
256 user_t *who;
257 flags_t flags;
258 char *item, *chan, *setting, *value, flagstr[64];
259 const char *next;
260 int i;
261
262 if (text && *text) who = user_lookup_by_handle(text);
263 else who = u;
264
265 if (!who) {
266 partymember_printf(p, "No such user.");
267 return(0);
268 }
269
270 next = core_config.whois_items;
271 while (next && *next) {
272 egg_get_arg(next, &next, &item);
273 if (!strcasecmp(item, "handle")) {
274 partymember_printf(p, "%s: '%s'", item, who->handle);
275 }
276 else if (!strcasecmp(item, "uid")) {
277 partymember_printf(p, "%s: '%d'", item, who->uid);
278 }
279 else if (!strcasecmp(item, "ircmasks")) {
280 partymember_printf(p, "%s:", item);
281 for (i = 0; i < who->nircmasks; i++) {
282 partymember_printf(p, " %d. '%s'", i+1, who->ircmasks[i]);
283 }
284 }
285 else {
286 if ((setting = strchr(item, '.'))) {
287 chan = item;
288 *setting = 0;
289 setting++;
290 }
291 else {
292 chan = NULL;
293 setting = item;
294 }
295 if (!strcasecmp(setting, "flags")) {
296 user_get_flags(who, chan, &flags);
297 flag_to_str(&flags, flagstr);
298 value = flagstr;
299 }
300 else {
301 user_get_setting(who, chan, setting, &value);
302 }
303
304 if (chan) partymember_printf(p, "%s.%s: %s", chan, setting, value);
305 else partymember_printf(p, "%s: %s", setting, value);
306 }
307 free(item);
308 }
309 return(0);
310 }
311
312 static int party_die(partymember_t *p, const char *nick, user_t *u, const char *cmd, const char *text)
313 {
314 /* XXX: should we really enable hard shutdowns?
315 if (*text && 0 == strcmp(text, "force")) {
316 return core_shutdown(SHUTDOWN_HARD, nick, text);
317 } else
318 */
319 return core_shutdown(SHUTDOWN_GRACEFULL, nick, text);
320 }
321
322 static int party_plus_user(partymember_t *p, const char *nick, user_t *u, const char *cmd, const char *text)
323 {
324 user_t *newuser;
325
326 if (!text || !*text) {
327 partymember_printf(p, _("Syntax: +user <handle>"));
328 return(0);
329 }
330 if (user_lookup_by_handle(text)) {
331 partymember_printf(p, _("User '%s' already exists!"));
332 return(0);
333 }
334 newuser = user_new(text);
335 if (newuser) partymember_printf(p, _("User '%s' created."), text);
336 else partymember_printf(p, _("Could not create user '%s'."), text);
337 return(0);
338 }
339
340 static int party_minus_user(partymember_t *p, const char *nick, user_t *u, const char *cmd, const char *text)
341 {
342 user_t *who;
343
344 if (!text || !*text) {
345 partymember_printf(p, _("Syntax: -user <handle>"));
346 return(0);
347 }
348 who = user_lookup_by_handle(text);
349 if (!who) partymember_printf(p, _("User '%s' not found."));
350 else {
351 partymember_printf(p, _("Deleting user '%s'."), who->handle);
352 user_delete(who);
353 }
354 return(0);
355 }
356
357 static int party_plus_host(partymember_t *p, const char *nick, user_t *u, const char *cmd, const char *text)
358 {
359 user_t *who;
360 char *target, *newhost;
361
362 egg_get_args(text, NULL, &target, &newhost, NULL);
363 if (!target) {
364 partymember_printf(p, _("Syntax: +host [handle] <host>"));
365 return(0);
366 }
367 if (!newhost) {
368 newhost = target;
369 target = NULL;
370 }
371 if (target) {
372 who = user_lookup_by_handle(target);
373 if (!who) {
374 partymember_printf(p, _("User '%s' not found."), target);
375 goto done;
376 }
377 }
378 else {
379 who = u;
380 if (!who) {
381 partymember_printf(p, _("Only valid users can add hosts."));
382 goto done;
383 }
384 }
385 user_add_ircmask(who, newhost);
386 partymember_printf(p, _("Added '%1$s' to user '%2$s'."), newhost, who->handle);
387
388 done:
389 if (target) free(target);
390 free(newhost);
391
392 return(0);
393 }
394
395 static int party_minus_host(partymember_t *p, const char *nick, user_t *u, const char *cmd, const char *text)
396 {
397 user_t *who;
398 char *target, *host;
399
400 egg_get_args(text, NULL, &target, &host, NULL);
401 if (!target) {
402 partymember_printf(p, _("Syntax: -host [handle] <host>"));
403 return(0);
404 }
405 if (!host) {
406 host = target;
407 target = NULL;
408 }
409 if (target) {
410 who = user_lookup_by_handle(target);
411 if (!who) {
412 partymember_printf(p, _("User '%s' not found."), target);
413 goto done;
414 }
415 }
416 else {
417 who = u;
418 if (!who) {
419 partymember_printf(p, _("Only valid users can remove hosts."));
420 goto done;
421 }
422 }
423 if (user_del_ircmask(who, host)) {
424 partymember_printf(p, _("Mask '%1$s' not found for user '%2$s'."), host, who->handle);
425 }
426 else {
427 partymember_printf(p, _("Removed '%1$s' from user '%2$s'."), host, who->handle);
428 }
429
430 done:
431 if (target) free(target);
432 free(host);
433
434 return(0);
435 }
436
437 /* Syntax: chattr <user> [chan] <flags> */
438 static int party_chattr(partymember_t *p, const char *nick, user_t *u, const char *cmd, const char *text)
439 {
440 const char *next;
441 char *who, *flags, *chan;
442 user_t *dest;
443 flags_t flagstruct;
444 char flagstr[64];
445 int n;
446
447 n = egg_get_args(text, &next, &who, &chan, &flags, NULL);
448 if (!chan || !*chan) {
449 if (who) free(who);
450 partymember_printf(p, _("Syntax: chattr <handle> [channel] <+/-flags>"));
451 return(0);
452 }
453 if (!flags || !*flags) {
454 flags = chan;
455 chan = NULL;
456 }
457 dest = user_lookup_by_handle(who);
458 if (dest) {
459 user_set_flags_str(dest, chan, flags);
460 user_get_flags(dest, chan, &flagstruct);
461 flag_to_str(&flagstruct, flagstr);
462 partymember_printf(p, _("Flags for %s are now '%s'."), who, flagstr);
463 }
464 else partymember_printf(p, _("'%s' is not a valid user."), who);
465 free(who);
466 free(flags);
467 if (chan) free(chan);
468 return(0);
469 }
470
471 static int party_help(partymember_t *p, const char *nick, user_t *u, const char *cmd, const char *text)
472 {
473 return 0;
474 }
475
476 static int party_addlog(partymember_t *p, const char *nick, user_t *u, const char *cmd, const char *text)
477 {
478 putlog(LOG_MISC, "*", "%s: %s", nick, text);
479
480 return BIND_RET_LOG;
481 }
482
483 static int party_modules(partymember_t *p, const char *nick, user_t *u, const char *cmd, const char *text)
484 {
485 const char **modules;
486 int nummods, ctr;
487
488 nummods = module_list(&modules);
489 partymember_printf(p, _("Loaded modules:"));
490 for (ctr = 0; ctr < nummods; ctr++) partymember_printf(p, " %s", modules[ctr]);
491 free(modules);
492
493 return BIND_RET_LOG;
494 }
495
496 static int party_loadmod(partymember_t *p, const char *nick, user_t *u, const char *cmd, const char *text)
497 {
498 if (!text || !*text) {
499 partymember_printf(p, _("Syntax: loadmod <module name>"));
500 return BIND_RET_BREAK;
501 }
502 switch (module_load(text)) {
503 case 0:
504 partymember_printf(p, _("Module '%s' loaded successfully."), text);
505 break;
506 case -1:
507 partymember_printf(p, _("Module '%s' is already loaded."), text);
508 break;
509 case -2:
510 partymember_printf(p, _("Module '%s' could not be loaded."), text);
511 break;
512 case -3:
513 partymember_printf(p, _("Module '%s' does not have a valid initialization function. Perhaps it is not an eggdrop module?"), text);
514 break;
515 }
516 return BIND_RET_LOG;
517 }
518
519 static int party_unloadmod(partymember_t *p, const char *nick, user_t *u, const char *cmd, const char *text)
520 {
521 if (!text || !*text) {
522 partymember_printf(p, _("Syntax: unloadmod <module name>"));
523 return BIND_RET_BREAK;
524 }
525 switch (module_unload(text, MODULE_USER)) {
526 case 0:
527 partymember_printf(p, _("Module '%s' unloaded successfully."), text);
528 break;
529 case -1:
530 partymember_printf(p, _("Module '%s' is not loaded."), text);
531 break;
532 case -2:
533 partymember_printf(p, _("Module '%s' has dependencies that are still loaded. You must unload them first."), text);
534 break;
535 case -3:
536 partymember_printf(p, _("Module '%s' refuses to be unloaded by you!"), text);
537 break;
538 }
539 return BIND_RET_LOG;
540 }
541
542 static int party_binds(partymember_t *p, const char *nick, user_t *u, const char *cmd, const char *text)
543 {
544 bind_table_t *table;
545 bind_entry_t *entry;
546 char flags[64];
547
548 partymember_printf(p, "%-16s %-16s %-16s %-10s %-5s %s", _("TABLE"), _("SYNTAX"),
549 _("FUNCTION"), _("MASK"), _("FLAGS"), _("HITS"));
550 for (table = bind_table_list(); table; table = table->next) {
551 for (entry = table->entries; entry; entry = entry->next) {
552 flag_to_str(&entry->user_flags, flags);
553 partymember_printf(p, "%-16s %-16s %-16s %-10s %-5s %i", table->name, table->syntax,
554 entry->function_name, entry->mask, flags, entry->nhits);
555 }
556 }
557
558 return BIND_RET_LOG;
559 }
560
561 static int party_restart(partymember_t *p, const char *nick, user_t *u, const char *cmd, const char *text)
562 {
563 core_restart (nick);
564
565 return BIND_RET_LOG;
566 }
567
568 /* Syntax: chhandle <old_handle> <new_handle> */
569 static int party_chhandle(partymember_t *p, const char *nick, user_t *u, const char *cmd, const char *text)
570 {
571 char *old = NULL, *newh = NULL;
572 user_t *dest;
573
574 egg_get_args(text, NULL, &old, &newh, NULL);
575 if (!old || !newh || !*old || !*newh) {
576 if (old) free(old);
577 if (newh) free(newh);
578 partymember_printf(p, _("Syntax: chhandle <old_handle> <new_handle>"));
579 goto chhandleend;
580 }
581
582 dest = user_lookup_by_handle(old);
583 if (!dest) {
584 free(old);
585 free(newh);
586 partymember_printf(p, _("Error: User '%s' does not exist."), old);
587 goto chhandleend;
588 }
589
590 if (user_lookup_by_handle(newh)) {
591 free(old);
592 free(newh);
593 partymember_printf(p, _("Error: User '%s' already exists."), newh);
594 return 0;
595 }
596
597 if (!user_change_handle(dest, newh))
598 partymember_printf(p, _("Ok, changed."));
599
600 chhandleend:
601 free(newh);
602 free(old);
603
604 return BIND_RET_LOG;
605 }
606
607 /* Syntax: chpass <handle> [new_pass] */
608 static int party_chpass(partymember_t *p, const char *nick, user_t *u, const char *cmd, const char *text)
609 {
610 char *user = NULL, *pass = NULL;
611 user_t *dest;
612
613 egg_get_args(text, NULL, &user, &pass, NULL);
614
615 if (!user || !*user) {
616 partymember_printf(p, _("Syntax: chpass <handle> [pass]"));
617 goto chpassend;
618 }
619
620 dest = user_lookup_by_handle(user);
621 if (!dest) {
622 partymember_printf(p, _("Error: User '%s' does not exist."), user);
623 goto chpassend;
624 }
625
626 if (pass && *pass && strlen(pass) < 6) {
627 partymember_printf(p, _("Error: Please use at least 6 characters."));
628 goto chpassend;
629 }
630
631 if (user_set_pass(dest, pass))
632 partymember_printf(p, _("Removed password for %s."), user);
633 else
634 partymember_printf(p, _("Password for %s is now '%s'."), user, pass);
635
636 chpassend:
637 free(user);
638 free(pass);
639
640 return BIND_RET_LOG_COMMAND;
641 }
642
643 /* Makes sure 'start' and 'limit' arguments for .match are reasonable, or else sets them -1 */
644 static int party_match_getbounds(const char *strstart, const char *strlimit, long *start, long *limit)
645 {
646 char *tmpptr;
647
648 if (strstart) {
649 *start = strtol(strstart, &tmpptr, 10);
650 if (!*strstart || *tmpptr || *start < 1) { /* Invalid input*/
651 *start = -1;
652 return 0;
653 }
654
655 if (strlimit) { /* 'start' was really a start and this is now 'limit' */
656 *limit = strtol(strlimit, &tmpptr, 10);
657 if (!*strlimit || *tmpptr || *limit < 1) { /* Invalid input*/
658 *limit = -1;
659 return 0;
660 }
661 }
662 else { /* Ah, no, the only argument specified was the 'limit' */
663 *limit = *start;
664 *start = 0;
665 }
666 }
667 else {
668 *limit = 20;
669 *start = 0;
670 }
671
672 return 0;
673 }
674
675 /* Handles case where .match was given mask to match against */
676 static int party_matchwild(partymember_t *p, const char *mask, const char *rest)
677 {
678 char *strstart = NULL, *strlimit = NULL;
679 long start, limit;
680
681 egg_get_args(rest, NULL, &strstart, &strlimit, NULL);
682
683 party_match_getbounds(strstart, strlimit, &start, &limit);
684 if (start == -1 || limit == -1)
685 partymember_printf(p, _("Error: 'start' and 'limit' must be positive integers"));
686 else
687 partyline_cmd_match_ircmask(p, mask, start, limit);
688
689 free(strstart);
690 free(strlimit);
691
692 return 0;
693 }
694
695 /* Handles case where .match was given attributes to match against */
696 static int party_matchattr(partymember_t *p, const char *mask, const char *rest)
697 {
698 char *channel = NULL, *strstart = NULL, *strlimit = NULL;
699 long start, limit;
700 int ischan = 0;
701
702 egg_get_args(rest, NULL, &channel, &strstart, &strlimit, NULL);
703
704 /* This is probably the easiest way to conclude if content of 'channel'
705 is *NOT* a number, and thus it is a candidate for a valid channel name */
706 if (channel && (*channel < '0' || *channel > '9'))
707 ischan = 1;
708
709
710 if (strlimit) /* .match <flags> <channel> <start> <limit> */
711 party_match_getbounds(strstart, strlimit, &start, &limit);
712 else if (strstart) /* .match <flags> <channel|start> <limit> */
713 party_match_getbounds(ischan?strstart:channel, ischan?NULL:strstart, &start, &limit);
714 else if (ischan) { /* .match <flags> <channel> */
715 start = 0;
716 limit = 20;
717 }
718 else /* .match <flags> [limit] */
719 party_match_getbounds(channel, NULL, &start, &limit);
720
721 free(strstart);
722 free(strlimit);
723
724 if (start == -1 || limit == -1)
725 partymember_printf(p, _("Error: 'start' and 'limit' must be positive integers"));
726 else
727 partyline_cmd_match_attr(p, mask, ischan?channel:NULL, start, limit);
728
729 free(channel);
730
731 return 0;
732 }
733
734 /* match <attr> [channel] [[start] limit] */
735 /* match <mask> [[start] limit] */
736 static int party_match(partymember_t *p, const char *nick, user_t *u, const char *cmd, const char *text)
737 {
738
739 char *attr = NULL;
740 const char *rest = NULL;
741
742 /* FIXME - Check if user is allowed to see results.. if !chan && !glob_master && -> error
743 I have left it available to everyone because 'whois' was that way too.
744 We should update both or neither */
745
746 egg_get_args(text, &rest, &attr, NULL);
747
748 if (!attr) {
749 partymember_printf(p, _("Syntax: match <attr> [channel] [[start] limit]"));
750 partymember_printf(p, _(" or: match <mask> [[start] limit]"));
751 free(attr);
752 return 0;
753 }
754
755 if (*attr == '+' || *attr == '-' || *attr == '|')
756 party_matchattr(p, attr, rest);
757 else if (*attr != '&')
758 party_matchwild(p, attr, rest);
759
760 free(attr);
761
762 return BIND_RET_LOG;
763 }
764
765 static bind_list_t core_party_binds[] = { /* Old flags requirement */
766 {NULL, "join", party_join}, /* DDD */
767 {NULL, "whisper", party_whisper}, /* DDD */
768 {NULL, "newpass", party_newpass}, /* DDC */ /* -|- */
769 {NULL, "help", party_help}, /* DDC */ /* -|- */
770 {NULL, "part", party_part}, /* DDD */
771 {NULL, "quit", party_quit}, /* DDD */ /* -|- */
772 {NULL, "who", party_who}, /* DDD */
773 {NULL, "whois", party_whois}, /* DDC */ /* ot|o */
774 {NULL, "match", party_match}, /* DDC */ /* ot|o */
775 {"n", "addlog", party_addlog}, /* DDD */ /* ot|o */
776 {"n", "get", party_get}, /* DDC */
777 {"n", "set", party_set}, /* DDC */
778 {"n", "unset", party_unset}, /* DDC */
779 {"n", "status", party_status}, /* DDC */ /* m|m */
780 {"n", "save", party_save}, /* DDD */ /* m|m */
781 {"n", "die", party_die}, /* DDD */ /* n|- */
782 {"n", "restart", party_restart}, /* DDD */ /* m|- */
783 {"n", "+user", party_plus_user}, /* DDC */ /* m|- */
784 {"n", "-user", party_minus_user}, /* DDC */ /* m|- */
785 {"n", "chattr", party_chattr}, /* DDC */ /* m|m */
786 {"n", "modules", party_modules}, /* DDD */ /* n|- */
787 {"n", "loadmod", party_loadmod}, /* DDD */ /* n|- */
788 {"n", "unloadmod", party_unloadmod}, /* DDD */ /* n|- */
789 {"n", "binds", party_binds}, /* DDD */ /* m|- */
790 {"m", "+host", party_plus_host}, /* DDC */ /* t|m */
791 {"m", "-host", party_minus_host}, /* DDC */ /* -|- */
792 {"t", "chhandle", party_chhandle}, /* DDC */ /* t|- */
793 {"t", "chpass", party_chpass}, /* DDC */ /* t|- */
794 {0}
795 };
796
797 void core_party_init(void)
798 {
799 bind_add_list("party", core_party_binds);
800 }
801

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23