summaryrefslogtreecommitdiff
path: root/modules/commands/ms_list.cpp
diff options
context:
space:
mode:
authorSadie Powell <sadie@witchery.services>2024-01-24 12:34:03 +0000
committerSadie Powell <sadie@witchery.services>2024-01-24 12:34:34 +0000
commit484160eb4ed560eeda97c94a42dd8e31431ab251 (patch)
tree03600af16b55fa2f268904d7a42a8b87f86c09f4 /modules/commands/ms_list.cpp
parent7ac1fe58478d58e2480b6919c4abf3a82929169c (diff)
Shuffle modules around a bit.
Diffstat (limited to 'modules/commands/ms_list.cpp')
-rw-r--r--modules/commands/ms_list.cpp167
1 files changed, 0 insertions, 167 deletions
diff --git a/modules/commands/ms_list.cpp b/modules/commands/ms_list.cpp
deleted file mode 100644
index 127cfdaaf..000000000
--- a/modules/commands/ms_list.cpp
+++ /dev/null
@@ -1,167 +0,0 @@
-/* MemoServ core functions
- *
- * (C) 2003-2024 Anope Team
- * Contact us at team@anope.org
- *
- * Please read COPYING and README for further details.
- *
- * Based on the original code of Epona by Lara.
- * Based on the original code of Services by Andy Church.
- */
-
-#include "module.h"
-
-class CommandMSList final
- : public Command
-{
-public:
- CommandMSList(Module *creator) : Command(creator, "memoserv/list", 0, 2)
- {
- this->SetDesc(_("List your memos"));
- this->SetSyntax(_("[\037channel\037] [\037list\037 | NEW]"));
- }
-
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
- {
-
- Anope::string param = !params.empty() ? params[0] : "", chan;
- ChannelInfo *ci = NULL;
- const MemoInfo *mi;
-
- if (!param.empty() && param[0] == '#')
- {
- chan = param;
- param = params.size() > 1 ? params[1] : "";
-
- ci = ChannelInfo::Find(chan);
- if (!ci)
- {
- source.Reply(CHAN_X_NOT_REGISTERED, chan.c_str());
- return;
- }
- else if (!source.AccessFor(ci).HasPriv("MEMO"))
- {
- source.Reply(ACCESS_DENIED);
- return;
- }
- mi = &ci->memos;
- }
- else
- mi = &source.nc->memos;
-
- if (!param.empty() && !isdigit(param[0]) && !param.equals_ci("NEW"))
- this->OnSyntaxError(source, param);
- else if (!mi->memos->size())
- {
- if (!chan.empty())
- source.Reply(MEMO_X_HAS_NO_MEMOS, chan.c_str());
- else
- source.Reply(MEMO_HAVE_NO_MEMOS);
- }
- else
- {
- ListFormatter list(source.GetAccount());
-
- list.AddColumn(_("Number")).AddColumn(_("Sender")).AddColumn(_("Date/Time"));
-
- if (!param.empty() && isdigit(param[0]))
- {
- class MemoListCallback final
- : public NumberList
- {
- ListFormatter &list;
- CommandSource &source;
- const MemoInfo *mi;
- public:
- MemoListCallback(ListFormatter &_list, CommandSource &_source, const MemoInfo *_mi, const Anope::string &numlist) : NumberList(numlist, false), list(_list), source(_source), mi(_mi)
- {
- }
-
- void HandleNumber(unsigned number) override
- {
- if (!number || number > mi->memos->size())
- return;
-
- const Memo *m = mi->GetMemo(number - 1);
-
- ListFormatter::ListEntry entry;
- entry["Number"] = (m->unread ? "* " : " ") + stringify(number);
- entry["Sender"] = m->sender;
- entry["Date/Time"] = Anope::strftime(m->time, source.GetAccount());
- this->list.AddEntry(entry);
- }
- }
- mlc(list, source, mi, param);
- mlc.Process();
- }
- else
- {
- if (!param.empty())
- {
- unsigned i, end;
- for (i = 0, end = mi->memos->size(); i < end; ++i)
- if (mi->GetMemo(i)->unread)
- break;
- if (i == end)
- {
- if (!chan.empty())
- source.Reply(MEMO_X_HAS_NO_NEW_MEMOS, chan.c_str());
- else
- source.Reply(MEMO_HAVE_NO_NEW_MEMOS);
- return;
- }
- }
-
- for (unsigned i = 0, end = mi->memos->size(); i < end; ++i)
- {
- if (!param.empty() && !mi->GetMemo(i)->unread)
- continue;
-
- const Memo *m = mi->GetMemo(i);
-
- ListFormatter::ListEntry entry;
- entry["Number"] = (m->unread ? "* " : " ") + stringify(i + 1);
- entry["Sender"] = m->sender;
- entry["Date/Time"] = Anope::strftime(m->time, source.GetAccount());
- list.AddEntry(entry);
- }
- }
-
- std::vector<Anope::string> replies;
- list.Process(replies);
-
- source.Reply(_("Memos for %s:"), ci ? ci->name.c_str() : source.GetNick().c_str());
- for (const auto &reply : replies)
- source.Reply(reply);
- }
- return;
- }
-
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
- {
- this->SendSyntax(source);
- source.Reply(" ");
- source.Reply(_("Lists any memos you currently have. With \002NEW\002, lists only\n"
- "new (unread) memos. Unread memos are marked with a \"*\"\n"
- "to the left of the memo number. You can also specify a list\n"
- "of numbers, as in the example below:\n"
- " \002LIST 2-5,7-9\002\n"
- " Lists memos numbered 2 through 5 and 7 through 9."));
- return true;
- }
-};
-
-class MSList final
- : public Module
-{
- CommandMSList commandmslist;
-
-public:
- MSList(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR),
- commandmslist(this)
- {
-
- }
-};
-
-MODULE_INIT(MSList)