1
0
mirror of https://github.com/anope/anope.git synced 2026-06-12 15:44:46 +02:00
Files
anope/include/modules/global/service.h
T
2026-01-01 18:07:12 +00:00

91 lines
3.2 KiB
C++

// Anope IRC Services <https://www.anope.org/>
//
// Copyright (C) 2003-2026 Anope Contributors
//
// Anope is free software. You can use, modify, and/or distribute it under the
// terms of version 2 of the GNU General Public License. See docs/LICENSE.txt
// for the complete terms of this license and docs/AUTHORS.txt for a list of
// contributors.
//
// Based on the original code of Epona by Lara
// Based on the original code of Services by Andy Church
//
// SPDX-License-Identifier: GPL-2.0-only
#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.")
#define GLOBAL_SERVICE "Global::Service"
namespace Global
{
class Service;
ServiceReference<Global::Service> service(GLOBAL_SERVICE, GLOBAL_SERVICE);
}
class Global::Service
: public ::Service
{
public:
Service(Module *m)
: ::Service(m, GLOBAL_SERVICE, GLOBAL_SERVICE)
{
}
/** Retrieves the bot which sends global messages unless otherwise specified. */
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;
/** 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 bool Unqueue(NickCore *nc, size_t idx) = 0;
};