From b12669487f40b7ba93c96fddd5088c041750d1af Mon Sep 17 00:00:00 2001 From: Adam Date: Sat, 30 Jan 2016 16:53:07 -0500 Subject: Allow /ms read to get a comma separated list of memo numbers as help describes. Show message if no memos could be displayed. --- modules/commands/ms_read.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'modules/commands/ms_read.cpp') 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()) { -- cgit