diff --git a/src/mod/channels.mod/channels.c b/src/mod/channels.mod/channels.c index dc202dc22..08584eb3d 100644 --- a/src/mod/channels.mod/channels.c +++ b/src/mod/channels.mod/channels.c @@ -32,6 +32,8 @@ static Function *global = NULL; static char chanfile[121], glob_chanmode[65]; static char *lastdeletedmask; +static p_tcl_bind_list H_chanset; + static struct udef_struct *udef; static int use_info, chan_hack, quiet_save, global_revenge_mode, @@ -241,6 +243,32 @@ static void get_mode_protect(struct chanset_t *chan, char *s) } } +static int builtin_chanset STDVAR +{ + Function F = (Function) cd; + + BADARGS(4, 4, " chan, setting, type, value"); + + CHECKVALIDITY(builtin_chanset); + F(argv[1], argv[2], argv[3]); + return TCL_OK; +} + +int check_tcl_chanset(const char *chan, const char *setting, const char *type, const char *value) +{ + int x; + + Tcl_SetVar(interp, "_chanset1", (char *) chan, 0); + Tcl_SetVar(interp, "_chanset2", (char *) setting, 0); + Tcl_SetVar(interp, "_chanset3", (char *) type, 0); + Tcl_SetVar(interp, "_chanset4", (char *) value, 0); + + x = check_tcl_bind(H_chanset, chan, 0, " $_chanset1 $_chanset2 $_chanset3 $_chanset4", + BIND_STACKABLE | BIND_WANTRET); + + return 0; +} + /* Returns true if this is one of the channel masks */ static int ismodeline(masklist *m, char *user) diff --git a/src/mod/channels.mod/cmdschan.c b/src/mod/channels.mod/cmdschan.c index a267dfb08..340d1ce7b 100644 --- a/src/mod/channels.mod/cmdschan.c +++ b/src/mod/channels.mod/cmdschan.c @@ -1472,7 +1472,7 @@ static void cmd_chaninfo(struct userrec *u, int idx, char *par) static void cmd_chanset(struct userrec *u, int idx, char *par) { - char *chname = NULL, answers[512], *parcpy; + char *chname = NULL, answers[1024], *parcpy; char *list[2], *bak, *buf; struct chanset_t *chan = NULL; int all = 0; @@ -1555,6 +1555,14 @@ static void cmd_chanset(struct userrec *u, int idx, char *par) return; } list[1] = par; + /* Don't send any follow-on arguments if this is an integer value */ + list[1] = newsplit(&par); +/* + ptr = strchr(list[1], ' '); + if (ptr != NULL) { + *ptr = '\0'; + } +*/ /* Par gets modified in tcl_channel_modify under some * circumstances, so save it now. */ @@ -1563,18 +1571,19 @@ static void cmd_chanset(struct userrec *u, int idx, char *par) irp = Tcl_CreateInterp(); if (tcl_channel_modify(irp, chan, 2, list) == TCL_OK) { int len = strlen(answers); - egg_snprintf(answers + len, (sizeof answers) - len, "%s { %s }", list[0], parcpy); /* Concatenation */ + egg_snprintf(answers + len, (sizeof answers) - len, "%s { %s } ", list[0], list[1]); /* Concatenation */ } else if (!all || !chan->next) dprintf(idx, "Error trying to set %s for %s, %s\n", list[0], all ? "all channels" : chname, Tcl_GetStringResult(irp)); Tcl_ResetResult(irp); Tcl_DeleteInterp(irp); nfree(parcpy); + list[0] = newsplit(&par); + list[1] = '\0'; } - break; } if (!all && answers[0]) { - dprintf(idx, "Successfully set modes { %s } on %s.\n", answers, + dprintf(idx, "Successfully set modes { %s} on %s.\n", answers, chname); putlog(LOG_CMDS, "*", "#%s# chanset %s %s", dcc[idx].nick, chname, answers); @@ -1585,7 +1594,7 @@ static void cmd_chanset(struct userrec *u, int idx, char *par) chan = chan->next; } if (all && answers[0]) { - dprintf(idx, "Successfully set modes { %s } on all channels.\n", + dprintf(idx, "Successfully set modes { %s} on all channels.\n", answers); putlog(LOG_CMDS, "*", "#%s# chanset * %s", dcc[idx].nick, answers); }