abstract class PrivateParlorXT::CommandHandler

Overview

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.

Direct Known Subclasses

Defined in:

private-parlor-xt/handlers/command_handler.cr

Instance Method Summary

Instance methods inherited from class PrivateParlorXT::Handler

do(message : Tourmaline::Message, services : Services) : Nil do, reply_message(user : User, message : Tourmaline::Message, services : Services) : Tourmaline::Message | Nil reply_message, reply_user(user : User, reply_message : Tourmaline::Message, services : Services) : User | Nil reply_user, unique?(user : User, message : Tourmaline::Message, services : Services, text : String | Nil = nil) : Bool unique?, update_user_activity(user : User, services : Services) : Nil update_user_activity

Constructor methods inherited from class PrivateParlorXT::Handler

new(config : Config) new

Instance Method Detail

def 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


[View source]
def 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


[View source]
def 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


[View source]
def deny_user(user : User, services : Services) : Nil #

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


[View source]
def 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


[View source]
def 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


[View source]