/[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.39 - (show annotations) (download) (as text)
Sat Jul 17 20:59:38 2004 UTC (14 years, 10 months ago) by darko
Branch: MAIN
Changes since 1.38: +164 -29 lines
File MIME type: text/x-chdr
- Added partyline command 'match'. It's a lot of complex, unreadable,
  error prone code, but it seems to be working quite well.
  Possible stumbling point which only had limited testing is matching
  against channel flags. Further testing will have to be done once the
  channel flags system is working correctly.

- Documented .match and .whois

- Fixed leaks in .chpass and .chhandle, caused by misunderstanding of
  the way user_get_args works. stdarg's mail provoked me into looking
  deeper and realising it infact allocates space itself and sends back
  *copies* of parsed arguments, and not only pointers to different places
  in original string. Thanks!

- Added comments in core_party.c which show flags needed to use certain
  command in 1.6 - it could serve as a guideline.

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.38 2004/07/05 22:12:22 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, help_count_entries(),
200 help_count_sections());
201 partymember_printf(p, "");
202 check_bind_status(p, text);
203 return(0);
204 }
205
206 static int party_save(partymember_t *p, const char *nick, user_t *u, const char *cmd, const char *text)
207 {
208 putlog(LOG_MISC, "*", _("Saving user file..."));
209 user_save(core_config.userfile);
210 putlog(LOG_MISC, "*", _("Saving config file..."));
211 core_config_save();
212 return(1);
213 }
214
215 static int party_newpass(partymember_t *p, const char *nick, user_t *u, const char *cmd, const char *text)
216 {
217 if (!text || strlen(text) < 6) {
218 partymember_printf(p, _("Please use at least 6 characters."));
219 return(0);
220 }
221 user_set_pass(p->user, text);
222 partymember_printf(p, _("Changed password to '%s'."), text);
223 return(0);
224 }
225
226 static int intsorter(const void *left, const void *right)
227 {
228 return(*(int *)left - *(int *)right);
229 }
230
231 static int party_who(partymember_t *p, const char *nick, user_t *u, const char *cmd, const char *text)
232 {
233 partymember_t *who;
234 int *pids, len, i, width = 0;
235
236 partymember_printf(p, _("Partyline members:"));
237 partymember_who(&pids, &len);
238 qsort(pids, len, sizeof(int), intsorter);
239 if (len > 0) {
240 i = pids[len-1];
241 if (!i) i++;
242 while (i != 0) {
243 i /= 10;
244 width++;
245 }
246 }
247 for (i = 0; i < len; i++) {
248 who = partymember_lookup_pid(pids[i]);
249 partymember_printf(p, " [%*d] %s (%s@%s)", width, who->pid, who->nick, who->ident, who->host);
250 }
251 free(pids);
252 return(0);
253 }
254
255 static int party_whois(partymember_t *p, const char *nick, user_t *u, const char *cmd, const char *text)
256 {
257 user_t *who;
258 flags_t flags;
259 char *item, *chan, *setting, *value, flagstr[64];
260 const char *next;
261 int i;
262
263 if (text && *text) who = user_lookup_by_handle(text);
264 else who = u;
265
266 if (!who) {
267 partymember_printf(p, "No such user.");
268 return(0);
269 }
270
271 next = core_config.whois_items;
272 while (next && *next) {
273 egg_get_arg(next, &next, &item);
274 if (!strcasecmp(item, "handle")) {
275 partymember_printf(p, "%s: '%s'", item, who->handle);
276 }
277 else if (!strcasecmp(item, "uid")) {
278 partymember_printf(p, "%s: '%d'", item, who->uid);
279 }
280 else if (!strcasecmp(item, "ircmasks")) {
281 partymember_printf(p, "%s:", item);
282 for (i = 0; i < who->nircmasks; i++) {
283 partymember_printf(p, " %d. '%s'", i+1, who->ircmasks[i]);
284 }
285 }
286 else {
287 if ((setting = strchr(item, '.'))) {
288 chan = item;
289 *setting = 0;
290 setting++;
291 }
292 else {
293 chan = NULL;
294 setting = item;
295 }
296 if (!strcasecmp(setting, "flags")) {
297 user_get_flags(who, chan, &flags);
298 flag_to_str(&flags, flagstr);
299 value = flagstr;
300 }
301 else {
302 user_get_setting(who, chan, setting, &value);
303 }
304
305 if (chan) partymember_printf(p, "%s.%s: %s", chan, setting, value);
306 else partymember_printf(p, "%s: %s", setting, value);
307 }
308 free(item);
309 }
310 return(0);
311 }
312
313 static int party_die(partymember_t *p, const char *nick, user_t *u, const char *cmd, const char *text)
314 {
315 /* XXX: should we really enable hard shutdowns?
316 if (*text && 0 == strcmp(text, "force")) {
317 return core_shutdown(SHUTDOWN_HARD, nick, text);
318 } else
319 */
320 return core_shutdown(SHUTDOWN_GRACEFULL, nick, text);
321 }
322
323 static int party_plus_user(partymember_t *p, const char *nick, user_t *u, const char *cmd, const char *text)
324 {
325 user_t *newuser;
326
327 if (!text || !*text) {
328 partymember_printf(p, _("Syntax: +user <handle>"));
329 return(0);
330 }
331 if (user_lookup_by_handle(text)) {
332 partymember_printf(p, _("User '%s' already exists!"));
333 return(0);
334 }
335 newuser = user_new(text);
336 if (newuser) partymember_printf(p, _("User '%s' created."), text);
337 else partymember_printf(p, _("Could not create user '%s'."), text);
338 return(0);
339 }
340
341 static int party_minus_user(partymember_t *p, const char *nick, user_t *u, const char *cmd, const char *text)
342 {
343 user_t *who;
344
345 if (!text || !*text) {
346 partymember_printf(p, _("Syntax: -user <handle>"));
347 return(0);
348 }
349 who = user_lookup_by_handle(text);
350 if (!who) partymember_printf(p, _("User '%s' not found."));
351 else {
352 partymember_printf(p, _("Deleting user '%s'."), who->handle);
353 user_delete(who);
354 }
355 return(0);
356 }
357
358 static int party_plus_host(partymember_t *p, const char *nick, user_t *u, const char *cmd, const char *text)
359 {
360 user_t *who;
361 char *target, *newhost;
362
363 egg_get_args(text, NULL, &target, &newhost, NULL);
364 if (!target) {
365 partymember_printf(p, _("Syntax: +host [handle] <host>"));
366 return(0);
367 }
368 if (!newhost) {
369 newhost = target;
370 target = NULL;
371 }
372 if (target) {
373 who = user_lookup_by_handle(target);
374 if (!who) {
375 partymember_printf(p, _("User '%s' not found."), target);
376 goto done;
377 }
378 }
379 else {
380 who = u;
381 if (!who) {
382 partymember_printf(p, _("Only valid users can add hosts."));
383 goto done;
384 }
385 }
386 user_add_ircmask(who, newhost);
387 partymember_printf(p, _("Added '%1$s' to user '%2$s'."), newhost, who->handle);
388
389 done:
390 if (target) free(target);
391 free(newhost);
392
393 return(0);
394 }
395
396 static int party_minus_host(partymember_t *p, const char *nick, user_t *u, const char *cmd, const char *text)
397 {
398 user_t *who;
399 char *target, *host;
400
401 egg_get_args(text, NULL, &target, &host, NULL);
402 if (!target) {
403 partymember_printf(p, _("Syntax: -host [handle] <host>"));
404 return(0);
405 }
406 if (!host) {
407 host = target;
408 target = NULL;
409 }
410 if (target) {
411 who = user_lookup_by_handle(target);
412 if (!who) {
413 partymember_printf(p, _("User '%s' not found."), target);
414 goto done;
415 }
416 }
417 else {
418 who = u;
419 if (!who) {
420 partymember_printf(p, _("Only valid users can remove hosts."));
421 goto done;
422 }
423 }
424 if (user_del_ircmask(who, host)) {
425 partymember_printf(p, _("Mask '%1$s' not found for user '%2$s'."), host, who->handle);
426 }
427 else {
428 partymember_printf(p, _("Removed '%1$s' from user '%2$s'."), host, who->handle);
429 }
430
431 done:
432 if (target) free(target);
433 free(host);
434
435 return(0);
436 }
437
438 /* Syntax: chattr <user> [chan] <flags> */
439 static int party_chattr(partymember_t *p, const char *nick, user_t *u, const char *cmd, const char *text)
440 {
441 const char *next;
442 char *who, *flags, *chan;
443 user_t *dest;
444 flags_t flagstruct;
445 char flagstr[64];
446 int n;
447
448 n = egg_get_args(text, &next, &who, &chan, &flags, NULL);
449 if (!chan || !*chan) {
450 if (who) free(who);
451 partymember_printf(p, _("Syntax: chattr <handle> [channel] <+/-flags>"));
452 return(0);
453 }
454 if (!flags || !*flags) {
455 flags = chan;
456 chan = NULL;
457 }
458 dest = user_lookup_by_handle(who);
459 if (dest) {
460 user_set_flags_str(dest, chan, flags);
461 user_get_flags(dest, chan, &flagstruct);
462 flag_to_str(&flagstruct, flagstr);
463 partymember_printf(p, _("Flags for %s are now '%s'."), who, flagstr);
464 }
465 else partymember_printf(p, _("'%s' is not a valid user."), who);
466 free(who);
467 free(flags);
468 if (chan) free(chan);
469 return(0);
470 }
471
472 static int party_help(partymember_t *p, const char *nick, user_t *u, const char *cmd, const char *text)
473 {
474 return help_print_party(p, text);
475 }
476
477 static int party_addlog(partymember_t *p, const char *nick, user_t *u, const char *cmd, const char *text)
478 {
479 putlog(LOG_MISC, "*", "%s: %s", nick, text);
480
481 return BIND_RET_LOG;
482 }
483
484 static int party_modules(partymember_t *p, const char *nick, user_t *u, const char *cmd, const char *text)
485 {
486 const char **modules;
487 int nummods, ctr;
488
489 nummods = module_list(&modules);
490 partymember_printf(p, _("Loaded modules:"));
491 for (ctr = 0; ctr < nummods; ctr++) partymember_printf(p, " %s", modules[ctr]);
492 free(modules);
493
494 return BIND_RET_LOG;
495 }
496
497 static int party_loadmod(partymember_t *p, const char *nick, user_t *u, const char *cmd, const char *text)
498 {
499 if (!text || !*text) {
500 partymember_printf(p, _("Syntax: loadmod <module name>"));
501 return BIND_RET_BREAK;
502 }
503 switch (module_load(text)) {
504 case 0:
505 partymember_printf(p, _("Module '%s' loaded successfully."), text);
506 break;
507 case -1:
508 partymember_printf(p, _("Module '%s' is already loaded."), text);
509 break;
510 case -2:
511 partymember_printf(p, _("Module '%s' could not be loaded."), text);
512 break;
513 case -3:
514 partymember_printf(p, _("Module '%s' does not have a valid initialization function. Perhaps it is not an eggdrop module?"), text);
515 break;
516 }
517 return BIND_RET_LOG;
518 }
519
520 static int party_unloadmod(partymember_t *p, const char *nick, user_t *u, const char *cmd, const char *text)
521 {
522 if (!text || !*text) {
523 partymember_printf(p, _("Syntax: unloadmod <module name>"));
524 return BIND_RET_BREAK;
525 }
526 switch (module_unload(text, MODULE_USER)) {
527 case 0:
528 partymember_printf(p, _("Module '%s' unloaded successfully."), text);
529 break;
530 case -1:
531 partymember_printf(p, _("Module '%s' is not loaded."), text);
532 break;
533 case -2:
534 partymember_printf(p, _("Module '%s' has dependencies that are still loaded. You must unload them first."), text);
535 break;
536 case -3:
537 partymember_printf(p, _("Module '%s' refuses to be unloaded by you!"), text);
538 break;
539 }
540 return BIND_RET_LOG;
541 }
542
543 static int party_binds(partymember_t *p, const char *nick, user_t *u, const char *cmd, const char *text)
544 {
545 bind_table_t *table;
546 bind_entry_t *entry;
547 char flags[64];
548
549 partymember_printf(p, "%-16s %-16s %-16s %-10s %-5s %s", _("TABLE"), _("SYNTAX"),
550 _("FUNCTION"), _("MASK"), _("FLAGS"), _("HITS"));
551 for (table = bind_table_list(); table; table = table->next) {
552 for (entry = table->entries; entry; entry = entry->next) {
553 flag_to_str(&entry->user_flags, flags);
554 partymember_printf(p, "%-16s %-16s %-16s %-10s %-5s %i", table->name, table->syntax,
555 entry->function_name, entry->mask, flags, entry->nhits);
556 }
557 }
558
559 return BIND_RET_LOG;
560 }
561
562 static int party_restart(partymember_t *p, const char *nick, user_t *u, const char *cmd, const char *text)
563 {
564 core_restart (nick);
565
566 return BIND_RET_LOG;
567 }
568
569 /* Syntax: chhandle <old_handle> <new_handle> */
570 static int party_chhandle(partymember_t *p, const char *nick, user_t *u, const char *cmd, const char *text)
571 {
572 char *old = NULL, *new = NULL;
573 user_t *dest;
574
575 egg_get_args(text, NULL, &old, &new, NULL);
576 if (!old || !new || !*old || !*new) {
577 partymember_printf(p, _("Syntax: chhandle <old_handle> <new_handle>"));
578 goto chhandleend;
579 }
580
581 dest = user_lookup_by_handle(old);
582 if (!dest) {
583 partymember_printf(p, _("Error: User '%s' does not exist."), old);
584 goto chhandleend;
585 }
586
587 if (user_lookup_by_handle(new)) {
588 partymember_printf(p, _("Error: User '%s' already exists."), new);
589 goto chhandleend;
590 }
591
592 if (user_change_handle(dest, old, new))
593 partymember_printf(p, _("Ok, changed."));
594
595 chhandleend:
596 free(new);
597 free(old);
598
599 return BIND_RET_LOG;
600 }
601
602 /* Syntax: chpass <handle> [new_pass] */
603 static int party_chpass(partymember_t *p, const char *nick, user_t *u, const char *cmd, const char *text)
604 {
605 char *user = NULL, *pass = NULL;
606 user_t *dest;
607
608 egg_get_args(text, NULL, &user, &pass, NULL);
609
610 if (!user || !*user) {
611 partymember_printf(p, _("Syntax: chpass <handle> [pass]"));
612 goto chpassend;
613 }
614
615 dest = user_lookup_by_handle(user);
616 if (!dest) {
617 partymember_printf(p, _("Error: User '%s' does not exist."), user);
618 goto chpassend;
619 }
620
621 if (pass && *pass && strlen(pass) < 6) {
622 partymember_printf(p, _("Error: Please use at least 6 characters."));
623 goto chpassend;
624 }
625
626 if (user_set_pass(dest, pass))
627 partymember_printf(p, _("Removed password for %s."), user);
628 else
629 partymember_printf(p, _("Password for %s is now '%s'."), user, pass);
630
631 chpassend:
632 free(user);
633 free(pass);
634
635 return BIND_RET_LOG_COMMAND;
636 }
637
638 /* Makes sure 'start' and 'limit' arguments for .match are reasonable, or else sets them -1 */
639 static int party_match_getbounds(const char *strstart, const char *strlimit, long *start, long *limit)
640 {
641 char *tmpptr;
642
643 if (strstart) {
644 *start = strtol(strstart, &tmpptr, 10);
645 if (!*strstart || *tmpptr || *start < 1) { /* Invalid input*/
646 *start = -1;
647 return 0;
648 }
649
650 if (strlimit) { /* 'start' was really a start and this is now 'limit' */
651 *limit = strtol(strlimit, &tmpptr, 10);
652 if (!*strlimit || *tmpptr || *limit < 1) { /* Invalid input*/
653 *limit = -1;
654 return 0;
655 }
656 }
657 else { /* Ah, no, the only argument specified was the 'limit' */
658 *limit = *start;
659 *start = 0;
660 }
661 }
662 else {
663 *limit = 20;
664 *start = 0;
665 }
666
667 return 0;
668 }
669
670 /* Handles case where .match was given mask to match against */
671 static int party_matchwild(partymember_t *p, const char *mask, const char *rest)
672 {
673 char *strstart = NULL, *strlimit = NULL;
674 long start, limit;
675
676 egg_get_args(rest, NULL, &strstart, &strlimit, NULL);
677
678 party_match_getbounds(strstart, strlimit, &start, &limit);
679 if (start == -1 || limit == -1)
680 partymember_printf(p, _("Error: 'start' and 'limit' must be positive integers"));
681 else
682 partyline_cmd_match_ircmask(p, mask, start, limit);
683
684 free(strstart);
685 free(strlimit);
686
687 return 0;
688 }
689
690 /* Handles case where .match was given attributes to match against */
691 static int party_matchattr(partymember_t *p, const char *mask, const char *rest)
692 {
693 char *channel = NULL, *strstart = NULL, *strlimit = NULL;
694 long start, limit;
695 int ischan = 0;
696
697 egg_get_args(rest, NULL, &channel, &strstart, &strlimit, NULL);
698
699 /* This is probably the easiest way to conclude if content of 'channel'
700 is *NOT* a number, and thus it is a candidate for a valid channel name */
701 if (channel && (*channel < '0' || *channel > '9'))
702 ischan = 1;
703
704
705 if (strlimit) /* .match <flags> <channel> <start> <limit> */
706 party_match_getbounds(strstart, strlimit, &start, &limit);
707 else if (strstart) /* .match <flags> <channel|start> <limit> */
708 party_match_getbounds(ischan?strstart:channel, ischan?NULL:strstart, &start, &limit);
709 else if (ischan) { /* .match <flags> <channel> */
710 start = 0;
711 limit = 20;
712 }
713 else /* .match <flags> [limit] */
714 party_match_getbounds(channel, NULL, &start, &limit);
715
716 free(strstart);
717 free(strlimit);
718
719 if (start == -1 || limit == -1)
720 partymember_printf(p, _("Error: 'start' and 'limit' must be positive integers"));
721 else
722 partyline_cmd_match_attr(p, mask, ischan?channel:NULL, start, limit);
723
724 free(channel);
725
726 return 0;
727 }
728
729 /* match <attr> [channel] [[start] limit] */
730 /* match <mask> [[start] limit] */
731 static int party_match(partymember_t *p, const char *nick, user_t *u, const char *cmd, const char *text)
732 {
733
734 char *attr = NULL;
735 const char *rest = NULL;
736
737 /* FIXME - Check if user is allowed to see results.. if !chan && !glob_master && -> error
738 I have left it available to everyone because 'whois' was that way too.
739 We should update both or neither */
740
741 egg_get_args(text, &rest, &attr, NULL);
742
743 if (!attr) {
744 partymember_printf(p, _("Syntax: match <attr> [channel] [[start] limit]"));
745 partymember_printf(p, _(" or: match <mask> [[start] limit]"));
746 free(attr);
747 return 0;
748 }
749
750 if (*attr == '+' || *attr == '-' || *attr == '|')
751 party_matchattr(p, attr, rest);
752 else if (*attr != '&')
753 party_matchwild(p, attr, rest);
754
755 free(attr);
756
757 return BIND_RET_LOG;
758 }
759
760 static bind_list_t core_party_binds[] = { /* Old flags requirement */
761 {NULL, "join", party_join}, /* DDD */
762 {NULL, "whisper", party_whisper}, /* DDD */
763 {NULL, "newpass", party_newpass}, /* DDC */ /* -|- */
764 {NULL, "help", party_help}, /* DDC */ /* -|- */
765 {NULL, "part", party_part}, /* DDD */
766 {NULL, "quit", party_quit}, /* DDD */ /* -|- */
767 {NULL, "who", party_who}, /* DDD */
768 {NULL, "whois", party_whois}, /* DDC */ /* ot|o */
769 {NULL, "match", party_match}, /* DDC */ /* ot|o */
770 {"n", "addlog", party_addlog}, /* DDD */ /* ot|o */
771 {"n", "get", party_get}, /* DDC */
772 {"n", "set", party_set}, /* DDC */
773 {"n", "unset", party_unset}, /* DDC */
774 {"n", "status", party_status}, /* DDC */ /* m|m */
775 {"n", "save", party_save}, /* DDD */ /* m|m */
776 {"n", "die", party_die}, /* DDD */ /* n|- */
777 {"n", "restart", party_restart}, /* DDD */ /* m|- */
778 {"n", "+user", party_plus_user}, /* DDC */ /* m|- */
779 {"n", "-user", party_minus_user}, /* DDC */ /* m|- */
780 {"n", "chattr", party_chattr}, /* DDC */ /* m|m */
781 {"n", "modules", party_modules}, /* DDD */ /* n|- */
782 {"n", "loadmod", party_loadmod}, /* DDD */ /* n|- */
783 {"n", "unloadmod", party_unloadmod}, /* DDD */ /* n|- */
784 {"n", "binds", party_binds}, /* DDD */ /* m|- */
785 {"m", "+host", party_plus_host}, /* DDC */ /* t|m */
786 {"m", "-host", party_minus_host}, /* DDC */ /* -|- */
787 {"t", "chhandle", party_chhandle}, /* DDC */ /* t|- */
788 {"t", "chpass", party_chpass}, /* DDC */ /* t|- */
789 {0}
790 };
791
792 void core_party_init(void)
793 {
794 bind_add_list("party", core_party_binds);
795 }
796

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23