class PrivateParlor
- PrivateParlor
- Tourmaline::Client
- Reference
- Object
Included Modules
- Tourmaline
Defined in:
privateparlor/telegram.crConstructors
-
.new(config : Config)
Creates a new instance of
PrivateParlor
.
Instance Method Summary
- #access : AuthorizedRanks
- #albums : Hash(String, Album)
- #allow_media_spoilers : Bool | Nil
-
#blacklist_command(ctx : CommandHandler::Context) : Nil
Blacklists a user from the chat, deletes the reply, and removes all the user's incoming and outgoing messages from the queue.
- #blacklist_contact : String | Nil
- #check_r9k_media(file_id : String, user : Database::User) : Bool | Nil
-
#check_text(text : String, user : Database::User, msid : Int64, entities : Array(Tourmaline::MessageEntity)) : String | Nil
Checks if the text contains a special font or starts a sign command.
-
#command_disabled(ctx : CommandHandler::Context) : Nil
Sends a message to the user if a disabled command is used
- #cooldown_time_begin : Array(Int32)
- #cooldown_time_linear_b : Int32
- #cooldown_time_linear_m : Int32
- #database : Database
- #default_rank : Int32
-
#delete_command(ctx : CommandHandler::Context) : Nil
Delete a message from a user, give a warning and a cooldown.
-
#delete_messages(msid : Int64, user_id : Int64, debug_enabled : Bool | Nil) : Int64 | Nil
Deletes the given message for all receivers and removes it from the message history.
-
#demote_command(ctx : CommandHandler::Context) : Nil
Demotes a user to a given rank.
- #demote_from_args(user : Database::User, args : Array(String) | Nil, msid : Int64) : Nil
- #demote_from_reply(user : Database::User, arg : String | Nil, msid : Int64, reply : Int64) : Nil
-
#deny_user(user : Database::User) : Nil
Sends a message to the user explaining why they cannot chat at this time
-
#downvote_command(ctx : CommandHandler::Context) : Nil
Downvotes a message.
- #downvote_limit_interval : Int32
- #enable_karma_sign : Bool | Nil
- #enable_ranksay : Bool | Nil
- #enable_sign : Bool | Nil
- #enable_tripsign : Bool | Nil
- #entity_types : Array(String)
-
#force_leave(user_id : Int64) : Nil
Set blocked user to left in the database and delete all incoming messages from the queue.
-
#get_history_type(db : DB::Database, config : Config) : History | DatabaseHistory
Determine appropriate
History
type based on given config variables -
#handle_animation(update : Tourmaline::Update) : Nil
Prepares a "animation" message for relaying.
-
#handle_audio(update : Tourmaline::Update) : Nil
Prepares a "audio" message for relaying.
-
#handle_basketball(update : Tourmaline::Update) : Nil
Prepares a "basketball" message for relaying.
-
#handle_bowling(update : Tourmaline::Update) : Nil
Prepares a "bowling" message for relaying.
-
#handle_contact(update : Tourmaline::Update) : Nil
Prepares a contact message for relaying.
-
#handle_dart(update : Tourmaline::Update) : Nil
Prepares a "dart" message for relaying.
-
#handle_dice(update : Tourmaline::Update) : Nil
Prepares a "dice" message for relaying.
-
#handle_document(update : Tourmaline::Update) : Nil
Prepares a "document" message for relaying.
- #handle_embedded_command(text : String, user : Database::User, msid : Int64) : String | Nil
-
#handle_forwarded_message(update : Tourmaline::Update) : Nil
Prepares a forwarded message for relaying.
-
#handle_karma_sign(text : String, user : Database::User, msid : Int64) : String | Nil
Given a command text, checks if karma signs are enabled and if the karma sign would be spammy, then returns the argument with a karma level signature
-
#handle_location(update : Tourmaline::Update) : Nil
Prepares a location message for relaying.
-
#handle_media_group(update : Tourmaline::Update) : Nil
Prepares an album message for relaying.
-
#handle_photo(update : Tourmaline::Update) : Nil
Prepares a "photo" message for relaying.
-
#handle_poll(update : Tourmaline::Update) : Nil
Prepares a poll for relaying.
-
#handle_ranksay(rank : String, text : String, user : Database::User, msid : Int64) : String | Nil
Given a ranked say command, checks if ranked says are enabled and determines the rank (either given or the user's current rank), then returns the argument with a ranked signature
- #handle_regular_forward(message : Tourmaline::Message, user : Database::User) : Nil
-
#handle_sign(text : String, user : Database::User, msid : Int64) : String | Nil
Given a command text, checks if signs are enabled, user has private forwards, or sign would be spammy, then returns the argument with a username signature
-
#handle_slot_machine(update : Tourmaline::Update) : Nil
Prepares a "slot_machine" message for relaying.
-
#handle_soccerball(update : Tourmaline::Update) : Nil
Prepares a "soccerball" message for relaying.
-
#handle_sticker(update : Tourmaline::Update) : Nil
Prepares a sticker message for relaying.
-
#handle_text(update : Tourmaline::Update)
Prepares a text message for relaying.
-
#handle_tripcode(text : String, user : Database::User, msid : Int64) : String | Nil
Given a command text, checks if tripcodes are enabled, if tripcode would be spammy, or if user does not have a tripcode set, then returns the argument with a tripcode header
-
#handle_venue(update : Tourmaline::Update) : Nil
Prepares a venue message for relaying.
-
#handle_video(update : Tourmaline::Update) : Nil
Prepares a "video" message for relaying.
-
#handle_video_note(update : Tourmaline::Update) : Nil
Prepares a "video_note" message for relaying.
-
#handle_voice(update : Tourmaline::Update) : Nil
Prepares a "voice" message for relaying.
-
#help_command(ctx : CommandHandler::Context) : Nil
Returns a message containing all the commands that a user can use, according to the user's rank.
- #history : History | DatabaseHistory
- #inactivity_limit : Int32
-
#info_command(ctx : CommandHandler::Context) : Nil
Returns a message containing the user's OID, username, karma, warnings, etc.
-
#initialize_handlers(descriptions : CommandDescriptions, config : Config) : Nil
Initializes CommandHandlers and UpdateHandlers Also checks whether or not a command or media type is enabled via the config, and registers commands with BotFather
- #karma_info_command(ctx : CommandHandler::Context) : Nil
- #karma_levels : Hash(Int32, String)
- #karma_warn_penalty : Int32
-
#kick_inactive_users : Nil
Kicks any users that have been inactive for a duration of time.
- #linked_network : Hash(String, String)
- #locale : Locale
- #log_channel : String
- #log_channel=(log_channel : String)
-
#log_output(log : String, params : Hash(String, String | Nil) = {"" => ""}) : Nil
Formats and outputs given log message to the log (either STDOUT or a file, defined in config) with INFO severity.
-
#media_disabled(update : Tourmaline::Update, type : String) : Nil
Sends a message to the user if a disabled media type is sent
- #media_limit_period : Int32
-
#motd_command(ctx : CommandHandler::Context) : Nil
Replies with the motd/rules associated with this bot.
- #pin_command(ctx : CommandHandler::Context) : Nil
- #preliminary_message_check(update : Tourmaline::Update) : Tuple(Tourmaline::Message | Nil, Database::User | Nil)
- #preliminary_message_check(ctx : CommandHandler::Context | Tourmaline::Update) : Tuple(Tourmaline::Message | Nil, Database::User | Nil)
-
#promote_command(ctx : CommandHandler::Context) : Nil
Promotes a user to a given rank.
- #promote_from_args(user : Database::User, authority : CommandPermissions, args : Array(String) | Nil, msid : Int64) : Nil
- #promote_from_reply(user : Database::User, authority : CommandPermissions, arg : String | Nil, msid : Int64, reply : Int64) : Nil
- #pseudonymous : Bool | Nil
-
#purge_command(ctx : CommandHandler::Context) : Nil
Delete all messages from recently blacklisted users.
- #queue : MessageQueue
- #r9k_cooldown : Int32
- #r9k_forwards : Bool | Nil
- #r9k_media : Bool | Nil
- #r9k_text : Bool | Nil
- #r9k_warn : Bool | Nil
- #ranked_info(user : Database::User, msid : Int64, reply : Int64) : Nil
-
#register_tasks(spam_interval_seconds : Int32) : Array(Tasker::Task)
Starts various background tasks and stores them in a hash.
- #registration_open : Bool | Nil
- #regular_forwards : Bool | Nil
-
#relay(reply_message : Tourmaline::Message | Nil, user : Database::User, cached_msid : Int64, proc : MessageProc) : Nil
Caches a message and sends it to the queue for relaying.
-
#relay(reply_message : Tourmaline::Message | Nil, user : Database::User, cached_msid : Array(Int64), proc : MessageProc) : Nil
Caches an album message and sends it to the queue for relaying.
- #relay_album(message : Tourmaline::Message, album : String, user : Database::User, caption : String | Nil, entities : Array(MessageEntity) = [] of MessageEntity) : Nil
- #relay_regular_forward(user : Database::User, message : Tourmaline::Message, text : String) : Nil
-
#relay_to_one(reply_message : Int64 | Nil, user : Int64, reply : String, params : Hash(String, String | Nil)) : Nil
Relay a message to a single user.
-
#relay_to_one(reply_message : Int64 | Nil, user : Int64, text : String)
Relay a message to a single user.
-
#remove_command(ctx : CommandHandler::Context) : Nil
Remove a message from a user without giving a warning or cooldown.
-
#reveal_command(ctx : CommandHandler::Context) : Nil
Privately reveal username to another user
-
#revert_ranked_users : Nil
Checks the database for any users that have ranks not found in the
AuthorizedRanks
hash. -
#send_messages : Bool | Nil
Receives a
Message
from the#queue
, calls its proc, and adds the returned message id to the History - #sign_limit_interval : Int32
- #smileys : Array(String)
- #spam_handler : SpamScoreHandler | Nil
- #spamming?(id : Int64, msid : Int64, score : Float32) : Bool | Nil
- #spamming_text?(id : Int64, msid : Int64, text : String) : Bool | Nil
-
#spoil_messages(msid : Int64, user_id : Int64, debug_enabled : Bool | Nil, input : InputMedia) : Bool | Nil
Spoils the given media message for all receivers by editing the media with the given input.
-
#spoiler_command(ctx : CommandHandler::Context) : Nil
Adds a spoiler overlay to a media message when replied to.
-
#start_command(ctx : CommandHandler::Context) : Nil
User starts the bot and begins receiving messages.
-
#stop_command(ctx : CommandHandler::Context) : Nil
Stops the bot for the user.
- #tasks : Array(Tasker::Task)
-
#toggle_debug_command(ctx : CommandHandler::Context) : Nil
Toggle the user's toggle_debug attribute.
-
#toggle_karma_command(ctx : CommandHandler::Context) : Nil
Toggle the user's hide_karma attribute.
-
#tripcode_command(ctx : CommandHandler::Context) : Nil
Set/modify/view the user's tripcode.
- #tripcode_salt : String
-
#uncooldown_command(ctx : CommandHandler::Context) : Nil
Removes a cooldown and warning from a user if the user is in cooldown.
- #unpin_command(ctx : CommandHandler::Context) : Nil
-
#upvote_command(ctx : CommandHandler::Context) : Nil
Upvotes a message.
- #upvote_limit_interval : Int32
- #user_info(user : Database::User, msid : Int64) : Nil
-
#users_command(ctx : CommandHandler::Context) : Nil
Return a message containing the number of users in the bot.
- #valid_codepoints : Array(Range(Int32, Int32))
- #validate_r9k_media(file_id : String | Nil, user : Database::User, message : Tourmaline::Message) : String | Nil
- #validate_r9k_text(text : String, user : Database::User, message : Tourmaline::Message) : Tuple(String | Nil, String | Nil)
-
#version_command(ctx : CommandHandler::Context) : Nil
Returns a message containing the progam's version.
-
#warn_command(ctx : CommandHandler::Context) : Nil
Warns a message without deleting it.
- #warn_expire_hours : Int32
-
#whitelist_command(ctx : CommandHandler::Context) : Nil
Whitelists a user, allowing the user to join the chat.
Constructor Detail
Creates a new instance of PrivateParlor
.
Arguments:
config
: a Config
from parsing the config.yaml
file
Instance Method Detail
Blacklists a user from the chat, deletes the reply, and removes all the user's incoming and outgoing messages from the queue.
Checks for the following permissions: blacklist
If blacklist
, allows the user to blacklist another user.
Checks if the text contains a special font or starts a sign command.
Returns the given text or a formatted text if it is allowed; nil if otherwise or a sign command could not be used.
Sends a message to the user if a disabled command is used
Delete a message from a user, give a warning and a cooldown.
Checks for the following permissions: delete
If delete
, allows the user to delete a message
Deletes the given message for all receivers and removes it from the message history.
Returns the sender's (user_id) original message id upon success.
Demotes a user to a given rank.
Checks for the following permissions: demote
If used with a reply, the reply user is demoted to either the user rank or a given rank.
Sends a message to the user explaining why they cannot chat at this time
Downvotes a message.
Checks for the following permissions: downvote
If downvote
, allows the user to downvote a message
Set blocked user to left in the database and delete all incoming messages from the queue.
Should only be invoked in #send_messages
, as this does not check the queue_mutex
Determine appropriate History
type based on given config variables
Prepares a "animation" message for relaying.
Prepares a "basketball" message for relaying.
Prepares a "document" message for relaying.
Prepares a forwarded message for relaying.
Given a command text, checks if karma signs are enabled and if the karma sign would be spammy, then returns the argument with a karma level signature
Given a ranked say command, checks if ranked says are enabled and determines the rank (either given or the user's current rank), then returns the argument with a ranked signature
Checks for the following permissions: ranksay
, ranksay_lower
If ranksay
, allows the user to sign a message with the user's rank name.
If ranksay_lower
, allows the user to sign a message with the user's rank name and any subordinate rank.
Given a command text, checks if signs are enabled, user has private forwards, or sign would be spammy, then returns the argument with a username signature
Checks for the following permissions: sign
If sign
, allows the user to sign a message
Prepares a "slot_machine" message for relaying.
Prepares a "soccerball" message for relaying.
Given a command text, checks if tripcodes are enabled, if tripcode would be spammy, or if user does not have a tripcode set, then returns the argument with a tripcode header
Checks for the following permissions: tsign
If tsign
, allows the user to sign a message with a tripcode.
Prepares a "video_note" message for relaying.
Returns a message containing all the commands that a user can use, according to the user's rank.
Returns a message containing the user's OID, username, karma, warnings, etc.
Checks for the following permissions: #ranked_info
(for replies only)
If this is used with a reply, returns the user info of that message if the invoker is ranked.
Initializes CommandHandlers and UpdateHandlers Also checks whether or not a command or media type is enabled via the config, and registers commands with BotFather
Formats and outputs given log message to the log (either STDOUT or a file, defined in config) with INFO severity.
Also outputs message to a given log channel, if available
Sends a message to the user if a disabled media type is sent
Replies with the motd/rules associated with this bot.
Checks for the following permissions: motd_set
(only when an argument is given)
If the host invokes this command, the motd/rules can be set or modified.
Promotes a user to a given rank.
Checks for the following permissions: promote
, promote_lower
, promote_same
If promote
, the reply user can be promoted to a rank lower or equal to the invoker's rank.
If promote_lower
, the reply user can be promoted to a rank lower than the invoker's rank.
If promote_same
, the reply user can only be promoted to the invoker's rank.
If used with a reply, the reply user is promoted to the invoker's rank or the given rank.
Delete all messages from recently blacklisted users.
Checks for the following permissions: purge
If purge
, allows the user to run a purge
Starts various background tasks and stores them in a hash.
Caches a message and sends it to the queue for relaying.
Caches an album message and sends it to the queue for relaying.
Relay a message to a single user. Used for system messages.
Relay a message to a single user. Used for system messages.
Remove a message from a user without giving a warning or cooldown.
Checks for the following permissions: remove
If remove
, allows the user to remove a message
Checks the database for any users that have ranks not found in the AuthorizedRanks
hash.
If the rank is not valid, the user is reverted to the default user rank.
Receives a Message
from the #queue
, calls its proc, and adds the returned message id to the History
This function should be invoked in a Fiber.
Spoils the given media message for all receivers by editing the media with the given input.
Returns true on success, false or nil otherwise.
Adds a spoiler overlay to a media message when replied to.
Checks for the following permissions: spoiler
If spoiler
, allows the user to add a spoiler to a relayed media message.
User starts the bot and begins receiving messages.
If the user is not in the database, this will add the user to it
If blacklisted or joined, this will not allow them to rejoin
Left users can rejoin the bot with this command
Stops the bot for the user.
This will set the user status to left, meaning the user will not receive any further messages.
Toggle the user's toggle_debug attribute.
Toggle the user's hide_karma attribute.
Removes a cooldown and warning from a user if the user is in cooldown.
Checks for the following permissions: uncooldown
If uncooldown
, allows the user to uncooldown another user
Upvotes a message.
Checks for the following permissions: upvote
If upvote
, allows the user to upvote a message
Return a message containing the number of users in the bot.
Checks for the following permissions: users
If the user does not have the "users" permission, show the total numbers of users. Otherwise, return a message containing the number of joined, left, and blacklisted users.
Returns a message containing the progam's version.
Warns a message without deleting it. Gives the user who sent the message a warning and a cooldown.
Checks for the following permissions: warn
If warn
, allows the user to warn a message
Whitelists a user, allowing the user to join the chat. Only applicable if registration is closed
Checks for the following permissions: whitelist
If whitelist
, allows the user to whitelist another user by user ID.