summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2016-01-30 16:53:07 -0500
committerAdam <Adam@anope.org>2016-01-30 16:54:20 -0500
commitb12669487f40b7ba93c96fddd5088c041750d1af (patch)
treea71c88cc7b10478be28613b42d6884b19f720923
parent0e9a1e87d0231cb3c0ebace983fc4593d0112919 (diff)
Allow /ms read to get a comma separated list of memo numbers as help describes. Show message if no memos could be displayed.
-rw-r--r--modules/commands/ms_read.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/modules/commands/ms_read.cpp b/modules/commands/ms_read.cpp
index 5462b3d76..96103d30b 100644
--- a/modules/commands/ms_read.cpp
+++ b/modules/commands/ms_read.cpp
@@ -52,9 +52,17 @@ class MemoListCallback : public NumberList
CommandSource &source;
MemoInfo *mi;
const ChannelInfo *ci;
+ bool found;
public:
MemoListCallback(CommandSource &_source, MemoInfo *_mi, const ChannelInfo *_ci, const Anope::string &numlist) : NumberList(numlist, false), source(_source), mi(_mi), ci(_ci)
{
+ found = false;
+ }
+
+ ~MemoListCallback()
+ {
+ if (!found)
+ source.Reply(_("No memos to display."));
}
void HandleNumber(unsigned number) anope_override
@@ -63,6 +71,7 @@ class MemoListCallback : public NumberList
return;
MemoListCallback::DoRead(source, mi, ci, number - 1);
+ found = true;
}
static void DoRead(CommandSource &source, MemoInfo *mi, const ChannelInfo *ci, unsigned index)
@@ -70,7 +79,7 @@ class MemoListCallback : public NumberList
Memo *m = mi->GetMemo(index);
if (!m)
return;
-
+
if (ci)
source.Reply(_("Memo %d from %s (%s)."), index + 1, m->sender.c_str(), Anope::strftime(m->time, source.GetAccount()).c_str());
else
@@ -132,7 +141,7 @@ class CommandMSRead : public Command
else
mi = &source.nc->memos;
- if (numstr.empty() || (!numstr.equals_ci("LAST") && !numstr.equals_ci("NEW") && !numstr.is_number_only()))
+ if (numstr.empty() || (!numstr.equals_ci("LAST") && !numstr.equals_ci("NEW") && numstr.find_first_not_of("0123456789.,-") != Anope::string::npos))
this->OnSyntaxError(source, numstr);
else if (mi->memos->empty())
{