diff options
author | Adam <Adam@anope.org> | 2011-04-22 03:16:11 -0400 |
---|---|---|
committer | Adam <Adam@anope.org> | 2011-05-16 04:06:17 -0400 |
commit | c8c23158a4ff74822d6c7d201dc53d879e3d91e8 (patch) | |
tree | 4bc9ae029691d5e7c03ebc1481683a010b733844 /modules/core/ms_read.cpp | |
parent | 1782ce260c5bc214ec0b2e39257ab1371b68ae9c (diff) |
Moved the core pseudo clients out into their own modules
Diffstat (limited to 'modules/core/ms_read.cpp')
-rw-r--r-- | modules/core/ms_read.cpp | 42 |
1 files changed, 40 insertions, 2 deletions
diff --git a/modules/core/ms_read.cpp b/modules/core/ms_read.cpp index 632bfd056..4b6e03aed 100644 --- a/modules/core/ms_read.cpp +++ b/modules/core/ms_read.cpp @@ -12,6 +12,41 @@ /*************************************************************************/ #include "module.h" +#include "memoserv.h" + +void rsend_notify(CommandSource &source, MemoInfo *mi, Memo *m, const Anope::string &targ) +{ + /* Only send receipt if memos are allowed */ + if (memoserv && !readonly) + { + /* Get nick alias for sender */ + NickAlias *na = findnick(m->sender); + + if (!na) + return; + + /* Get nick core for sender */ + NickCore *nc = na->nc; + + if (!nc) + return; + + /* Text of the memo varies if the recepient was a + nick or channel */ + Anope::string text = Anope::printf(GetString(na->nc, _("\002[auto-memo]\002 The memo you sent to %s has been viewed.")).c_str(), targ.c_str()); + + /* Send notification */ + memoserv->Send(source.u->nick, m->sender, text, true); + + /* Notify recepient of the memo that a notification has + been sent to the sender */ + source.Reply(_("A notification memo has been sent to %s informing him/her you have\n" + "read his/her memo."), nc->display.c_str()); + } + + /* Remove receipt flag from the original memo */ + m->UnsetFlag(MF_RECEIPT); +} class MemoListCallback : public NumberList { @@ -42,7 +77,7 @@ class MemoListCallback : public NumberList /* Check if a receipt notification was requested */ if (m->HasFlag(MF_RECEIPT)) - rsend_notify(source, m, ci ? ci->name : ""); + rsend_notify(source, mi, m, ci ? ci->name : source.u->nick); } }; @@ -157,7 +192,10 @@ class MSRead : public Module this->SetAuthor("Anope"); this->SetType(CORE); - this->AddCommand(MemoServ, &commandmsread); + if (!memoserv) + throw ModuleException("MemoServ is not loaded!"); + + this->AddCommand(memoserv->Bot(), &commandmsread); } }; |