From 6c55e0a529c7f1216ff6f63a4fc77ea06a2a3a38 Mon Sep 17 00:00:00 2001 From: rburchell Date: Fri, 14 Nov 2008 20:57:20 +0000 Subject: Insane commit of doom: s/ \t/g git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@1681 5417fbe8-f217-4b02-8779-1006273d7864 --- src/core/bs_act.c | 64 +-- src/core/bs_assign.c | 52 +- src/core/bs_badwords.c | 476 +++++++++--------- src/core/bs_bot.c | 8 +- src/core/bs_botlist.c | 70 +-- src/core/bs_fantasy.c | 58 +-- src/core/bs_fantasy_kick.c | 72 +-- src/core/bs_fantasy_kickban.c | 74 +-- src/core/bs_fantasy_owner.c | 40 +- src/core/bs_fantasy_seen.c | 152 +++--- src/core/bs_help.c | 20 +- src/core/bs_info.c | 394 +++++++-------- src/core/bs_kick.c | 544 ++++++++++---------- src/core/bs_say.c | 56 +-- src/core/bs_set.c | 222 ++++----- src/core/bs_unassign.c | 40 +- src/core/cs_access.c | 872 ++++++++++++++++---------------- src/core/cs_akick.c | 1110 ++++++++++++++++++++--------------------- src/core/cs_ban.c | 286 +++++------ src/core/cs_clear.c | 606 +++++++++++----------- src/core/cs_drop.c | 118 ++--- src/core/cs_forbid.c | 142 +++--- src/core/cs_getkey.c | 34 +- src/core/cs_getpass.c | 60 +-- src/core/cs_help.c | 56 +-- src/core/cs_identify.c | 88 ++-- src/core/cs_info.c | 348 ++++++------- src/core/cs_invite.c | 40 +- src/core/cs_kick.c | 170 +++---- src/core/cs_list.c | 254 +++++----- src/core/cs_logout.c | 100 ++-- src/core/cs_modes.c | 420 ++++++++-------- src/core/cs_register.c | 240 ++++----- src/core/cs_sendpass.c | 100 ++-- src/core/cs_set.c | 1084 ++++++++++++++++++++-------------------- src/core/cs_status.c | 62 +-- src/core/cs_suspend.c | 264 +++++----- src/core/cs_topic.c | 96 ++-- src/core/cs_xop.c | 746 +++++++++++++-------------- src/core/enc_md5.c | 56 +-- src/core/enc_none.c | 40 +- src/core/enc_old.c | 388 +++++++------- src/core/enc_sha1.c | 266 +++++----- src/core/he_help.c | 30 +- src/core/hs_del.c | 44 +- src/core/hs_delall.c | 54 +- src/core/hs_group.c | 106 ++-- src/core/hs_help.c | 18 +- src/core/hs_list.c | 220 ++++---- src/core/hs_off.c | 38 +- src/core/hs_on.c | 68 +-- src/core/hs_set.c | 218 ++++---- src/core/hs_setall.c | 220 ++++---- src/core/ms_cancel.c | 66 +-- src/core/ms_check.c | 98 ++-- src/core/ms_del.c | 242 ++++----- src/core/ms_help.c | 20 +- src/core/ms_info.c | 328 ++++++------ src/core/ms_list.c | 198 ++++---- src/core/ms_read.c | 218 ++++---- src/core/ms_rsend.c | 100 ++-- src/core/ms_send.c | 12 +- src/core/ms_sendall.c | 48 +- src/core/ms_set.c | 334 ++++++------- src/core/ms_staff.c | 46 +- src/core/ns_access.c | 240 ++++----- src/core/ns_alist.c | 212 ++++---- src/core/ns_drop.c | 158 +++--- src/core/ns_forbid.c | 160 +++--- src/core/ns_getemail.c | 60 +-- src/core/ns_getpass.c | 86 ++-- src/core/ns_ghost.c | 104 ++-- src/core/ns_group.c | 434 ++++++++-------- src/core/ns_help.c | 42 +- src/core/ns_identify.c | 194 +++---- src/core/ns_info.c | 406 +++++++-------- src/core/ns_list.c | 322 ++++++------ src/core/ns_logout.c | 104 ++-- src/core/ns_recover.c | 114 ++--- src/core/ns_register.c | 744 +++++++++++++-------------- src/core/ns_release.c | 90 ++-- src/core/ns_saset.c | 678 ++++++++++++------------- src/core/ns_sendpass.c | 100 ++-- src/core/ns_set.c | 600 +++++++++++----------- src/core/ns_status.c | 48 +- src/core/ns_suspend.c | 226 ++++----- src/core/ns_update.c | 40 +- src/core/os_admin.c | 320 ++++++------ src/core/os_akill.c | 560 ++++++++++----------- src/core/os_chankill.c | 122 ++--- src/core/os_chanlist.c | 88 ++-- src/core/os_clearmodes.c | 452 ++++++++--------- src/core/os_defcon.c | 162 +++--- src/core/os_global.c | 26 +- src/core/os_help.c | 20 +- src/core/os_ignore.c | 136 ++--- src/core/os_jupe.c | 34 +- src/core/os_kick.c | 62 +-- src/core/os_logonnews.c | 22 +- src/core/os_mode.c | 60 +-- src/core/os_modinfo.c | 118 ++--- src/core/os_modlist.c | 254 +++++----- src/core/os_modload.c | 8 +- src/core/os_modunload.c | 6 +- src/core/os_noop.c | 68 +-- src/core/os_oline.c | 70 +-- src/core/os_oper.c | 312 ++++++------ src/core/os_opernews.c | 28 +- src/core/os_quit.c | 26 +- src/core/os_randomnews.c | 6 +- src/core/os_raw.c | 34 +- src/core/os_reload.c | 32 +- src/core/os_restart.c | 30 +- src/core/os_session.c | 8 +- src/core/os_set.c | 322 ++++++------ src/core/os_sgline.c | 492 +++++++++--------- src/core/os_shutdown.c | 28 +- src/core/os_sqline.c | 498 +++++++++--------- src/core/os_staff.c | 140 +++--- src/core/os_stats.c | 698 +++++++++++++------------- src/core/os_svsnick.c | 106 ++-- src/core/os_szline.c | 488 +++++++++--------- src/core/os_umode.c | 84 ++-- src/core/os_update.c | 12 +- src/core/os_userlist.c | 94 ++-- 125 files changed, 12151 insertions(+), 12151 deletions(-) (limited to 'src/core') diff --git a/src/core/bs_act.c b/src/core/bs_act.c index a5c8864da..87cd3d21d 100644 --- a/src/core/bs_act.c +++ b/src/core/bs_act.c @@ -23,15 +23,15 @@ class BSAct : public Module public: BSAct(const std::string &modname, const std::string &creator) : Module(modname, creator) { - Command *c; + Command *c; - this->SetAuthor("Anope"); - this->SetVersion("$Id$"); - this->SetType(CORE); - c = createCommand("ACT", do_act, NULL, BOT_HELP_ACT, -1, -1, -1, -1); - this->AddCommand(BOTSERV, c, MOD_UNIQUE); + this->SetAuthor("Anope"); + this->SetVersion("$Id$"); + this->SetType(CORE); + c = createCommand("ACT", do_act, NULL, BOT_HELP_ACT, -1, -1, -1, -1); + this->AddCommand(BOTSERV, c, MOD_UNIQUE); - moduleSetBotHelp(myBotServHelp); + moduleSetBotHelp(myBotServHelp); } }; @@ -42,7 +42,7 @@ class BSAct : public Module **/ void myBotServHelp(User * u) { - notice_lang(s_BotServ, u, BOT_HELP_CMD_ACT); + notice_lang(s_BotServ, u, BOT_HELP_CMD_ACT); } /** @@ -52,32 +52,32 @@ void myBotServHelp(User * u) **/ int do_act(User * u) { - ChannelInfo *ci; + ChannelInfo *ci; - char *chan = strtok(NULL, " "); - char *text = strtok(NULL, ""); + char *chan = strtok(NULL, " "); + char *text = strtok(NULL, ""); - if (!chan || !text) - syntax_error(s_BotServ, u, "ACT", BOT_ACT_SYNTAX); - else if (!(ci = cs_findchan(chan))) - notice_lang(s_BotServ, u, CHAN_X_NOT_REGISTERED, chan); - else if (ci->flags & CI_VERBOTEN) - notice_lang(s_BotServ, u, CHAN_X_FORBIDDEN, chan); - else if (!ci->bi) - notice_help(s_BotServ, u, BOT_NOT_ASSIGNED); - else if (!ci->c || ci->c->usercount < BSMinUsers) - notice_lang(s_BotServ, u, BOT_NOT_ON_CHANNEL, ci->name); - else if (!check_access(u, ci, CA_SAY)) - notice_lang(s_BotServ, u, ACCESS_DENIED); - else { - strnrepl(text, BUFSIZE, "\001", ""); - ircdproto->SendAction(ci->bi, ci->name, "%s", text); - ci->bi->lastmsg = time(NULL); - if (LogBot && LogChannel && logchan && !debug && findchan(LogChannel)) - ircdproto->SendPrivmsg(ci->bi, LogChannel, "ACT %s %s %s", - u->nick, ci->name, text); - } - return MOD_CONT; + if (!chan || !text) + syntax_error(s_BotServ, u, "ACT", BOT_ACT_SYNTAX); + else if (!(ci = cs_findchan(chan))) + notice_lang(s_BotServ, u, CHAN_X_NOT_REGISTERED, chan); + else if (ci->flags & CI_VERBOTEN) + notice_lang(s_BotServ, u, CHAN_X_FORBIDDEN, chan); + else if (!ci->bi) + notice_help(s_BotServ, u, BOT_NOT_ASSIGNED); + else if (!ci->c || ci->c->usercount < BSMinUsers) + notice_lang(s_BotServ, u, BOT_NOT_ON_CHANNEL, ci->name); + else if (!check_access(u, ci, CA_SAY)) + notice_lang(s_BotServ, u, ACCESS_DENIED); + else { + strnrepl(text, BUFSIZE, "\001", ""); + ircdproto->SendAction(ci->bi, ci->name, "%s", text); + ci->bi->lastmsg = time(NULL); + if (LogBot && LogChannel && logchan && !debug && findchan(LogChannel)) + ircdproto->SendPrivmsg(ci->bi, LogChannel, "ACT %s %s %s", + u->nick, ci->name, text); + } + return MOD_CONT; } MODULE_INIT("bs_act", BSAct) diff --git a/src/core/bs_assign.c b/src/core/bs_assign.c index 7cb6e3887..030a3c215 100644 --- a/src/core/bs_assign.c +++ b/src/core/bs_assign.c @@ -41,7 +41,7 @@ class BSAssign : public Module **/ void myBotServHelp(User * u) { - notice_lang(s_BotServ, u, BOT_HELP_CMD_ASSIGN); + notice_lang(s_BotServ, u, BOT_HELP_CMD_ASSIGN); } /** @@ -51,33 +51,33 @@ void myBotServHelp(User * u) **/ int do_assign(User * u) { - char *chan = strtok(NULL, " "); - char *nick = strtok(NULL, " "); - BotInfo *bi; - ChannelInfo *ci; + char *chan = strtok(NULL, " "); + char *nick = strtok(NULL, " "); + BotInfo *bi; + ChannelInfo *ci; - if (readonly) - notice_lang(s_BotServ, u, BOT_ASSIGN_READONLY); - else if (!chan || !nick) - syntax_error(s_BotServ, u, "ASSIGN", BOT_ASSIGN_SYNTAX); - else if (!(bi = findbot(nick))) - notice_lang(s_BotServ, u, BOT_DOES_NOT_EXIST, nick); - else if (bi->flags & BI_PRIVATE && !is_oper(u)) - notice_lang(s_BotServ, u, PERMISSION_DENIED); - else if (!(ci = cs_findchan(chan))) - notice_lang(s_BotServ, u, CHAN_X_NOT_REGISTERED, chan); - else if (ci->flags & CI_VERBOTEN) - notice_lang(s_BotServ, u, CHAN_X_FORBIDDEN, chan); - else if ((ci->bi) && (stricmp(ci->bi->nick, nick) == 0)) - notice_lang(s_BotServ, u, BOT_ASSIGN_ALREADY, ci->bi->nick, chan); - else if ((ci->botflags & BS_NOBOT) - || (!check_access(u, ci, CA_ASSIGN) && !is_services_admin(u))) - notice_lang(s_BotServ, u, PERMISSION_DENIED); - else { + if (readonly) + notice_lang(s_BotServ, u, BOT_ASSIGN_READONLY); + else if (!chan || !nick) + syntax_error(s_BotServ, u, "ASSIGN", BOT_ASSIGN_SYNTAX); + else if (!(bi = findbot(nick))) + notice_lang(s_BotServ, u, BOT_DOES_NOT_EXIST, nick); + else if (bi->flags & BI_PRIVATE && !is_oper(u)) + notice_lang(s_BotServ, u, PERMISSION_DENIED); + else if (!(ci = cs_findchan(chan))) + notice_lang(s_BotServ, u, CHAN_X_NOT_REGISTERED, chan); + else if (ci->flags & CI_VERBOTEN) + notice_lang(s_BotServ, u, CHAN_X_FORBIDDEN, chan); + else if ((ci->bi) && (stricmp(ci->bi->nick, nick) == 0)) + notice_lang(s_BotServ, u, BOT_ASSIGN_ALREADY, ci->bi->nick, chan); + else if ((ci->botflags & BS_NOBOT) + || (!check_access(u, ci, CA_ASSIGN) && !is_services_admin(u))) + notice_lang(s_BotServ, u, PERMISSION_DENIED); + else { bi->Assign(u, ci); - notice_lang(s_BotServ, u, BOT_ASSIGN_ASSIGNED, bi->nick, ci->name); - } - return MOD_CONT; + notice_lang(s_BotServ, u, BOT_ASSIGN_ASSIGNED, bi->nick, ci->name); + } + return MOD_CONT; } MODULE_INIT("bs_assign", BSAssign) diff --git a/src/core/bs_badwords.c b/src/core/bs_badwords.c index 65190c286..e1518c51c 100644 --- a/src/core/bs_badwords.c +++ b/src/core/bs_badwords.c @@ -46,7 +46,7 @@ class BSBadwords : public Module **/ void myBotServHelp(User * u) { - notice_lang(s_BotServ, u, BOT_HELP_CMD_BADWORDS); + notice_lang(s_BotServ, u, BOT_HELP_CMD_BADWORDS); } /** @@ -56,259 +56,259 @@ void myBotServHelp(User * u) **/ int do_badwords(User * u) { - char *chan = strtok(NULL, " "); - char *cmd = strtok(NULL, " "); - char *word = strtok(NULL, ""); - ChannelInfo *ci; - BadWord *bw; - - int i; - int need_args = (cmd - && (!stricmp(cmd, "LIST") || !stricmp(cmd, "CLEAR"))); - - if (!cmd || (need_args ? 0 : !word)) { - syntax_error(s_BotServ, u, "BADWORDS", BOT_BADWORDS_SYNTAX); - } else if (!(ci = cs_findchan(chan))) { - notice_lang(s_BotServ, u, CHAN_X_NOT_REGISTERED, chan); - } else if (ci->flags & CI_VERBOTEN) { - notice_lang(s_BotServ, u, CHAN_X_FORBIDDEN, chan); - } else if (!check_access(u, ci, CA_BADWORDS) - && (!need_args || !is_services_admin(u))) { - notice_lang(s_BotServ, u, ACCESS_DENIED); - } else if (stricmp(cmd, "ADD") == 0) { - - char *opt, *pos; - int type = BW_ANY; - - if (readonly) { - notice_lang(s_BotServ, u, BOT_BADWORDS_DISABLED); - return MOD_CONT; - } - - pos = strrchr(word, ' '); - if (pos) { - opt = pos + 1; - if (*opt) { - if (!stricmp(opt, "SINGLE")) - type = BW_SINGLE; - else if (!stricmp(opt, "START")) - type = BW_START; - else if (!stricmp(opt, "END")) - type = BW_END; - if (type != BW_ANY) - *pos = 0; - } - } - - for (bw = ci->badwords, i = 0; i < ci->bwcount; bw++, i++) { - if (bw->word && ((BSCaseSensitive && (!strcmp(bw->word, word))) - || (!BSCaseSensitive - && (!stricmp(bw->word, word))))) { - notice_lang(s_BotServ, u, BOT_BADWORDS_ALREADY_EXISTS, - bw->word, ci->name); - return MOD_CONT; - } - } - - for (i = 0; i < ci->bwcount; i++) { - if (!ci->badwords[i].in_use) - break; - } - if (i == ci->bwcount) { - if (i < BSBadWordsMax) { - ci->bwcount++; - ci->badwords = - (BadWord *)srealloc(ci->badwords, sizeof(BadWord) * ci->bwcount); - } else { - notice_lang(s_BotServ, u, BOT_BADWORDS_REACHED_LIMIT, - BSBadWordsMax); - return MOD_CONT; - } - } - bw = &ci->badwords[i]; - bw->in_use = 1; - bw->word = sstrdup(word); - bw->type = type; - - notice_lang(s_BotServ, u, BOT_BADWORDS_ADDED, bw->word, ci->name); - - } else if (stricmp(cmd, "DEL") == 0) { - int deleted = 0, a, b; - - if (readonly) { - notice_lang(s_BotServ, u, BOT_BADWORDS_DISABLED); - return MOD_CONT; - } - - /* Special case: is it a number/list? Only do search if it isn't. */ - if (isdigit(*word) && strspn(word, "1234567890,-") == strlen(word)) { - int count, last = -1; - deleted = - process_numlist(word, &count, badwords_del_callback, u, ci, - &last); - if (!deleted) { - if (count == 1) { - notice_lang(s_BotServ, u, BOT_BADWORDS_NO_SUCH_ENTRY, - last, ci->name); - } else { - notice_lang(s_BotServ, u, BOT_BADWORDS_NO_MATCH, - ci->name); - } - } else if (deleted == 1) { - notice_lang(s_BotServ, u, BOT_BADWORDS_DELETED_ONE, - ci->name); - } else { - notice_lang(s_BotServ, u, BOT_BADWORDS_DELETED_SEVERAL, - deleted, ci->name); - } - } else { - for (i = 0; i < ci->bwcount; i++) { - if (ci->badwords[i].in_use - && !stricmp(ci->badwords[i].word, word)) - break; - } - if (i == ci->bwcount) { - notice_lang(s_BotServ, u, BOT_BADWORDS_NOT_FOUND, word, - chan); - return MOD_CONT; - } - bw = &ci->badwords[i]; - notice_lang(s_BotServ, u, BOT_BADWORDS_DELETED, bw->word, - ci->name); - if (bw->word) - free(bw->word); - bw->word = NULL; - bw->in_use = 0; - deleted = 1; - } - - if (deleted) { - /* Reordering - DrStein */ - for (b = 0; b < ci->bwcount; b++) { - if (ci->badwords[b].in_use) { - for (a = 0; a < ci->bwcount; a++) { - if (a > b) - break; - if (!(ci->badwords[a].in_use)) { - ci->badwords[a].in_use = ci->badwords[b].in_use; - ci->badwords[a].type = ci->badwords[b].type; - if (ci->badwords[b].word) { - ci->badwords[a].word = sstrdup(ci->badwords[b].word); - free(ci->badwords[b].word); - } - ci->badwords[b].word = NULL; - ci->badwords[b].in_use = 0; - break; - } - } - } - } - /* After reordering only the entries at the end could still be empty. - * We ll free the places no longer in use... - Viper */ - for (i = ci->bwcount - 1; i >= 0; i--) { - if (ci->badwords[i].in_use) - break; - ci->bwcount--; - } - ci->badwords = - (BadWord *)srealloc(ci->badwords,sizeof(BadWord) * ci->bwcount); - } - - } else if (stricmp(cmd, "LIST") == 0) { - int sent_header = 0; - - if (ci->bwcount == 0) { - notice_lang(s_BotServ, u, BOT_BADWORDS_LIST_EMPTY, chan); - return MOD_CONT; - } - if (word && strspn(word, "1234567890,-") == strlen(word)) { - process_numlist(word, NULL, badwords_list_callback, u, ci, - &sent_header); - } else { - for (i = 0; i < ci->bwcount; i++) { - if (!(ci->badwords[i].in_use)) - continue; - if (word && ci->badwords[i].word - && !match_wild_nocase(word, ci->badwords[i].word)) - continue; - badwords_list(u, i, ci, &sent_header); - } - } - if (!sent_header) - notice_lang(s_BotServ, u, BOT_BADWORDS_NO_MATCH, chan); - - } else if (stricmp(cmd, "CLEAR") == 0) { - - if (readonly) { - notice_lang(s_BotServ, u, BOT_BADWORDS_DISABLED); - return MOD_CONT; - } - - for (i = 0; i < ci->bwcount; i++) - if (ci->badwords[i].word) - free(ci->badwords[i].word); - - free(ci->badwords); - ci->badwords = NULL; - ci->bwcount = 0; - - notice_lang(s_BotServ, u, BOT_BADWORDS_CLEAR); - - } else { - syntax_error(s_BotServ, u, "BADWORDS", BOT_BADWORDS_SYNTAX); - } - return MOD_CONT; + char *chan = strtok(NULL, " "); + char *cmd = strtok(NULL, " "); + char *word = strtok(NULL, ""); + ChannelInfo *ci; + BadWord *bw; + + int i; + int need_args = (cmd + && (!stricmp(cmd, "LIST") || !stricmp(cmd, "CLEAR"))); + + if (!cmd || (need_args ? 0 : !word)) { + syntax_error(s_BotServ, u, "BADWORDS", BOT_BADWORDS_SYNTAX); + } else if (!(ci = cs_findchan(chan))) { + notice_lang(s_BotServ, u, CHAN_X_NOT_REGISTERED, chan); + } else if (ci->flags & CI_VERBOTEN) { + notice_lang(s_BotServ, u, CHAN_X_FORBIDDEN, chan); + } else if (!check_access(u, ci, CA_BADWORDS) + && (!need_args || !is_services_admin(u))) { + notice_lang(s_BotServ, u, ACCESS_DENIED); + } else if (stricmp(cmd, "ADD") == 0) { + + char *opt, *pos; + int type = BW_ANY; + + if (readonly) { + notice_lang(s_BotServ, u, BOT_BADWORDS_DISABLED); + return MOD_CONT; + } + + pos = strrchr(word, ' '); + if (pos) { + opt = pos + 1; + if (*opt) { + if (!stricmp(opt, "SINGLE")) + type = BW_SINGLE; + else if (!stricmp(opt, "START")) + type = BW_START; + else if (!stricmp(opt, "END")) + type = BW_END; + if (type != BW_ANY) + *pos = 0; + } + } + + for (bw = ci->badwords, i = 0; i < ci->bwcount; bw++, i++) { + if (bw->word && ((BSCaseSensitive && (!strcmp(bw->word, word))) + || (!BSCaseSensitive + && (!stricmp(bw->word, word))))) { + notice_lang(s_BotServ, u, BOT_BADWORDS_ALREADY_EXISTS, + bw->word, ci->name); + return MOD_CONT; + } + } + + for (i = 0; i < ci->bwcount; i++) { + if (!ci->badwords[i].in_use) + break; + } + if (i == ci->bwcount) { + if (i < BSBadWordsMax) { + ci->bwcount++; + ci->badwords = + (BadWord *)srealloc(ci->badwords, sizeof(BadWord) * ci->bwcount); + } else { + notice_lang(s_BotServ, u, BOT_BADWORDS_REACHED_LIMIT, + BSBadWordsMax); + return MOD_CONT; + } + } + bw = &ci->badwords[i]; + bw->in_use = 1; + bw->word = sstrdup(word); + bw->type = type; + + notice_lang(s_BotServ, u, BOT_BADWORDS_ADDED, bw->word, ci->name); + + } else if (stricmp(cmd, "DEL") == 0) { + int deleted = 0, a, b; + + if (readonly) { + notice_lang(s_BotServ, u, BOT_BADWORDS_DISABLED); + return MOD_CONT; + } + + /* Special case: is it a number/list? Only do search if it isn't. */ + if (isdigit(*word) && strspn(word, "1234567890,-") == strlen(word)) { + int count, last = -1; + deleted = + process_numlist(word, &count, badwords_del_callback, u, ci, + &last); + if (!deleted) { + if (count == 1) { + notice_lang(s_BotServ, u, BOT_BADWORDS_NO_SUCH_ENTRY, + last, ci->name); + } else { + notice_lang(s_BotServ, u, BOT_BADWORDS_NO_MATCH, + ci->name); + } + } else if (deleted == 1) { + notice_lang(s_BotServ, u, BOT_BADWORDS_DELETED_ONE, + ci->name); + } else { + notice_lang(s_BotServ, u, BOT_BADWORDS_DELETED_SEVERAL, + deleted, ci->name); + } + } else { + for (i = 0; i < ci->bwcount; i++) { + if (ci->badwords[i].in_use + && !stricmp(ci->badwords[i].word, word)) + break; + } + if (i == ci->bwcount) { + notice_lang(s_BotServ, u, BOT_BADWORDS_NOT_FOUND, word, + chan); + return MOD_CONT; + } + bw = &ci->badwords[i]; + notice_lang(s_BotServ, u, BOT_BADWORDS_DELETED, bw->word, + ci->name); + if (bw->word) + free(bw->word); + bw->word = NULL; + bw->in_use = 0; + deleted = 1; + } + + if (deleted) { + /* Reordering - DrStein */ + for (b = 0; b < ci->bwcount; b++) { + if (ci->badwords[b].in_use) { + for (a = 0; a < ci->bwcount; a++) { + if (a > b) + break; + if (!(ci->badwords[a].in_use)) { + ci->badwords[a].in_use = ci->badwords[b].in_use; + ci->badwords[a].type = ci->badwords[b].type; + if (ci->badwords[b].word) { + ci->badwords[a].word = sstrdup(ci->badwords[b].word); + free(ci->badwords[b].word); + } + ci->badwords[b].word = NULL; + ci->badwords[b].in_use = 0; + break; + } + } + } + } + /* After reordering only the entries at the end could still be empty. + * We ll free the places no longer in use... - Viper */ + for (i = ci->bwcount - 1; i >= 0; i--) { + if (ci->badwords[i].in_use) + break; + ci->bwcount--; + } + ci->badwords = + (BadWord *)srealloc(ci->badwords,sizeof(BadWord) * ci->bwcount); + } + + } else if (stricmp(cmd, "LIST") == 0) { + int sent_header = 0; + + if (ci->bwcount == 0) { + notice_lang(s_BotServ, u, BOT_BADWORDS_LIST_EMPTY, chan); + return MOD_CONT; + } + if (word && strspn(word, "1234567890,-") == strlen(word)) { + process_numlist(word, NULL, badwords_list_callback, u, ci, + &sent_header); + } else { + for (i = 0; i < ci->bwcount; i++) { + if (!(ci->badwords[i].in_use)) + continue; + if (word && ci->badwords[i].word + && !match_wild_nocase(word, ci->badwords[i].word)) + continue; + badwords_list(u, i, ci, &sent_header); + } + } + if (!sent_header) + notice_lang(s_BotServ, u, BOT_BADWORDS_NO_MATCH, chan); + + } else if (stricmp(cmd, "CLEAR") == 0) { + + if (readonly) { + notice_lang(s_BotServ, u, BOT_BADWORDS_DISABLED); + return MOD_CONT; + } + + for (i = 0; i < ci->bwcount; i++) + if (ci->badwords[i].word) + free(ci->badwords[i].word); + + free(ci->badwords); + ci->badwords = NULL; + ci->bwcount = 0; + + notice_lang(s_BotServ, u, BOT_BADWORDS_CLEAR); + + } else { + syntax_error(s_BotServ, u, "BADWORDS", BOT_BADWORDS_SYNTAX); + } + return MOD_CONT; } int badwords_del_callback(User * u, int num, va_list args) { - BadWord *bw; - ChannelInfo *ci = va_arg(args, ChannelInfo *); - int *last = va_arg(args, int *); + BadWord *bw; + ChannelInfo *ci = va_arg(args, ChannelInfo *); + int *last = va_arg(args, int *); - *last = num; + *last = num; - if (num < 1 || num > ci->bwcount) - return 0; + if (num < 1 || num > ci->bwcount) + return 0; - bw = &ci->badwords[num - 1]; - if (bw->word) - free(bw->word); - bw->word = NULL; - bw->in_use = 0; + bw = &ci->badwords[num - 1]; + if (bw->word) + free(bw->word); + bw->word = NULL; + bw->in_use = 0; - return 1; + return 1; } int badwords_list(User * u, int index, ChannelInfo * ci, int *sent_header) { - BadWord *bw = &ci->badwords[index]; - - if (!bw->in_use) - return 0; - if (!*sent_header) { - notice_lang(s_BotServ, u, BOT_BADWORDS_LIST_HEADER, ci->name); - *sent_header = 1; - } - - notice_lang(s_BotServ, u, BOT_BADWORDS_LIST_FORMAT, index + 1, - bw->word, - ((bw->type == - BW_SINGLE) ? "(SINGLE)" : ((bw->type == - BW_START) ? "(START)" - : ((bw->type == - BW_END) ? "(END)" : ""))) - ); - return 1; + BadWord *bw = &ci->badwords[index]; + + if (!bw->in_use) + return 0; + if (!*sent_header) { + notice_lang(s_BotServ, u, BOT_BADWORDS_LIST_HEADER, ci->name); + *sent_header = 1; + } + + notice_lang(s_BotServ, u, BOT_BADWORDS_LIST_FORMAT, index + 1, + bw->word, + ((bw->type == + BW_SINGLE) ? "(SINGLE)" : ((bw->type == + BW_START) ? "(START)" + : ((bw->type == + BW_END) ? "(END)" : ""))) + ); + return 1; } int badwords_list_callback(User * u, int num, va_list args) { - ChannelInfo *ci = va_arg(args, ChannelInfo *); - int *sent_header = va_arg(args, int *); - if (num < 1 || num > ci->bwcount) - return 0; - return badwords_list(u, num - 1, ci, sent_header); + ChannelInfo *ci = va_arg(args, ChannelInfo *); + int *sent_header = va_arg(args, int *); + if (num < 1 || num > ci->bwcount) + return 0; + return badwords_list(u, num - 1, ci, sent_header); } MODULE_INIT("bs_badwords", BSBadwords) diff --git a/src/core/bs_bot.c b/src/core/bs_bot.c index 69f7e23a7..946dd2d96 100644 --- a/src/core/bs_bot.c +++ b/src/core/bs_bot.c @@ -43,9 +43,9 @@ class BSBot : public Module **/ void myBotServHelp(User * u) { - if (is_services_admin(u)) { - notice_lang(s_BotServ, u, BOT_HELP_CMD_BOT); - } + if (is_services_admin(u)) { + notice_lang(s_BotServ, u, BOT_HELP_CMD_BOT); + } } /** @@ -61,7 +61,7 @@ int do_bot(User * u) if (!cmd) { - syntax_error(s_BotServ, u, "BOT", BOT_BOT_SYNTAX); + syntax_error(s_BotServ, u, "BOT", BOT_BOT_SYNTAX); return MOD_CONT; } diff --git a/src/core/bs_botlist.c b/src/core/bs_botlist.c index 7173a7807..75cbe1a90 100644 --- a/src/core/bs_botlist.c +++ b/src/core/bs_botlist.c @@ -42,7 +42,7 @@ class BSBotList : public Module **/ void myBotServHelp(User * u) { - notice_lang(s_BotServ, u, BOT_HELP_CMD_BOTLIST); + notice_lang(s_BotServ, u, BOT_HELP_CMD_BOTLIST); } /** @@ -52,45 +52,45 @@ void myBotServHelp(User * u) **/ int do_botlist(User * u) { - int i, count = 0; - BotInfo *bi; + int i, count = 0; + BotInfo *bi; - if (!nbots) { - notice_lang(s_BotServ, u, BOT_BOTLIST_EMPTY); - return MOD_CONT; - } + if (!nbots) { + notice_lang(s_BotServ, u, BOT_BOTLIST_EMPTY); + return MOD_CONT; + } - for (i = 0; i < 256; i++) { - for (bi = botlists[i]; bi; bi = bi->next) { - if (!(bi->flags & BI_PRIVATE)) { - if (!count) - notice_lang(s_BotServ, u, BOT_BOTLIST_HEADER); - count++; - notice_user(s_BotServ, u, " %-15s (%s@%s)", bi->nick, - bi->user, bi->host); - } - } - } + for (i = 0; i < 256; i++) { + for (bi = botlists[i]; bi; bi = bi->next) { + if (!(bi->flags & BI_PRIVATE)) { + if (!count) + notice_lang(s_BotServ, u, BOT_BOTLIST_HEADER); + count++; + notice_user(s_BotServ, u, " %-15s (%s@%s)", bi->nick, + bi->user, bi->host); + } + } + } - if (is_oper(u) && count < nbots) { - notice_lang(s_BotServ, u, BOT_BOTLIST_PRIVATE_HEADER); + if (is_oper(u) && count < nbots) { + notice_lang(s_BotServ, u, BOT_BOTLIST_PRIVATE_HEADER); - for (i = 0; i < 256; i++) { - for (bi = botlists[i]; bi; bi = bi->next) { - if (bi->flags & BI_PRIVATE) { - notice_user(s_BotServ, u, " %-15s (%s@%s)", - bi->nick, bi->user, bi->host); - count++; - } - } - } - } + for (i = 0; i < 256; i++) { + for (bi = botlists[i]; bi; bi = bi->next) { + if (bi->flags & BI_PRIVATE) { + notice_user(s_BotServ, u, " %-15s (%s@%s)", + bi->nick, bi->user, bi->host); + count++; + } + } + } + } - if (!count) - notice_lang(s_BotServ, u, BOT_BOTLIST_EMPTY); - else - notice_lang(s_BotServ, u, BOT_BOTLIST_FOOTER, count); - return MOD_CONT; + if (!count) + notice_lang(s_BotServ, u, BOT_BOTLIST_EMPTY); + else + notice_lang(s_BotServ, u, BOT_BOTLIST_FOOTER, count); + return MOD_CONT; } MODULE_INIT("bs_botlist", BSBotList) diff --git a/src/core/bs_fantasy.c b/src/core/bs_fantasy.c index 20e7aaeb7..2885db065 100644 --- a/src/core/bs_fantasy.c +++ b/src/core/bs_fantasy.c @@ -48,40 +48,40 @@ void AnopeFini(void) **/ int do_fantasy(int argc, char **argv) { - User *u; - ChannelInfo *ci; - CSModeUtil *util = csmodeutils; - char *target; + User *u; + ChannelInfo *ci; + CSModeUtil *util = csmodeutils; + char *target; - if (argc < 3) - return MOD_CONT; + if (argc < 3) + return MOD_CONT; - do { - if (stricmp(argv[0], util->bsname) == 0) { - /* This could have been moved to its own module - however it would require more coding to handle the pass holders - similar to how PROTECT is done - */ - if (!ircd->halfop) { - if (!stricmp(argv[0], "halfop") || !stricmp(argv[0], "dehalfop")) { - return MOD_CONT; - } - } - u = finduser(argv[1]); - ci = cs_findchan(argv[2]); - if (!u || !ci) - return MOD_CONT; + do { + if (stricmp(argv[0], util->bsname) == 0) { + /* This could have been moved to its own module + however it would require more coding to handle the pass holders + similar to how PROTECT is done + */ + if (!ircd->halfop) { + if (!stricmp(argv[0], "halfop") || !stricmp(argv[0], "dehalfop")) { + return MOD_CONT; + } + } + u = finduser(argv[1]); + ci = cs_findchan(argv[2]); + if (!u || !ci) + return MOD_CONT; - target = ((argc == 4) ? argv[3] : NULL); + target = ((argc == 4) ? argv[3] : NULL); - if (!target && check_access(u, ci, util->levelself)) - bot_raw_mode(u, ci, util->mode, u->nick); - else if (target && check_access(u, ci, util->level)) - bot_raw_mode(u, ci, util->mode, target); - } - } while ((++util)->name != NULL); + if (!target && check_access(u, ci, util->levelself)) + bot_raw_mode(u, ci, util->mode, u->nick); + else if (target && check_access(u, ci, util->level)) + bot_raw_mode(u, ci, util->mode, target); + } + } while ((++util)->name != NULL); - return MOD_CONT; + return MOD_CONT; } MODULE_INIT("bs_fantasy", BSFantasy) diff --git a/src/core/bs_fantasy_kick.c b/src/core/bs_fantasy_kick.c index e1e92e161..f5c3018b6 100644 --- a/src/core/bs_fantasy_kick.c +++ b/src/core/bs_fantasy_kick.c @@ -41,47 +41,47 @@ class BSFantasyKick : public Module **/ int do_fantasy(int argc, char **argv) { - User *u, *u2; - ChannelInfo *ci; - char *target = NULL; - char *reason = NULL; + User *u, *u2; + ChannelInfo *ci; + char *target = NULL; + char *reason = NULL; - if (argc < 3) - return MOD_CONT; + if (argc < 3) + return MOD_CONT; - if ((stricmp(argv[0], "kick") == 0) || (stricmp(argv[0], "k") == 0)) { - u = finduser(argv[1]); - ci = cs_findchan(argv[2]); - if (!u || !ci) - return MOD_CONT; + if ((stricmp(argv[0], "kick") == 0) || (stricmp(argv[0], "k") == 0)) { + u = finduser(argv[1]); + ci = cs_findchan(argv[2]); + if (!u || !ci) + return MOD_CONT; - if (argc >= 4) { - target = myStrGetToken(argv[3], ' ', 0); - reason = myStrGetTokenRemainder(argv[3], ' ', 1); - } - if (!target && check_access(u, ci, CA_KICKME)) { - bot_raw_kick(u, ci, u->nick, "Requested"); - } else if (target && check_access(u, ci, CA_KICK)) { - if (!stricmp(target, ci->bi->nick)) - bot_raw_kick(u, ci, u->nick, "Oops!"); - else { - u2 = finduser(target); - if (u2 && ci->c && is_on_chan(ci->c, u2)) { - if (!reason && !is_protected(u2)) - bot_raw_kick(u, ci, target, "Requested"); - else if (!is_protected(u2)) - bot_raw_kick(u, ci, target, reason); - } - } - } - } + if (argc >= 4) { + target = myStrGetToken(argv[3], ' ', 0); + reason = myStrGetTokenRemainder(argv[3], ' ', 1); + } + if (!target && check_access(u, ci, CA_KICKME)) { + bot_raw_kick(u, ci, u->nick, "Requested"); + } else if (target && check_access(u, ci, CA_KICK)) { + if (!stricmp(target, ci->bi->nick)) + bot_raw_kick(u, ci, u->nick, "Oops!"); + else { + u2 = finduser(target); + if (u2 && ci->c && is_on_chan(ci->c, u2)) { + if (!reason && !is_protected(u2)) + bot_raw_kick(u, ci, target, "Requested"); + else if (!is_protected(u2)) + bot_raw_kick(u, ci, target, reason); + } + } + } + } - if (target) - free(target); - if (reason) - free(reason); + if (target) + free(target); + if (reason) + free(reason); - return MOD_CONT; + return MOD_CONT; } MODULE_INIT("bs_fantasy_kick", BSFantasyKick) diff --git a/src/core/bs_fantasy_kickban.c b/src/core/bs_fantasy_kickban.c index b0514ff84..1281d938b 100644 --- a/src/core/bs_fantasy_kickban.c +++ b/src/core/bs_fantasy_kickban.c @@ -42,48 +42,48 @@ class BSFantasyKickBan : public Module **/ int do_fantasy(int argc, char **argv) { - User *u, *u2; - ChannelInfo *ci; - char *target = NULL; - char *reason = NULL; + User *u, *u2; + ChannelInfo *ci; + char *target = NULL; + char *reason = NULL; - if (argc < 3) - return MOD_CONT; + if (argc < 3) + return MOD_CONT; - if ((stricmp(argv[0], "kickban") == 0) - || (stricmp(argv[0], "kb") == 0)) { - u = finduser(argv[1]); - ci = cs_findchan(argv[2]); - if (!u || !ci) - return MOD_CONT; + if ((stricmp(argv[0], "kickban") == 0) + || (stricmp(argv[0], "kb") == 0)) { + u = finduser(argv[1]); + ci = cs_findchan(argv[2]); + if (!u || !ci) + return MOD_CONT; - if (argc >= 4) { - target = myStrGetToken(argv[3], ' ', 0); - reason = myStrGetTokenRemainder(argv[3], ' ', 1); - } - if (!target && check_access(u, ci, CA_BANME)) { - bot_raw_ban(u, ci, u->nick, "Requested"); - } else if (target && check_access(u, ci, CA_BAN)) { - if (stricmp(target, ci->bi->nick) == 0) { - bot_raw_ban(u, ci, u->nick, "Oops!"); - } else { - u2 = finduser(target); - if (u2 && ci->c && is_on_chan(ci->c, u2)) { - if (!reason && !is_protected(u2)) - bot_raw_ban(u, ci, target, "Requested"); - else if (!is_protected(u2)) - bot_raw_ban(u, ci, target, reason); - } - } - } - } + if (argc >= 4) { + target = myStrGetToken(argv[3], ' ', 0); + reason = myStrGetTokenRemainder(argv[3], ' ', 1); + } + if (!target && check_access(u, ci, CA_BANME)) { + bot_raw_ban(u, ci, u->nick, "Requested"); + } else if (target && check_access(u, ci, CA_BAN)) { + if (stricmp(target, ci->bi->nick) == 0) { + bot_raw_ban(u, ci, u->nick, "Oops!"); + } else { + u2 = finduser(target); + if (u2 && ci->c && is_on_chan(ci->c, u2)) { + if (!reason && !is_protected(u2)) + bot_raw_ban(u, ci, target, "Requested"); + else if (!is_protected(u2)) + bot_raw_ban(u, ci, target, reason); + } + } + } + } - if (target) - free(target); - if (reason) - free(reason); + if (target) + free(target); + if (reason) + free(reason); - return MOD_CONT; + return MOD_CONT; } MODULE_INIT("bs_fantasy_kickban", BSFantasyKickBan) diff --git a/src/core/bs_fantasy_owner.c b/src/core/bs_fantasy_owner.c index 3501f6c08..b521baaa9 100644 --- a/src/core/bs_fantasy_owner.c +++ b/src/core/bs_fantasy_owner.c @@ -48,31 +48,31 @@ class BSFantasyOwner : public Module **/ int do_fantasy(int argc, char **argv) { - User *u; - ChannelInfo *ci; + User *u; + ChannelInfo *ci; - if (argc < 3) - return MOD_CONT; + if (argc < 3) + return MOD_CONT; - if (stricmp(argv[0], "deowner") == 0) { - u = finduser(argv[1]); - ci = cs_findchan(argv[2]); - if (!u || !ci) - return MOD_CONT; + if (stricmp(argv[0], "deowner") == 0) { + u = finduser(argv[1]); + ci = cs_findchan(argv[2]); + if (!u || !ci) + return MOD_CONT; - if (is_founder(u, ci)) - bot_raw_mode(u, ci, ircd->ownerunset, u->nick); - } else if (stricmp(argv[0], "owner") == 0) { - u = finduser(argv[1]); - ci = cs_findchan(argv[2]); - if (!u || !ci) - return MOD_CONT; + if (is_founder(u, ci)) + bot_raw_mode(u, ci, ircd->ownerunset, u->nick); + } else if (stricmp(argv[0], "owner") == 0) { + u = finduser(argv[1]); + ci = cs_findchan(argv[2]); + if (!u || !ci) + return MOD_CONT; - if (is_founder(u, ci)) - bot_raw_mode(u, ci, ircd->ownerset, u->nick); - } + if (is_founder(u, ci)) + bot_raw_mode(u, ci, ircd->ownerset, u->nick); + } - return MOD_CONT; + return MOD_CONT; } MODULE_INIT("bs_fantasy_owner", BSFantasyOwner) diff --git a/src/core/bs_fantasy_seen.c b/src/core/bs_fantasy_seen.c index 5173a7695..76e9a0273 100644 --- a/src/core/bs_fantasy_seen.c +++ b/src/core/bs_fantasy_seen.c @@ -49,88 +49,88 @@ void AnopeFini(void) **/ int do_fantasy(int argc, char **argv) { - User *u; - ChannelInfo *ci; - User *u2; - NickAlias *na; - ChanAccess *access; - char buf[BUFSIZE]; - char *target = NULL; + User *u; + ChannelInfo *ci; + User *u2; + NickAlias *na; + ChanAccess *access; + char buf[BUFSIZE]; + char *target = NULL; - if (argc < 4) - return MOD_CONT; + if (argc < 4) + return MOD_CONT; - if (stricmp(argv[0], "seen") == 0) { - u = finduser(argv[1]); - ci = cs_findchan(argv[2]); - if (!u || !ci) - return MOD_CONT; + if (stricmp(argv[0], "seen") == 0) { + u = finduser(argv[1]); + ci = cs_findchan(argv[2]); + if (!u || !ci) + return MOD_CONT; - target = myStrGetToken(argv[3], ' ', 0); + target = myStrGetToken(argv[3], ' ', 0); - if (stricmp(ci->bi->nick, target) == 0) { - /* If we look for the bot */ - snprintf(buf, sizeof(buf), getstring(u->na, BOT_SEEN_BOT), - u->nick); - ircdproto->SendPrivmsg(ci->bi, ci->name, "%s", buf); - } else if (!(na = findnick(target)) || (na->status & NS_VERBOTEN)) { - /* If the nick is not registered or forbidden */ - snprintf(buf, sizeof(buf), getstring(u->na, BOT_SEEN_UNKNOWN), - target); - ircdproto->SendPrivmsg(ci->bi, ci->name, "%s", buf); - } else if ((u2 = nc_on_chan(ci->c, na->nc))) { - /* If the nick we're looking for is on the channel, - * there are three possibilities: it's yourself, - * it's the nick we look for, it's an alias of the - * nick we look for. - */ - if (u == u2 || (u->na && u->na->nc == na->nc)) - snprintf(buf, sizeof(buf), getstring(u->na, BOT_SEEN_YOU), - u->nick); - else if (!stricmp(u2->nick, target)) - snprintf(buf, sizeof(buf), - getstring(u->na, BOT_SEEN_ON_CHANNEL), u2->nick); - else - snprintf(buf, sizeof(buf), - getstring(u->na, BOT_SEEN_ON_CHANNEL_AS), target, - u2->nick); + if (stricmp(ci->bi->nick, target) == 0) { + /* If we look for the bot */ + snprintf(buf, sizeof(buf), getstring(u->na, BOT_SEEN_BOT), + u->nick); + ircdproto->SendPrivmsg(ci->bi, ci->name, "%s", buf); + } else if (!(na = findnick(target)) || (na->status & NS_VERBOTEN)) { + /* If the nick is not registered or forbidden */ + snprintf(buf, sizeof(buf), getstring(u->na, BOT_SEEN_UNKNOWN), + target); + ircdproto->SendPrivmsg(ci->bi, ci->name, "%s", buf); + } else if ((u2 = nc_on_chan(ci->c, na->nc))) { + /* If the nick we're looking for is on the channel, + * there are three possibilities: it's yourself, + * it's the nick we look for, it's an alias of the + * nick we look for. + */ + if (u == u2 || (u->na && u->na->nc == na->nc)) + snprintf(buf, sizeof(buf), getstring(u->na, BOT_SEEN_YOU), + u->nick); + else if (!stricmp(u2->nick, target)) + snprintf(buf, sizeof(buf), + getstring(u->na, BOT_SEEN_ON_CHANNEL), u2->nick); + else + snprintf(buf, sizeof(buf), + getstring(u->na, BOT_SEEN_ON_CHANNEL_AS), target, + u2->nick); - ircdproto->SendPrivmsg(ci->bi, ci->name, "%s", buf); - } else if ((access = get_access_entry(na->nc, ci))) { - /* User is on the access list but not present actually. - Special case: if access->last_seen is 0 it's that we - never seen the user. - */ - if (access->last_seen) { - char durastr[192]; - duration(u->na, durastr, sizeof(durastr), - time(NULL) - access->last_seen); - snprintf(buf, sizeof(buf), getstring(u->na, BOT_SEEN_ON), - target, durastr); - } else { - snprintf(buf, sizeof(buf), - getstring(u->na, BOT_SEEN_NEVER), target); - } - ircdproto->SendPrivmsg(ci->bi, ci->name, "%s", buf); - } else if (na->nc == ci->founder) { - /* User is the founder of the channel */ - char durastr[192]; - duration(u->na, durastr, sizeof(durastr), - time(NULL) - na->last_seen); - snprintf(buf, sizeof(buf), getstring(u->na, BOT_SEEN_ON), - target, durastr); - ircdproto->SendPrivmsg(ci->bi, ci->name, "%s", buf); - } else { - /* All other cases */ - snprintf(buf, sizeof(buf), getstring(u->na, BOT_SEEN_UNKNOWN), - target); - ircdproto->SendPrivmsg(ci->bi, ci->name, "%s", buf); - } - /* free myStrGetToken(ed) variable target (#851) */ - Anope_Free(target); - } + ircdproto->SendPrivmsg(ci->bi, ci->name, "%s", buf); + } else if ((access = get_access_entry(na->nc, ci))) { + /* User is on the access list but not present actually. + Special case: if access->last_seen is 0 it's that we + never seen the user. + */ + if (access->last_seen) { + char durastr[192]; + duration(u->na, durastr, sizeof(durastr), + time(NULL) - access->last_seen); + snprintf(buf, sizeof(buf), getstring(u->na, BOT_SEEN_ON), + target, durastr); + } else { + snprintf(buf, sizeof(buf), + getstring(u->na, BOT_SEEN_NEVER), target); + } + ircdproto->SendPrivmsg(ci->bi, ci->name, "%s", buf); + } else if (na->nc == ci->founder) { + /* User is the founder of the channel */ + char durastr[192]; + duration(u->na, durastr, sizeof(durastr), + time(NULL) - na->last_seen); + snprintf(buf, sizeof(buf), getstring(u->na, BOT_SEEN_ON), + target, durastr); + ircdproto->SendPrivmsg(ci->bi, ci->name, "%s", buf); + } else { + /* All other cases */ + snprintf(buf, sizeof(buf), getstring(u->na, BOT_SEEN_UNKNOWN), + target); + ircdproto->SendPrivmsg(ci->bi, ci->name, "%s", buf); + } + /* free myStrGetToken(ed) variable target (#851) */ + Anope_Free(target); + } - return MOD_CONT; + return MOD_CONT; } MODULE_INIT("bs_fantasy_seen", BSFantasySeen) diff --git a/src/core/bs_help.c b/src/core/bs_help.c index 3c807275c..d838f9d85 100644 --- a/src/core/bs_help.c +++ b/src/core/bs_help.c @@ -40,16 +40,16 @@ class BSHelp : public Module **/ int do_help(User * u) { - char *cmd = strtok(NULL, ""); - - if (!cmd) { - notice_help(s_BotServ, u, BOT_HELP); - moduleDisplayHelp(4, u); - notice_help(s_BotServ, u, BOT_HELP_FOOTER, BSMinUsers); - } else { - mod_help_cmd(s_BotServ, u, BOTSERV, cmd); - } - return MOD_CONT; + char *cmd = strtok(NULL, ""); + + if (!cmd) { + notice_help(s_BotServ, u, BOT_HELP); + moduleDisplayHelp(4, u); + notice_help(s_BotServ, u, BOT_HELP_FOOTER, BSMinUsers); + } else { + mod_help_cmd(s_BotServ, u, BOTSERV, cmd); + } + return MOD_CONT; } MODULE_INIT("bs_help", BSHelp) diff --git a/src/core/bs_info.c b/src/core/bs_info.c index ce802db3c..d3590f624 100644 --- a/src/core/bs_info.c +++ b/src/core/bs_info.c @@ -43,7 +43,7 @@ class BSInfo : public Module **/ void myBotServHelp(User * u) { - notice_lang(s_BotServ, u, BOT_HELP_CMD_INFO); + notice_lang(s_BotServ, u, BOT_HELP_CMD_INFO); } /** @@ -53,217 +53,217 @@ void myBotServHelp(User * u) **/ int do_info(User * u) { - BotInfo *bi; - ChannelInfo *ci; - char *query = strtok(NULL, " "); + BotInfo *bi; + ChannelInfo *ci; + char *query = strtok(NULL, " "); - int need_comma = 0, is_servadmin = is_services_admin(u); - char buf[BUFSIZE], *end; - const char *commastr = getstring(u->na, COMMA_SPACE); + int need_comma = 0, is_servadmin = is_services_admin(u); + char buf[BUFSIZE], *end; + const char *commastr = getstring(u->na, COMMA_SPACE); - if (!query) - syntax_error(s_BotServ, u, "INFO", BOT_INFO_SYNTAX); - else if ((bi = findbot(query))) { - struct tm *tm; + if (!query) + syntax_error(s_BotServ, u, "INFO", BOT_INFO_SYNTAX); + else if ((bi = findbot(query))) { + struct tm *tm; - notice_lang(s_BotServ, u, BOT_INFO_BOT_HEADER, bi->nick); - notice_lang(s_BotServ, u, BOT_INFO_BOT_MASK, bi->user, bi->host); - notice_lang(s_BotServ, u, BOT_INFO_BOT_REALNAME, bi->real); - tm = localtime(&bi->created); - strftime_lang(buf, sizeof(buf), u, STRFTIME_DATE_TIME_FORMAT, tm); - notice_lang(s_BotServ, u, BOT_INFO_BOT_CREATED, buf); - notice_lang(s_BotServ, u, BOT_INFO_BOT_OPTIONS, - getstring(u->na, - (bi-> - flags & BI_PRIVATE) ? BOT_INFO_OPT_PRIVATE : - BOT_INFO_OPT_NONE)); - notice_lang(s_BotServ, u, BOT_INFO_BOT_USAGE, bi->chancount); + notice_lang(s_BotServ, u, BOT_INFO_BOT_HEADER, bi->nick); + notice_lang(s_BotServ, u, BOT_INFO_BOT_MASK, bi->user, bi->host); + notice_lang(s_BotServ, u, BOT_INFO_BOT_REALNAME, bi->real); + tm = localtime(&bi->created); + strftime_lang(buf, sizeof(buf), u, STRFTIME_DATE_TIME_FORMAT, tm); + notice_lang(s_BotServ, u, BOT_INFO_BOT_CREATED, buf); + notice_lang(s_BotServ, u, BOT_INFO_BOT_OPTIONS, + getstring(u->na, + (bi-> + flags & BI_PRIVATE) ? BOT_INFO_OPT_PRIVATE : + BOT_INFO_OPT_NONE)); + notice_lang(s_BotServ, u, BOT_INFO_BOT_USAGE, bi->chancount); - if (is_services_admin(u)) - send_bot_channels(u, bi); - } else if ((ci = cs_findchan(query))) { - if (!is_servadmin && !is_founder(u, ci)) { - notice_lang(s_BotServ, u, PERMISSION_DENIED); - return MOD_CONT; - } - if (ci->flags & CI_VERBOTEN) { - notice_lang(s_BotServ, u, CHAN_X_FORBIDDEN, query); - return MOD_CONT; - } + if (is_services_admin(u)) + send_bot_channels(u, bi); + } else if ((ci = cs_findchan(query))) { + if (!is_servadmin && !is_founder(u, ci)) { + notice_lang(s_BotServ, u, PERMISSION_DENIED); + return MOD_CONT; + } + if (ci->flags & CI_VERBOTEN) { + notice_lang(s_BotServ, u, CHAN_X_FORBIDDEN, query); + return MOD_CONT; + } - notice_lang(s_BotServ, u, BOT_INFO_CHAN_HEADER, ci->name); - if (ci->bi) - notice_lang(s_BotServ, u, BOT_INFO_CHAN_BOT, ci->bi->nick); - else - notice_lang(s_BotServ, u, BOT_INFO_CHAN_BOT_NONE); + notice_lang(s_BotServ, u, BOT_INFO_CHAN_HEADER, ci->name); + if (ci->bi) + notice_lang(s_BotServ, u, BOT_INFO_CHAN_BOT, ci->bi->nick); + else + notice_lang(s_BotServ, u, BOT_INFO_CHAN_BOT_NONE); - if (ci->botflags & BS_KICK_BADWORDS) { - if (ci->ttb[TTB_BADWORDS]) - notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_BADWORDS_BAN, - getstring(u->na, BOT_INFO_ACTIVE), - ci->ttb[TTB_BADWORDS]); - else - notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_BADWORDS, - getstring(u->na, BOT_INFO_ACTIVE)); - } else - notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_BADWORDS, - getstring(u->na, BOT_INFO_INACTIVE)); - if (ci->botflags & BS_KICK_BOLDS) { - if (ci->ttb[TTB_BOLDS]) - notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_BOLDS_BAN, - getstring(u->na, BOT_INFO_ACTIVE), - ci->ttb[TTB_BOLDS]); - else - notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_BOLDS, - getstring(u->na, BOT_INFO_ACTIVE)); - } else - notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_BOLDS, - getstring(u->na, BOT_INFO_INACTIVE)); - if (ci->botflags & BS_KICK_CAPS) { - if (ci->ttb[TTB_CAPS]) - notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_CAPS_BAN, - getstring(u->na, BOT_INFO_ACTIVE), - ci->ttb[TTB_CAPS], ci->capsmin, - ci->capspercent); - else - notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_CAPS_ON, - getstring(u->na, BOT_INFO_ACTIVE), ci->capsmin, - ci->capspercent); - } else - notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_CAPS_OFF, - getstring(u->na, BOT_INFO_INACTIVE)); - if (ci->botflags & BS_KICK_COLORS) { - if (ci->ttb[TTB_COLORS]) - notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_COLORS_BAN, - getstring(u->na, BOT_INFO_ACTIVE), - ci->ttb[TTB_COLORS]); - else - notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_COLORS, - getstring(u->na, BOT_INFO_ACTIVE)); - } else - notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_COLORS, - getstring(u->na, BOT_INFO_INACTIVE)); - if (ci->botflags & BS_KICK_FLOOD) { - if (ci->ttb[TTB_FLOOD]) - notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_FLOOD_BAN, - getstring(u->na, BOT_INFO_ACTIVE), - ci->ttb[TTB_FLOOD], ci->floodlines, - ci->floodsecs); - else - notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_FLOOD_ON, - getstring(u->na, BOT_INFO_ACTIVE), - ci->floodlines, ci->floodsecs); - } else - notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_FLOOD_OFF, - getstring(u->na, BOT_INFO_INACTIVE)); - if (ci->botflags & BS_KICK_REPEAT) { - if (ci->ttb[TTB_REPEAT]) - notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_REPEAT_BAN, - getstring(u->na, BOT_INFO_ACTIVE), - ci->ttb[TTB_REPEAT], ci->repeattimes); - else - notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_REPEAT_ON, - getstring(u->na, BOT_INFO_ACTIVE), - ci->repeattimes); - } else - notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_REPEAT_OFF, - getstring(u->na, BOT_INFO_INACTIVE)); - if (ci->botflags & BS_KICK_REVERSES) { - if (ci->ttb[TTB_REVERSES]) - notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_REVERSES_BAN, - getstring(u->na, BOT_INFO_ACTIVE), - ci->ttb[TTB_REVERSES]); - else - notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_REVERSES, - getstring(u->na, BOT_INFO_ACTIVE)); - } else - notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_REVERSES, - getstring(u->na, BOT_INFO_INACTIVE)); - if (ci->botflags & BS_KICK_UNDERLINES) { - if (ci->ttb[TTB_UNDERLINES]) - notice_lang(s_BotServ, u, - BOT_INFO_CHAN_KICK_UNDERLINES_BAN, - getstring(u->na, BOT_INFO_ACTIVE), - ci->ttb[TTB_UNDERLINES]); - else - notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_UNDERLINES, - getstring(u->na, BOT_INFO_ACTIVE)); - } else - notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_UNDERLINES, - getstring(u->na, BOT_INFO_INACTIVE)); + if (ci->botflags & BS_KICK_BADWORDS) { + if (ci->ttb[TTB_BADWORDS]) + notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_BADWORDS_BAN, + getstring(u->na, BOT_INFO_ACTIVE), + ci->ttb[TTB_BADWORDS]); + else + notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_BADWORDS, + getstring(u->na, BOT_INFO_ACTIVE)); + } else + notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_BADWORDS, + getstring(u->na, BOT_INFO_INACTIVE)); + if (ci->botflags & BS_KICK_BOLDS) { + if (ci->ttb[TTB_BOLDS]) + notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_BOLDS_BAN, + getstring(u->na, BOT_INFO_ACTIVE), + ci->ttb[TTB_BOLDS]); + else + notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_BOLDS, + getstring(u->na, BOT_INFO_ACTIVE)); + } else + notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_BOLDS, + getstring(u->na, BOT_INFO_INACTIVE)); + if (ci->botflags & BS_KICK_CAPS) { + if (ci->ttb[TTB_CAPS]) + notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_CAPS_BAN, + getstring(u->na, BOT_INFO_ACTIVE), + ci->ttb[TTB_CAPS], ci->capsmin, + ci->capspercent); + else + notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_CAPS_ON, + getstring(u->na, BOT_INFO_ACTIVE), ci->capsmin, + ci->capspercent); + } else + notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_CAPS_OFF, + getstring(u->na, BOT_INFO_INACTIVE)); + if (ci->botflags & BS_KICK_COLORS) { + if (ci->ttb[TTB_COLORS]) + notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_COLORS_BAN, + getstring(u->na, BOT_INFO_ACTIVE), + ci->ttb[TTB_COLORS]); + else + notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_COLORS, + getstring(u->na, BOT_INFO_ACTIVE)); + } else + notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_COLORS, + getstring(u->na, BOT_INFO_INACTIVE)); + if (ci->botflags & BS_KICK_FLOOD) { + if (ci->ttb[TTB_FLOOD]) + notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_FLOOD_BAN, + getstring(u->na, BOT_INFO_ACTIVE), + ci->ttb[TTB_FLOOD], ci->floodlines, + ci->floodsecs); + else + notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_FLOOD_ON, + getstring(u->na, BOT_INFO_ACTIVE), + ci->floodlines, ci->floodsecs); + } else + notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_FLOOD_OFF, + getstring(u->na, BOT_INFO_INACTIVE)); + if (ci->botflags & BS_KICK_REPEAT) { + if (ci->ttb[TTB_REPEAT]) + notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_REPEAT_BAN, + getstring(u->na, BOT_INFO_ACTIVE), + ci->ttb[TTB_REPEAT], ci->repeattimes); + else + notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_REPEAT_ON, + getstring(u->na, BOT_INFO_ACTIVE), + ci->repeattimes); + } else + notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_REPEAT_OFF, + getstring(u->na, BOT_INFO_INACTIVE)); + if (ci->botflags & BS_KICK_REVERSES) { + if (ci->ttb[TTB_REVERSES]) + notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_REVERSES_BAN, + getstring(u->na, BOT_INFO_ACTIVE), + ci->ttb[TTB_REVERSES]); + else + notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_REVERSES, + getstring(u->na, BOT_INFO_ACTIVE)); + } else + notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_REVERSES, + getstring(u->na, BOT_INFO_INACTIVE)); + if (ci->botflags & BS_KICK_UNDERLINES) { + if (ci->ttb[TTB_UNDERLINES]) + notice_lang(s_BotServ, u, + BOT_INFO_CHAN_KICK_UNDERLINES_BAN, + getstring(u->na, BOT_INFO_ACTIVE), + ci->ttb[TTB_UNDERLINES]); + else + notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_UNDERLINES, + getstring(u->na, BOT_INFO_ACTIVE)); + } else + notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_UNDERLINES, + getstring(u->na, BOT_INFO_INACTIVE)); - end = buf; - *end = 0; - if (ci->botflags & BS_DONTKICKOPS) { - end += snprintf(end, sizeof(buf) - (end - buf), "%s", - getstring(u->na, BOT_INFO_OPT_DONTKICKOPS)); - need_comma = 1; - } - if (ci->botflags & BS_DONTKICKVOICES) { - end += snprintf(end, sizeof(buf) - (end - buf), "%s%s", - need_comma ? commastr : "", - getstring(u->na, BOT_INFO_OPT_DONTKICKVOICES)); - need_comma = 1; - } - if (ci->botflags & BS_FANTASY) { - end += snprintf(end, sizeof(buf) - (end - buf), "%s%s", - need_comma ? commastr : "", - getstring(u->na, BOT_INFO_OPT_FANTASY)); - need_comma = 1; - } - if (ci->botflags & BS_GREET) { - end += snprintf(end, sizeof(buf) - (end - buf), "%s%s", - need_comma ? commastr : "", - getstring(u->na, BOT_INFO_OPT_GREET)); - need_comma = 1; - } - if (ci->botflags & BS_NOBOT) { - end += snprintf(end, sizeof(buf) - (end - buf), "%s%s", - need_comma ? commastr : "", - getstring(u->na, BOT_INFO_OPT_NOBOT)); - need_comma = 1; - } - if (ci->botflags & BS_SYMBIOSIS) { - end += snprintf(end, sizeof(buf) - (end - buf), "%s%s", - need_comma ? commastr : "", - getstring(u->na, BOT_INFO_OPT_SYMBIOSIS)); - need_comma = 1; - } - notice_lang(s_BotServ, u, BOT_INFO_CHAN_OPTIONS, - *buf ? buf : getstring(u->na, BOT_INFO_OPT_NONE)); + end = buf; + *end = 0; + if (ci->botflags & BS_DONTKICKOPS) { + end += snprintf(end, sizeof(buf) - (end - buf), "%s", + getstring(u->na, BOT_INFO_OPT_DONTKICKOPS)); + need_comma = 1; + } + if (ci->botflags & BS_DONTKICKVOICES) { + end += snprintf(end, sizeof(buf) - (end - buf), "%s%s", + need_comma ? commastr : "", + getstring(u->na, BOT_INFO_OPT_DONTKICKVOICES)); + need_comma = 1; + } + if (ci->botflags & BS_FANTASY) { + end += snprintf(end, sizeof(buf) - (end - buf), "%s%s", + need_comma ? commastr : "", + getstring(u->na, BOT_INFO_OPT_FANTASY)); + need_comma = 1; + } + if (ci->botflags & BS_GREET) { + end += snprintf(end, sizeof(buf) - (end - buf), "%s%s", + need_comma ? commastr : "", + getstring(u->na, BOT_INFO_OPT_GREET)); + need_comma = 1; + } + if (ci->botflags & BS_NOBOT) { + end += snprintf(end, sizeof(buf) - (end - buf), "%s%s", + need_comma ? commastr : "", + getstring(u->na, BOT_INFO_OPT_NOBOT)); + need_comma = 1; + } + if (ci->botflags & BS_SYMBIOSIS) { + end += snprintf(end, sizeof(buf) - (end - buf), "%s%s", + need_comma ? commastr : "", + getstring(u->na, BOT_INFO_OPT_SYMBIOSIS)); + need_comma = 1; + } + notice_lang(s_BotServ, u, BOT_INFO_CHAN_OPTIONS, + *buf ? buf : getstring(u->na, BOT_INFO_OPT_NONE)); - } else - notice_lang(s_BotServ, u, BOT_INFO_NOT_FOUND, query); - return MOD_CONT; + } else + notice_lang(s_BotServ, u, BOT_INFO_NOT_FOUND, query); + return MOD_CONT; } void send_bot_channels(User * u, BotInfo * bi) { - int i; - ChannelInfo *ci; - char buf[307], *end; + int i; + ChannelInfo *ci; + char buf[307], *end; - *buf = 0; - end = buf; + *buf = 0; + end = buf; - for (i = 0; i < 256; i++) { - for (ci = chanlists[i]; ci; ci = ci->next) { - if (ci->bi == bi) { - if (strlen(buf) + strlen(ci->name) > 300) { - notice_user(s_BotServ, u, "%s", buf); - *buf = 0; - end = buf; - } - end += - snprintf(end, sizeof(buf) - (end - buf), " %s ", - ci->name); - } - } - } + for (i = 0; i < 256; i++) { + for (ci = chanlists[i]; ci; ci = ci->next) { + if (ci->bi == bi) { + if (strlen(buf) + strlen(ci->name) > 300) { + notice_user(s_BotServ, u, "%s", buf); + *buf = 0; + end = buf; + } + end += + snprintf(end, sizeof(buf) - (end - buf), " %s ", + ci->name); + } + } + } - if (*buf) - notice_user(s_BotServ, u, "%s", buf); - return; + if (*buf) + notice_user(s_BotServ, u, "%s", buf); + return; } MODULE_INIT("bs_info", BSInfo) diff --git a/src/core/bs_kick.c b/src/core/bs_kick.c index fb48c9413..229b4dba2 100644 --- a/src/core/bs_kick.c +++ b/src/core/bs_kick.c @@ -59,7 +59,7 @@ class BSKick : public Module **/ void myBotServHelp(User * u) { - notice_lang(s_BotServ, u, BOT_HELP_CMD_KICK); + notice_lang(s_BotServ, u, BOT_HELP_CMD_KICK); } /** @@ -69,290 +69,290 @@ void myBotServHelp(User * u) **/ int do_kickcmd(User * u) { - char *chan = strtok(NULL, " "); - char *option = strtok(NULL, " "); - char *value = strtok(NULL, " "); - char *ttb = strtok(NULL, " "); + char *chan = strtok(NULL, " "); + char *option = strtok(NULL, " "); + char *value = strtok(NULL, " "); + char *ttb = strtok(NULL, " "); - ChannelInfo *ci; + ChannelInfo *ci; - if (readonly) - notice_lang(s_BotServ, u, BOT_KICK_DISABLED); - else if (!chan || !option || !value) - syntax_error(s_BotServ, u, "KICK", BOT_KICK_SYNTAX); - else if (stricmp(value, "ON") && stricmp(value, "OFF")) - syntax_error(s_BotServ, u, "KI