summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data/operserv.example.conf7
-rw-r--r--language/anope.en_US.po16
-rw-r--r--modules/operserv/os_news.cpp30
3 files changed, 41 insertions, 12 deletions
diff --git a/data/operserv.example.conf b/data/operserv.example.conf
index f5dc935a6..2b35bf574 100644
--- a/data/operserv.example.conf
+++ b/data/operserv.example.conf
@@ -502,6 +502,13 @@ module
* This directive is optional, if not set it will default to 3.
*/
#newscount = 3
+
+ /*
+ * Whether to show the datetime at which the news entry was added.
+ *
+ * This directive is optional, if not set it will default to yes.
+ */
+ #showdate = yes
}
command { service = "OperServ"; name = "LOGONNEWS"; command = "operserv/logonnews"; permission = "operserv/news"; }
command { service = "OperServ"; name = "OPERNEWS"; command = "operserv/opernews"; permission = "operserv/news"; }
diff --git a/language/anope.en_US.po b/language/anope.en_US.po
index dfd101bb0..5dfbb990a 100644
--- a/language/anope.en_US.po
+++ b/language/anope.en_US.po
@@ -7,8 +7,8 @@ msgid ""
msgstr ""
"Project-Id-Version: Anope\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2025-04-23 01:56+0100\n"
-"PO-Revision-Date: 2025-04-23 01:56+0100\n"
+"POT-Creation-Date: 2025-04-25 13:08+0100\n"
+"PO-Revision-Date: 2025-04-25 13:08+0100\n"
"Last-Translator: Sadie Powell <sadie@witchery.services>\n"
"Language-Team: English\n"
"Language: en_US\n"
@@ -6293,13 +6293,25 @@ msgid "[Logon News - %s] %s"
msgstr ""
#, c-format
+msgid "[Logon News] %s"
+msgstr ""
+
+#, c-format
msgid "[Oper News - %s] %s"
msgstr ""
#, c-format
+msgid "[Oper News] %s"
+msgstr ""
+
+#, c-format
msgid "[Random News - %s] %s"
msgstr ""
+#, c-format
+msgid "[Random News] %s"
+msgstr ""
+
msgid "[account] password"
msgstr ""
diff --git a/modules/operserv/os_news.cpp b/modules/operserv/os_news.cpp
index 37eeef1c1..dc8ac32c7 100644
--- a/modules/operserv/os_news.cpp
+++ b/modules/operserv/os_news.cpp
@@ -22,6 +22,8 @@
enum
{
MSG_SYNTAX,
+ MSG_NEWS_SHORT,
+ MSG_NEWS_LONG,
MSG_LIST_HEADER,
MSG_LIST_NONE,
MSG_ADDED,
@@ -34,6 +36,8 @@ enum
struct NewsMessages msgarray[] = {
{NEWS_LOGON, "LOGON",
{_("LOGONNEWS {ADD|DEL|LIST} [\037text\037|\037num\037]\002"),
+ _("[\002Logon News\002] %s"),
+ _("[\002Logon News\002 - %s] %s"),
_("Logon news items:"),
_("There is no logon news."),
_("Added new logon news item."),
@@ -44,6 +48,8 @@ struct NewsMessages msgarray[] = {
},
{NEWS_OPER, "OPER",
{_("OPERNEWS {ADD|DEL|LIST} [\037text\037|\037num\037]\002"),
+ _("[\002Oper News\002] %s"),
+ _("[\002Oper News\002 - %s] %s"),
_("Oper news items:"),
_("There is no oper news."),
_("Added new oper news item."),
@@ -54,6 +60,8 @@ struct NewsMessages msgarray[] = {
},
{NEWS_RANDOM, "RANDOM",
{_("RANDOMNEWS {ADD|DEL|LIST} [\037text\037|\037num\037]\002"),
+ _("[\002Random News\002] %s"),
+ _("[\002Random News\002 - %s] %s"),
_("Random news items:"),
_("There is no random news."),
_("Added new random news item."),
@@ -409,21 +417,18 @@ class OSNews final
if (newsList.empty())
return;
+ const auto &modconf = Config->GetModule(this);
BotInfo *bi = NULL;
if (Type == NEWS_OPER)
- bi = BotInfo::Find(Config->GetModule(this).Get<const Anope::string>("oper_announcer", "OperServ"), true);
+ bi = BotInfo::Find(modconf.Get<const Anope::string>("oper_announcer", "OperServ"), true);
else
- bi = BotInfo::Find(Config->GetModule(this).Get<const Anope::string>("announcer", "Global"), true);
+ bi = BotInfo::Find(modconf.Get<const Anope::string>("announcer", "Global"), true);
if (bi == NULL)
return;
- Anope::string msg;
- if (Type == NEWS_LOGON)
- msg = _("[\002Logon News\002 - %s] %s");
- else if (Type == NEWS_OPER)
- msg = _("[\002Oper News\002 - %s] %s");
- else if (Type == NEWS_RANDOM)
- msg = _("[\002Random News\002 - %s] %s");
+ const auto **msgs = findmsgs(Type);
+ if (!msgs)
+ return; // BUG
int start = 0;
@@ -434,12 +439,17 @@ class OSNews final
start = 0;
}
+ const auto showdate = modconf.Get<bool>("showdate", "yes");
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());
+ const auto *news = newsList[i];
+ if (showdate)
+ u->SendMessage(bi, msgs[MSG_NEWS_LONG], Anope::strftime(news->time, u->Account(), true).c_str(), news->text.c_str());
+ else
+ u->SendMessage(bi, msgs[MSG_NEWS_SHORT], news->text.c_str());
if (Type == NEWS_RANDOM)
{