abstract class PrivateParlorXT::UpdateHandler
- PrivateParlorXT::UpdateHandler
- PrivateParlorXT::Handler
- Reference
- Object
Overview
A base class for handling one of the Telegram updates (Tourmaline::Text
, Tourmaline::Photo
, Tourmaline::ForwardedMessage
, etc).
Handlers that are meant to work with Telegram updates should inherit this class,
and include an On
annotation to have it be usable by the bot.
Direct Known Subclasses
- PrivateParlorXT::AlbumHandler
- PrivateParlorXT::AnimationHandler
- PrivateParlorXT::AudioHandler
- PrivateParlorXT::ContactHandler
- PrivateParlorXT::DocumentHandler
- PrivateParlorXT::ForwardHandler
- PrivateParlorXT::LocationHandler
- PrivateParlorXT::PhotoHandler
- PrivateParlorXT::PollHandler
- PrivateParlorXT::RegularForwardHandler
- PrivateParlorXT::StickerHandler
- PrivateParlorXT::TextHandler
- PrivateParlorXT::VenueHandler
- PrivateParlorXT::VideoHandler
- PrivateParlorXT::VideoNoteHandler
- PrivateParlorXT::VoiceHandler
Defined in:
private-parlor-xt/handlers/update_handler.crMacro Summary
-
return_on_command(text)
Returns early if the message text contains a command.
Instance Method Summary
-
#authorized?(user : User, message : Tourmaline::Message, authority : MessagePermissions, services : Services) : Bool
Returns
true
if user is authorized to send this type of message (one of theMessagePermissions
types). -
#deny_user(user : User, services : Services) : Nil
Queues a system reply when the user cannot chat due to being either cooldowned, blacklisted, media limited, or left.
-
#meets_requirements?(message : Tourmaline::Message) : Bool
Returns
true
if the message is not a forward or an album. -
#message_receivers(user : User, services : Services) : Array(UserID)
Returns an array of
UserID
for which the relayed message will be sent to -
#record_message_statistics(type : Statistics::Messages, services : Services) : Nil
If the statistics module is enabled, update the message_stats for the given type by incrementing the totals.
-
#reply_receivers(message : Tourmaline::Message, user : User, services : Services) : Hash(UserID, ReplyParameters) | Nil
Returns a hash of a receiver's
UserID
to the relevant message ID for which this message will reply to when relayed. - #user_from_message(message : Tourmaline::Message, services : Services) : User | Nil
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
Macro Detail
Returns early if the message text contains a command.
Iterates through all HearsHandlers
that are meant to be commands,
and returns early if the handler matches a substring in the text (for RegexLiteral
patterns)
or if the handler starts with a substring (for StringLiteral
patterns)
Instance Method Detail
Returns true
if user is authorized to send this type of message (one of the MessagePermissions
types).
Returns false
otherwise.
Queues a system reply when the user cannot chat due to being either cooldowned, blacklisted, media limited, or left.
Returns true
if the message is not a forward or an album.
Returns false
otherwise.
Returns an array of UserID
for which the relayed message will be sent to
If the given User has debug mode enabled, he will get a copy of the relayed message
If the statistics module is enabled, update the message_stats for the given type by incrementing the totals.
Returns a hash of a receiver's UserID
to the relevant message ID for which this message will reply to when relayed.
When quoting, the ReplyParameters
value will contain the replied message's quote if it is not invalid (i.e., user quoted his own message and it had strippable entities or was edited)
The hash will be empty if the message does not have a reply
Returns nil if the message had a reply, but no receiver message IDs could be found (message replied to is no longer in the cache)