class
Telecr::Core::Context
- Telecr::Core::Context
- Reference
- Object
Overview
Context holds everything related to a single Telegram update It's passed through middleware chain and finally to the user's handler
Defined in:
core/context.crConstructors
-
.new(update : Types::Update, bot : Bot)
Initialize with update and bot
Instance Method Summary
-
#answer_callback_query(text : String | Nil = nil, show_alert : Bool = false, **options)
Answer a callback query
-
#answer_inline_query(results : Array, **options)
Answer an inline query with results
-
#api
Get API client
-
#audio(audio, caption : String | Nil = nil, **options)
Send an audio file
-
#ban_chat_member(user_id : Int64, **options)
Ban a member from the chat
- #bot : Bot
- #bot=(bot : Bot)
-
#callback_query : Types::CallbackQuery | Nil
Get the callback query if this update is a callback
-
#callback_query? : Bool
Check if this is a callback query
-
#caption : String | Nil
Get message caption
-
#caption_entities : Array(Types::MessageEntity)
Get caption entities
-
#channel_post? : Bool
Check if this is a channel post
-
#chat : Types::Chat | Nil
Get the chat where this update occurred
-
#command? : Bool
Check if this is a command message
-
#command_args : String | Nil
Get command arguments if this is a command
-
#command_name : String | Nil
Get command name if this is a command
-
#copy_message(from_chat_id : Int64, message_id : Int64, **options)
Copy a message from another chat
-
#data : String | Nil
Get callback data (for callback queries)
-
#delete_message(message_id : Int64 | Nil = nil)
Delete a message
-
#document(document, caption : String | Nil = nil, **options)
Send a document
-
#download_file(file_id : String, destination_path : String | Nil = nil)
Download a file from Telegram
-
#edit_date : Time | Nil
Get edit date if message was edited
-
#edit_message_reply_markup(reply_markup, **options)
Edit message reply markup
-
#edit_message_text(text : String, **options)
Edit the current message text
-
#edited? : Bool
Check if this is an edited message
-
#entities : Array(Types::MessageEntity)
Get message entities
-
#forward_message(from_chat_id : Int64, message_id : Int64, **options)
Forward a message from another chat
-
#from : Types::User | Nil
Get the user who sent this update
-
#get_chat(**options)
Get chat info
-
#get_chat_administrators(**options)
Get chat administrators
-
#get_chat_members_count(**options)
Get members count
-
#has_media? : Bool
Check if message has media
-
#inline_keyboard(&)
Create an inline keyboard
-
#inline_query : Types::InlineQuery | Nil
Get the inline query if this update is an inline query
-
#inline_query? : Bool
Check if this is an inline query
-
#keyboard(&)
===== Keyboard Helpers ===== Create a reply keyboard
-
#kick_chat_member(user_id : Int64, **options)
Kick a member from the chat
-
#location(latitude : Float64, longitude : Float64, **options)
Send a location
-
#logger
===== Utility Methods ===== Get logger from bot
- #match : Regex::MatchData | Nil
- #match=(match : Regex::MatchData | Nil)
-
#media_type : Symbol | Nil
Get media type if present
-
#message : Types::Message | Nil
===== Update Type Accessors ===== Get the message if this update is a message
-
#message_date : Time | Nil
Get message date
-
#message_id : Int64 | Nil
===== Message Properties ===== Get message ID
-
#photo(photo, caption : String | Nil = nil, **options)
===== Media Sending Methods ===== Send a photo
-
#pin_message(message_id : Int64, **options)
===== Chat Management ===== Pin a message in the chat
-
#query : String | Nil
Get inline query text
-
#raw_update
Get raw update data (for debugging)
-
#remove_keyboard(text : String | Nil = nil, **options)
Remove keyboard
-
#replied_chat : Types::Chat | Nil
Get chat of replied message
-
#replied_from : Types::User | Nil
Get sender of replied message
-
#replied_message : Types::Message | Nil
Get the message being replied to
-
#replied_text : String | Nil
Get text of replied message
-
#reply(text : String, options : Hash(String, JSON::Any) = {} of String => JSON::Any)
===== Response Methods ===== Send a text message to the chat (with hash options)
-
#reply(text : String, **options)
Send a text message to the chat (with named arguments)
-
#reply? : Bool
Check if this is a reply to another message
-
#reply_draft(text : String, **options)
NEW in API 9.5: Send a message draft (streaming)
-
#reply_with_inline_keyboard(text : String, inline_markup, **options)
Reply with inline keyboard (using the hash version of reply)
-
#reply_with_keyboard(text : String, keyboard_markup, **options)
Reply with a keyboard (using the hash version of reply)
-
#send_chat_action(action : String, **options)
Send a chat action (typing, uploading, etc.)
-
#sender_tag : String | Nil
NEW in API 9.5: Get sender tag (for group members)
- #session : Hash(String, JSON::Any)
- #session=(session : Hash(String, JSON::Any))
- #state : Hash(Symbol, JSON::Any)
- #state=(state : Hash(Symbol, JSON::Any))
-
#sticker(sticker, **options)
Send a sticker
-
#typing(**options)
===== Chat Actions ===== Send typing action
- #typing_active : Bool
- #typing_active=(typing_active : Bool)
-
#unban_chat_member(user_id : Int64, **options)
Unban a member
-
#unpin_message(**options)
Unpin a message
-
#update : Types::Update
Core properties
-
#update=(update : Types::Update)
Core properties
-
#update_type : Symbol
===== Update Type Detection ===== Get the type of this update as a symbol
-
#uploading_audio(**options)
Send uploading audio action
-
#uploading_document(**options)
Send uploading document action
-
#uploading_photo(**options)
Send uploading photo action
-
#uploading_video(**options)
Send uploading video action
-
#user_id : Int64 | Nil
Get user ID
-
#video(video, caption : String | Nil = nil, **options)
Send a video
-
#voice(voice, caption : String | Nil = nil, **options)
Send a voice message
-
#with_typing(&block)
Keep typing active during a long operation
Constructor Detail
Instance Method Detail
Answer a callback query
Get the callback query if this update is a callback
Copy a message from another chat
Download a file from Telegram
Forward a message from another chat
Get the inline query if this update is an inline query
===== Update Type Accessors ===== Get the message if this update is a message
===== Media Sending Methods ===== Send a photo
===== Chat Management ===== Pin a message in the chat
===== Response Methods ===== Send a text message to the chat (with hash options)
Reply with inline keyboard (using the hash version of reply)
Reply with a keyboard (using the hash version of reply)
===== Update Type Detection ===== Get the type of this update as a symbol