class

PrivateParlorXT::CommandHandler

Inherits PrivateParlorXT::Handler < Reference < Object

A base class for handling a Telegram command

Handlers that are meant to respond to commands (messages that start with '/') should inherit this class, and include a RespondsTo annotation to have it be usable by the bot.

Instance methods

authorized?(user : User, message : Tourmaline::Message, permission : CommandPermissions, services : Services) : Bool

Checks if the user's Rank contain the given CommandPermissions

Returns true if it does, false otherwise

Source
authorized?(user : User, message : Tourmaline::Message, services : Services, *permissions : CommandPermissions) : CommandPermissions | Nil

Checks if the user's Rank contains any of the given CommandPermissions

If it does, it returns the one CommandPermissions Returns nil otherwise

Source
delete_messages(message : MessageID, user : UserID, debug_enabled : Bool | Nil, services : Services) : MessageID | Nil

Deletes the message group associated with the given message ID in the chat and from the History

Returns the original MessageID of the associated message group

Source
deny_user(user : User, services : Services) : Nil

Queues a system reply when the user is blacklisted and cannot use a command

Source
remove_command_entity(text : String, entities : Array(Tourmaline::MessageEntity), arg : String) : Array(Tourmaline::MessageEntity)

Removes the bot command message entity from entities and subtracts the index of the arg start from the offset of each message entity in entities

Returns an array of updated Tourmaline::MessageEntity

Source
user_from_message(message : Tourmaline::Message, services : Services) : User | Nil

Gets the User with updated names from the given message and returns it if the message is a command, the user exists, and the user is not blacklisted

Source