/[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.41 - (show annotations) (download) (as text)
Wed Sep 29 15:38:39 2004 UTC (15 years ago) by stdarg
Branch: MAIN
Changes since 1.40: +31 -8 lines
File MIME type: text/x-chdr
*** empty log message ***

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

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23