From abc7e4b423d6701e5771ff08b3eadf81f50488ec Mon Sep 17 00:00:00 2001 From: Adam Date: Thu, 12 Sep 2013 08:07:11 -0400 Subject: [PATCH] Fix os_news to not load items until the news service is constructed Fix session exceptions not expirigin --- modules/commands/os_modinfo.cpp | 2 ++ modules/commands/os_news.cpp | 19 +++++++++++++++---- modules/commands/os_session.cpp | 2 +- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/modules/commands/os_modinfo.cpp b/modules/commands/os_modinfo.cpp index 3563185ae..972f8631e 100644 --- a/modules/commands/os_modinfo.cpp +++ b/modules/commands/os_modinfo.cpp @@ -30,6 +30,8 @@ class CommandOSModInfo : public Command if (m) { source.Reply(_("Module: \002%s\002 Version: \002%s\002 Author: \002%s\002 loaded: \002%s\002"), m->name.c_str(), !m->version.empty() ? m->version.c_str() : "?", !m->author.empty() ? m->author.c_str() : "Unknown", Anope::strftime(m->created).c_str()); + if (Anope::Debug) + source.Reply(_(" Loaded at: %p"), m->handle); std::vector servicekeys = Service::GetServiceKeys("Command"); for (unsigned i = 0; i < servicekeys.size(); ++i) diff --git a/modules/commands/os_news.cpp b/modules/commands/os_news.cpp index 487a45300..c71d7ed27 100644 --- a/modules/commands/os_news.cpp +++ b/modules/commands/os_news.cpp @@ -329,13 +329,16 @@ static unsigned cur_rand_news = 0; class OSNews : public Module { - Serialize::Type newsitem_type; MyNewsService newsservice; + Serialize::Type newsitem_type; CommandOSLogonNews commandoslogonnews; CommandOSOperNews commandosopernews; CommandOSRandomNews commandosrandomnews; + Anope::string oper_announcer, announcer; + unsigned news_count; + void DisplayNews(User *u, NewsType Type) { std::vector &newsList = this->newsservice.GetNewsList(Type); @@ -358,13 +361,13 @@ class OSNews : public Module else if (Type == NEWS_RANDOM) msg = _("[\002Random News\002 - %s] %s"); - unsigned displayed = 0, news_count = Config->GetModule(this)->Get("newscount", "3"); + unsigned displayed = 0; for (unsigned i = 0, end = newsList.size(); i < end; ++i) { if (Type == NEWS_RANDOM && i != cur_rand_news) continue; - u->SendMessage(bi, msg.c_str(), Anope::strftime(newsList[i]->time).c_str(), newsList[i]->text.c_str()); + u->SendMessage(bi, msg.c_str(), Anope::strftime(newsList[i]->time, u->Account(), true).c_str(), newsList[i]->text.c_str()); ++displayed; @@ -384,10 +387,18 @@ class OSNews : public Module public: OSNews(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - newsitem_type("NewsItem", NewsItem::Unserialize), newsservice(this), commandoslogonnews(this), commandosopernews(this), commandosrandomnews(this) + newsservice(this), newsitem_type("NewsItem", NewsItem::Unserialize), + commandoslogonnews(this), commandosopernews(this), commandosrandomnews(this) { } + void OnReload(Configuration::Conf *conf) anope_override + { + oper_announcer = conf->GetModule(this)->Get("oper_announcer", "OperServ"); + announcer = conf->GetModule(this)->Get("announcer", "Global"); + news_count = conf->GetModule(this)->Get("newscount", "3"); + } + void OnUserModeSet(const MessageSource &setter, User *u, const Anope::string &mname) anope_override { if (mname == "OPER") diff --git a/modules/commands/os_session.cpp b/modules/commands/os_session.cpp index 7b0ee1fb1..d04085347 100644 --- a/modules/commands/os_session.cpp +++ b/modules/commands/os_session.cpp @@ -742,7 +742,7 @@ class OSSession : public Module void OnExpireTick() anope_override { - if (!Anope::NoExpire) + if (Anope::NoExpire) return; for (unsigned i = this->ss.GetExceptions().size(); i > 0; --i) {