summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorSadie Powell <sadie@witchery.services>2024-03-14 21:18:08 +0000
committerSadie Powell <sadie@witchery.services>2024-03-14 21:35:17 +0000
commitbeaf09de7bcb0042dfd8f388064126e511a5b28d (patch)
treeba14e1ff1ff96b5623c459b2de35d766d086e427 /include
parentc8d8978cd0bfb10613da331c5b13bbcf8486f85f (diff)
Rework sending global notices.
Admins can now queue multiple messages and send them when they are ready. This is fully compatible with the previous global behaviour. Admins can now also send messages to individual servers. This is useful for informing users of maintenance due to downtime.
Diffstat (limited to 'include')
-rw-r--r--include/language.h1
-rw-r--r--include/modules/pseudoclients/global.h61
2 files changed, 55 insertions, 7 deletions
diff --git a/include/language.h b/include/language.h
index 405102c1d..657f3669c 100644
--- a/include/language.h
+++ b/include/language.h
@@ -66,6 +66,7 @@ namespace Language
/* Commonly used language strings */
#define CONFIRM_DROP _("Please confirm that you want to drop \002%s\002 with \002%s%s DROP %s %s\002")
+#define SERVICE_UNAVAILABLE _("Sorry, %s is temporarily unavailable.")
#define MORE_INFO _("\002%s%s HELP %s\002 for more information.")
#define BAD_USERHOST_MASK _("Mask must be in the form \037user\037@\037host\037.")
#define BAD_EXPIRY_TIME _("Invalid expiry time.")
diff --git a/include/modules/pseudoclients/global.h b/include/modules/pseudoclients/global.h
index 73283605d..4b5dd0eb4 100644
--- a/include/modules/pseudoclients/global.h
+++ b/include/modules/pseudoclients/global.h
@@ -8,21 +8,68 @@
#pragma once
+#define GLOBAL_NO_MESSAGE _("You do not have any messages queued and did not specify a message to send.")
+#define GLOBAL_QUEUE_CONFLICT _("You can not send a single message while you have messages queued.")
+
class GlobalService
: public Service
{
public:
- GlobalService(Module *m) : Service(m, "GlobalService", "Global")
+ GlobalService(Module *m)
+ : Service(m, "GlobalService", "Global")
{
}
/** Retrieves the bot which sends global messages unless otherwise specified. */
- virtual Reference<BotInfo> GetDefaultSender() = 0;
+ virtual Reference<BotInfo> GetDefaultSender() const = 0;
+
+ /** Clears any queued messages for the specified account.
+ * @param nc The account to clear queued messages for.
+ */
+ virtual void ClearQueue(NickCore *nc) = 0;
+
+ /** Retrieves the size of the messages queue for the specified user.
+ * @param nc The account to count queued messages for.
+ */
+ inline size_t CountQueue(NickCore* nc) const
+ {
+ auto *q = GetQueue(nc);
+ return q ? q->size() : 0;
+ }
+
+ /** Retrieves the messages queue for the specified user.
+ * @param nc The account to retrieve queued messages for.
+ */
+ virtual const std::vector<Anope::string> *GetQueue(NickCore* nc) const = 0;
+
+ /** Queues a message to be sent later.
+ * @param nc The account to queue the message for.
+ * @param message The message to queue.
+ * @return The new number of messages in the queue.
+ */
+ virtual size_t Queue(NickCore *nc, const Anope::string &message) = 0;
+
+ /** Sends a single message to all users on the network.
+ * @param message The message to send.
+ * @param source If non-nullptr then the source of the message.
+ * @param sender If non-nullptr then the bot to send the message from.
+ * @param server If non-nullptr then the server to send messages to.
+ * @return If the message was sent then true; otherwise, false.
+ */
+ virtual bool SendSingle(const Anope::string &message, CommandSource *source = nullptr, BotInfo *sender = nullptr, Server *server = nullptr) = 0;
+
+ /** Sends a message queue to all users on the network.
+ * @param source The source of the message.
+ * @param sender If non-nullptr then the bot to send the message from.
+ * @param server If non-nullptr then the server to send messages to.
+ * @return If the message queue was sent then true; otherwise, false.
+ */
+ virtual bool SendQueue(CommandSource &source, BotInfo *sender = nullptr, Server *server = nullptr) = 0;
- /** Send out a global message to all users
- * @param sender Our client which should send the global
- * @param source The sender of the global
- * @param message The message
+ /** Unqueues a message from the message queue.
+ * @param nc The account to unqueue the message from.
+ * @param idx The index of the item to remove.
+ * @return Whether the message was removed from the queue.
*/
- virtual void SendGlobal(BotInfo *sender, const Anope::string &source, const Anope::string &message) = 0;
+ virtual bool Unqueue(NickCore *nc, size_t idx) = 0;
};