mirror of
https://github.com/anope/anope.git
synced 2026-06-25 12:16:39 +02:00
Fix os_news to not load items until the news service is constructed
Fix session exceptions not expirigin
This commit is contained in:
@@ -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<Anope::string> servicekeys = Service::GetServiceKeys("Command");
|
||||
for (unsigned i = 0; i < servicekeys.size(); ++i)
|
||||
|
||||
@@ -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<NewsItem *> &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<unsigned>("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<const Anope::string>("oper_announcer", "OperServ");
|
||||
announcer = conf->GetModule(this)->Get<const Anope::string>("announcer", "Global");
|
||||
news_count = conf->GetModule(this)->Get<unsigned>("newscount", "3");
|
||||
}
|
||||
|
||||
void OnUserModeSet(const MessageSource &setter, User *u, const Anope::string &mname) anope_override
|
||||
{
|
||||
if (mname == "OPER")
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user