diff options
author | Adam <Adam@anope.org> | 2010-11-24 21:40:56 -0600 |
---|---|---|
committer | Adam <Adam@anope.org> | 2010-12-12 19:36:19 -0500 |
commit | cb6ef574e3df5cc846247450b74ca37d265f319e (patch) | |
tree | 8ce3374a537c312af63c78125bfea4622bb188f0 /modules/core/ms_read.cpp | |
parent | 37e02a3594fdddc3d5a3df0501c528f42db6c4da (diff) |
Send replies from fantasy commands back to the channel, this will be expanded on later
Diffstat (limited to 'modules/core/ms_read.cpp')
-rw-r--r-- | modules/core/ms_read.cpp | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/modules/core/ms_read.cpp b/modules/core/ms_read.cpp index 2f743cb30..785755fec 100644 --- a/modules/core/ms_read.cpp +++ b/modules/core/ms_read.cpp @@ -15,10 +15,10 @@ class MemoListCallback : public NumberList { - User *u; + CommandSource &source; MemoInfo *mi; public: - MemoListCallback(User *_u, MemoInfo *_mi, const Anope::string &numlist) : NumberList(numlist, false), u(_u), mi(_mi) + MemoListCallback(CommandSource &_source, MemoInfo *_mi, const Anope::string &numlist) : NumberList(numlist, false), source(_source), mi(_mi) { } @@ -27,11 +27,12 @@ class MemoListCallback : public NumberList if (!Number || Number > mi->memos.size()) return; - MemoListCallback::DoRead(u, mi, NULL, Number - 1); + MemoListCallback::DoRead(source, mi, NULL, Number - 1); } - static void DoRead(User *u, MemoInfo *mi, ChannelInfo *ci, unsigned index) + static void DoRead(CommandSource &source, MemoInfo *mi, ChannelInfo *ci, unsigned index) { + User *u = source.u; Memo *m = mi->memos[index]; if (ci) u->SendMessage(MemoServ, MEMO_CHAN_HEADER, index + 1, m->sender.c_str(), do_strftime(m->time).c_str(), Config->s_MemoServ.c_str(), ci->name.c_str(), index + 1); @@ -53,8 +54,10 @@ class CommandMSRead : public Command { } - CommandReturn Execute(User *u, const std::vector<Anope::string> ¶ms) + CommandReturn Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) { + User *u = source.u; + MemoInfo *mi; ChannelInfo *ci = NULL; Anope::string numstr = !params.empty() ? params[0] : "", chan; @@ -67,12 +70,12 @@ class CommandMSRead : public Command if (!(ci = cs_findchan(chan))) { - u->SendMessage(MemoServ, CHAN_X_NOT_REGISTERED, chan.c_str()); + source.Reply(CHAN_X_NOT_REGISTERED, chan.c_str()); return MOD_CONT; } else if (!check_access(u, ci, CA_MEMO)) { - u->SendMessage(MemoServ, ACCESS_DENIED); + source.Reply(ACCESS_DENIED); return MOD_CONT; } mi = &ci->memos; @@ -85,9 +88,9 @@ class CommandMSRead : public Command else if (mi->memos.empty()) { if (!chan.empty()) - u->SendMessage(MemoServ, MEMO_X_HAS_NO_MEMOS, chan.c_str()); + source.Reply(MEMO_X_HAS_NO_MEMOS, chan.c_str()); else - u->SendMessage(MemoServ, MEMO_HAVE_NO_MEMOS); + source.Reply(MEMO_HAVE_NO_MEMOS); } else { int i, end; @@ -98,25 +101,25 @@ class CommandMSRead : public Command for (i = 0, end = mi->memos.size(); i < end; ++i) if (mi->memos[i]->HasFlag(MF_UNREAD)) { - MemoListCallback::DoRead(u, mi, ci, i); + MemoListCallback::DoRead(source, mi, ci, i); ++readcount; } if (!readcount) { if (!chan.empty()) - u->SendMessage(MemoServ, MEMO_X_HAS_NO_NEW_MEMOS, chan.c_str()); + source.Reply(MEMO_X_HAS_NO_NEW_MEMOS, chan.c_str()); else - u->SendMessage(MemoServ, MEMO_HAVE_NO_NEW_MEMOS); + source.Reply(MEMO_HAVE_NO_NEW_MEMOS); } } else if (numstr.equals_ci("LAST")) { for (i = 0, end = mi->memos.size() - 1; i < end; ++i); - MemoListCallback::DoRead(u, mi, ci, i); + MemoListCallback::DoRead(source, mi, ci, i); } else /* number[s] */ { - MemoListCallback list(u, mi, numstr); + MemoListCallback list(source, mi, numstr); list.Process(); } } |