1
0
mirror of https://github.com/anope/anope.git synced 2026-07-05 14:03:13 +02:00

Fix logonnews to prioritize the newest entries if it can't show them all

This commit is contained in:
Adam
2015-11-04 20:03:26 -05:00
parent 27a2645ed3
commit 80c332bc41
+10 -6
View File
@@ -403,23 +403,27 @@ class OSNews : public Module
else if (Type == NEWS_RANDOM)
msg = _("[\002Random News\002 - %s] %s");
unsigned displayed = 0;
for (unsigned i = 0, end = newsList.size(); i < end; ++i)
int start = 0;
if (type != NEWS_RANDOM)
{
start = newsList.size() - news_count;
if (start < 0)
start = 0;
}
for (unsigned i = start, 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, u->Account(), true).c_str(), newsList[i]->text.c_str());
++displayed;
if (Type == NEWS_RANDOM)
{
++cur_rand_news;
break;
}
else if (displayed >= news_count)
break;
}
/* Reset to head of list to get first random news value */