X-Git-Url: https://jfr.im/git/irc/evilnet/x3.git/blobdiff_plain/eb43ca8c26a2dcc64b1c3a82c30d2c4cbf01226c..4a2a9a4e6a8fccd440da203bdfb8bba3f0b973a9:/src/mod-memoserv.c diff --git a/src/mod-memoserv.c b/src/mod-memoserv.c index a9a1447..4c9011f 100644 --- a/src/mod-memoserv.c +++ b/src/mod-memoserv.c @@ -42,6 +42,7 @@ #include "conf.h" #include "modcmd.h" #include "nickserv.h" +#include "opserv.h" #include "saxdb.h" #include "timeq.h" @@ -108,6 +109,8 @@ static const struct message_entry msgtab[] = { { "MSMSG_LIST_END", "--------------End of Memos--------------" }, { "MSMSG_BAR", "----------------------------------------"}, + { "MSMSG_DEFCON_NO_NEW_MEMOS", "You cannot send new memos at this time, please try again soon." }, + { NULL, NULL } }; @@ -128,6 +131,15 @@ struct history { unsigned long id; }; +struct userNode *memoserv; + +#define MEMOSERV_FUNC(NAME) MODCMD_FUNC(NAME) +#define MEMOSERV_SYNTAX() svccmd_send_help_brief(user, memoserv, cmd) +#define MEMOSERV_MIN_PARAMS(N) if(argc < (N)) { \ + reply("MSG_MISSING_PARAMS", argv[0]); \ + MEMOSERV_SYNTAX(); \ + return 0; } + DECLARE_LIST(memoList, struct memo*); DEFINE_LIST(memoList, struct memo*); DECLARE_LIST(historyList, struct history*); @@ -390,6 +402,13 @@ static MODCMD_FUNC(cmd_send) struct memo_account *ma, *sender; struct memo *memo; + MEMOSERV_MIN_PARAMS(3); + + if (checkDefCon(DEFCON_NO_NEW_MEMOS) && !IsOper(user)) { + reply("MSMSG_DEFCON_NO_NEW_MEMOS"); + return 0; + } + if (!(hi = modcmd_get_handle_info(user, argv[1]))) return 0; @@ -528,7 +547,7 @@ static MODCMD_FUNC(cmd_read) if (!(memo = find_memo(user, cmd, ma, argv[1], &memoid))) return 0; - if (argv[2]) { + if (argc > 2) { char *argtwo = argv[2]; while (*argtwo) { switch (*argtwo) { @@ -600,6 +619,8 @@ static MODCMD_FUNC(cmd_delete) struct memo *memo; unsigned int memoid; + MEMOSERV_MIN_PARAMS(2); + if (!(ma = memoserv_get_account(user->handle_info))) return 0; if (!irccasecmp(argv[1], "*") || !irccasecmp(argv[1], "all")) { @@ -628,6 +649,8 @@ static MODCMD_FUNC(cmd_cancel) struct memo *memo; struct memo_account *ma; + MEMOSERV_MIN_PARAMS(2); + if (isdigit(argv[1][0])) { id = strtoul(argv[1], NULL, 0); } else { @@ -727,8 +750,7 @@ static MODCMD_FUNC(cmd_oset) struct handle_info *hi; option_func_t *opt; - if (argc < 2) - return 0; + MEMOSERV_MIN_PARAMS(2); if (!(hi = get_victim_oper(cmd, user, argv[1]))) return 0; @@ -1218,8 +1240,8 @@ memoserv_check_messages(struct userNode *user, UNUSED_ARG(struct handle_info *ol if (!memo->is_read) unseen++; } - if (ma->recvd.used && memoserv_conf.bot) - if(unseen) send_message(user, memoserv_conf.bot, "MSMSG_MEMOS_INBOX", unseen, ma->recvd.used - unseen); + if (ma->recvd.used && memoserv) + if(unseen) send_message(user, memoserv, "MSMSG_MEMOS_INBOX", unseen, ma->recvd.used - unseen); } } @@ -1300,15 +1322,17 @@ memoserv_finalize(void) { } str = database_get_data(conf_node, "bot", RECDB_QSTRING); - if (str) - memoserv_conf.bot = GetUserH(str); - else + if (str) { + memoserv = memoserv_conf.bot; + } else { log_module(MS_LOG, LOG_ERROR, "database_get_data for memoserv_conf.bot failed!"); + exit(1); + } - if (autojoin_channels && memoserv_conf.bot) { + if (autojoin_channels && memoserv) { for (i = 0; i < autojoin_channels->used; i++) { chan = AddChannel(autojoin_channels->list[i], now, "+nt", NULL, NULL); - AddChannelUser(memoserv_conf.bot, chan)->modes |= MODE_CHANOP; + AddChannelUser(memoserv, chan)->modes |= MODE_CHANOP; } }