static void DoRead(CommandSource &source, MemoServ::MemoInfo *mi, ChanServ::Channel *ci, unsigned index) { MemoServ::Memo *m = mi->GetMemo(index); if (!m) return; if (ci) source.Reply(_("Memo \002{0}\002 from \002{1}\002 (\002{2}\002)."), index + 1, m->GetSender(), Anope::strftime(m->GetTime(), source.GetAccount())); else source.Reply(_("Memo \002{0}\002 from \002{1}\002 (\002{2}\002)."), index + 1, m->GetSender(), Anope::strftime(m->GetTime(), source.GetAccount())); ServiceBot *bi; Anope::string cmd; if (Command::FindCommandFromService("memoserv/del", bi, cmd)) { if (ci) source.Reply(_("To delete, use \002{0}{1} {2} {3} {4}\002"), Config->StrictPrivmsg, bi->nick, cmd, ci->GetName(), index + 1); else source.Reply(_("To delete, use \002{0}{1} {2} {3}\002"), Config->StrictPrivmsg, bi->nick, cmd, index + 1); } source.Reply(m->GetText()); m->SetUnread(false); /* Check if a receipt notification was requested */ if (m->GetReceipt()) rsend_notify(source, mi, m, ci ? ci->GetName() : source.GetNick()); }
MemoResult Send(const Anope::string &source, const Anope::string &target, const Anope::string &message, bool force) override { bool ischan, isregistered; MemoServ::MemoInfo *mi = GetMemoInfo(target, ischan, isregistered, true); if (mi == NULL) return MEMO_INVALID_TARGET; User *sender = User::Find(source); if (sender != NULL && !sender->HasPriv("memoserv/no-limit") && !force) { time_t send_delay = Config->GetModule("memoserv")->Get<time_t>("senddelay"); if (send_delay > 0 && sender->lastmemosend + send_delay > Anope::CurTime) return MEMO_TOO_FAST; else if (!mi->GetMemoMax()) return MEMO_TARGET_FULL; else if (mi->GetMemoMax() > 0 && mi->GetMemos().size() >= static_cast<unsigned>(mi->GetMemoMax())) return MEMO_TARGET_FULL; else if (mi->HasIgnore(sender)) return MEMO_SUCCESS; } if (sender != NULL) sender->lastmemosend = Anope::CurTime; MemoServ::Memo *m = Serialize::New<MemoServ::Memo *>(); m->SetMemoInfo(mi); m->SetSender(source); m->SetTime(Anope::CurTime); m->SetText(message); m->SetUnread(true); EventManager::Get()->Dispatch(&MemoServ::Event::MemoSend::OnMemoSend, source, target, mi, m); if (ischan) { ChanServ::Channel *ci = ChanServ::Find(target); if (ci->c) { for (Channel::ChanUserList::iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end; ++it) { ChanUserContainer *cu = it->second; if (ci->AccessFor(cu->user).HasPriv("MEMO")) { if (cu->user->Account() && cu->user->Account()->HasFieldS("MEMO_RECEIVE")) cu->user->SendMessage(*MemoServ, _("There is a new memo on channel \002{0}\002. Type \002{1}{2} READ {3} {4}\002 to read it."), ci->GetName(), Config->StrictPrivmsg, MemoServ->nick, ci->GetName(), mi->GetMemos().size()); // XXX } } } } else { NickServ::Account *nc = NickServ::FindNick(target)->GetAccount(); if (nc->HasFieldS("MEMO_RECEIVE")) for (User *u : nc->users) u->SendMessage(*MemoServ, _("You have a new memo from \002{0}\002. Type \002{1}{2} READ {3}\002 to read it."), source, Config->StrictPrivmsg, MemoServ->nick, mi->GetMemos().size());//XXX /* let's get out the mail if set in the nickcore - certus */ if (nc->HasFieldS("MEMO_MAIL")) SendMemoMail(nc, mi, m); } return MEMO_SUCCESS; }