+ struct helpfile_table tbl;
+ unsigned int count = 0, ii = 0;
+ struct badword **badwords;
+
+ dict_iterator_t it;
+ for (it = dict_first(shitlist); it; it = iter_next(it)) {
+ count++;
+ }
+ tbl.length = count+1;
+ tbl.width = 5;
+ tbl.flags = 0;
+ tbl.flags = TABLE_NO_FREE;
+ tbl.contents = malloc(tbl.length * sizeof(tbl.contents[0]));
+ tbl.contents[0] = malloc(tbl.width * sizeof(tbl.contents[0][0]));
+ tbl.contents[0][0] = "#";
+ tbl.contents[0][1] = "Badword";
+ tbl.contents[0][2] = "Action";
+ tbl.contents[0][3] = "(Triggered)";
+ tbl.contents[0][4] = "Alert";
+ if(!count)
+ {
+ table_send(cmd->parent->bot, user->nick, 0, NULL, tbl);
+ reply("MSG_NONE");
+ free(tbl.contents[0]);
+ free(tbl.contents);
+ return 0;
+ }
+ badwords = alloca(count * sizeof(badwords[0]));
+ for (it = dict_first(shitlist); it; it = iter_next(it)) {
+ struct badword *bw = iter_data(it);
+ badwords[ii++] = bw;
+ }
+ qsort(badwords, count, sizeof(badwords[0]), badwords_sort);
+ for (ii = 1; ii <= count; ii++) {
+ struct badword *bw = badwords[ii-1];
+ tbl.contents[ii] = malloc(tbl.width * sizeof(tbl.contents[0][0]));
+ tbl.contents[ii][0] = strdup(bw->id);
+ tbl.contents[ii][1] = strdup(bw->badword_mask);
+ switch(bw->action) {
+ case BADACTION_KICK:
+ tbl.contents[ii][2] = "KICK";
+ break;
+ case BADACTION_BAN:
+ tbl.contents[ii][2] = "BAN";
+ break;
+ case BADACTION_KILL:
+ tbl.contents[ii][2] = "KILL";
+ break;
+ case BADACTION_GLINE:
+ tbl.contents[ii][2] = "GLINE";
+ break;
+ default:
+ tbl.contents[ii][2] = "*undef*";
+ }
+ tbl.contents[ii][3] = strtab(bw->triggered);
+ tbl.contents[ii][4] = strtab(bw->alert);
+ }
+ table_send(cmd->parent->bot, user->nick, 0, NULL, tbl);
+ for(ii = 1; ii < tbl.length; ++ii)
+ {
+ free(tbl.contents[ii]);
+ }
+ free(tbl.contents[0]);
+ free(tbl.contents);
+ return 1;
+}
+
+static MODCMD_FUNC(cmd_register)
+{
+ dict_iterator_t it;
+ struct modeNode *mn;
+
+ if(channel)
+ {
+
+ if(channel->bad_channel)
+ {
+ reply("CSMSG_ILLEGAL_CHANNEL", channel->name);
+ return 0;
+ }
+
+ if(!IsHelping(user)
+ && (!(mn = GetUserMode(channel, user)) || !(mn->modes & MODE_CHANOP)))
+ {
+ reply("CSMSG_MUST_BE_OPPED", channel->name);
+ return 0;
+ }
+
+ }
+ else
+ {
+
+ if((argc < 2) || !IsChannelName(argv[1]))
+ {
+ reply("MSG_NOT_CHANNEL_NAME");
+ return 0;
+ }
+
+ if(opserv_bad_channel(argv[1]))
+ {
+ reply("CSMSG_ILLEGAL_CHANNEL", argv[1]);
+ return 0;
+ }
+
+ channel = AddChannel(argv[1], now, NULL, NULL);
+ }
+
+ for (it = dict_first(chanlist); it; it = iter_next(it)) {
+ struct watchdog_channel *chan = iter_data(it);
+ if(chan->channel == channel) {
+ reply("CSMSG_ALREADY_REGGED", channel->name);
+ return 0;
+ }
+ }
+
+ add_channel(channel->name);
+ reply("WDMSG_REGISTER_SUCCESS", channel->name, watchdog->nick);
+ watchdog_oper_message("WDMSG_REGISTER_SUCCESS", channel->name, watchdog->nick);