class PrivateParlorXT::Relay

Overview

Handles the MessageQueue and sends prepared messages to Telegram

Defined in:

private-parlor-xt/relay/relay.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(log_channel : String, client : Tourmaline::Client) #

[View source]

Instance Method Detail

def cache_message(success : Tourmaline::Message | Array(Tourmaline::Message), message : QueuedMessage, services : Services) : Nil #

Caches data from the message returned from Telegram in the message History


[View source]
def delete_message(receiver : UserID, message : MessageID) : Nil #

Delete a message for receiver


[View source]
def edit_message_media(user : UserID, media : Tourmaline::InputMedia, message : MessageID) : Nil #

Edit a message's media, usually used for placing a spoiler on a message


[View source]
def edit_message_text(user : UserID, text : String, markup : Tourmaline::InlineKeyboardMarkup | Nil, message : MessageID) : Nil #

Exit a message's text


[View source]
def get_chat(user : UserID) : Tourmaline::ChatFullInfo | Nil #

Returns the full chat information for the given user


[View source]
def log_output(text : String) : Nil #

Prints text to the log and send it to the log_channel if it is set


[View source]
def pin_message(user : UserID, message : MessageID) : Nil #

Pins the given message to the chat


[View source]
def purge_messages(receiver : UserID, messages : Array(MessageID)) : Nil #

Bulk dellete messages for a given receiver


[View source]
def reject_blacklisted_messages(user : UserID) : Nil #

Remove messages from the queue that are sent by or addressed to user


[View source]
def reject_inactive_user_messages(user : UserID) : Nil #

Remove messages from the queue that are addressed to user


[View source]
def relay_message(message : QueuedMessage, services : Services) : Tourmaline::Message | Array(Tourmaline::Message) | Nil #

Calls the proc associated with the given message.

Returns a Tourmaline::Message when sending messages that are not albums Returns an array of Tourmaline::Message for sent albums Returns nil on sending a system message, Telegram giving us a boolean, or encountering an error


[View source]
def send_album(params : AlbumHelpers::AlbumRelayParameters) : Nil #

Queues an album with the given params


[View source]
def send_animation(params : RelayParameters) : Nil #

Queues a GIF with the given params


[View source]
def send_audio(params : RelayParameters) : Nil #

Queues an audio message with the given params


[View source]
def send_contact(params : RelayParameters, contact : Tourmaline::Contact) : Nil #

Queues a Tourmaline::Contact with the given params


[View source]
def send_document(params : RelayParameters) : Nil #

Queues a document with the given params


[View source]
def send_forward(params : RelayParameters, message : MessageID) : Nil #

Queues a forwarded message with the given params


[View source]
def send_location(params : RelayParameters, location : Tourmaline::Location) : Nil #

Queues a Tourmaline::Location with the given params


[View source]
def send_message(services : Services) : Bool | Nil #

Takes a message from the queue and sends it.

Returns true if queue is empty


[View source]
def send_photo(params : RelayParameters) : Nil #

Queues a photo with the given params


[View source]
def send_poll_copy(reply : MessageID, user : User, effect : String | Nil, poll : Tourmaline::Poll) : Tourmaline::Message #

Sends a Tourmaline::Poll with the given parameters found in poll


[View source]
def send_sticker(params : RelayParameters) : Nil #

Queues a sticker with the given params


[View source]
def send_text(params : RelayParameters) : Nil #

Queues a text message with the given params


[View source]
def send_to_channel(reply_message : MessageID | Nil, channel : String, text : String) : Nil #

Relay a message to the log channel.


[View source]
def send_to_user(reply_message : ReplyParameters | Nil, user : UserID, text : String, reply_markup : Tourmaline::InlineKeyboardMarkup | Nil = nil) : Nil #

Relay a message to a single user. Used for system messages.


[View source]
def send_venue(params : RelayParameters, venue : Tourmaline::Venue) : Nil #

Queues a Tourmaline::Venue with the given params


[View source]
def send_video(params : RelayParameters) : Nil #

Queues a video with the given params


[View source]
def send_video_note(params : RelayParameters) : Nil #

Queues a video note with the given params


[View source]
def send_voice(params : RelayParameters) : Nil #

Queues a voice message with the given params


[View source]
def set_log_channel(channel_id : String) : Nil #

Set the log chanel ID to channel_id


[View source]
def start_polling #

Start polling Telegram for updates


[View source]
def stop_polling #

Stop polling Telegram for updates


[View source]
def unpin_message(user : UserID, message : MessageID | Nil = nil) : Nil #

Unpins the most recent message from the chat, or unpins the given message


[View source]