abstract class TelegramBot::Bot
- TelegramBot::Bot
- Reference
- Object
Defined in:
telegram_bot/bot.crConstructors
-
.new(name : String, token : String, whitelist : Array(String) | Nil = nil, blacklist : Array(String) | Nil = nil, updates_timeout : Int32 | Nil = nil, allowed_updates : Array(String) | Nil = nil)
@name username of the bot @token @whitelist @blacklist @updates_timeout
Instance Method Summary
- #add_sticker_to_set(user_id : Int, name : String, png_sticker : ::File | String, emojis : String, mask_position : MaskPosition | Nil = nil)
- #answer_callback_query(callback_query_id : String, text : String | Nil = nil, show_alert : Bool | Nil = nil, url : String | Nil = nil, cache_time : Int32 | Nil = nil)
- #answer_inline_query(inline_query_id : String, results : Array(InlineQueryResult), cache_time : Int32 | Nil = nil, is_personal : Bool | Nil = nil, next_offset : String | Nil = nil, switch_pm_text : String | Nil = nil, switch_pm_parameter : String | Nil = nil) : Bool | Nil
- #answer_pre_checkout_query(pre_checkout_query_id : String, ok : Bool, error_message : String | Nil = nil) : Bool | Message | Nil
- #answer_shipping_query(shipping_query_id : String, ok : Bool, shipping_option : Array(ShippingOption) | Nil = nil, error_message : String | Nil = nil) : Bool | Message | Nil
- #create_new_sticker_set(user_id : Int, name : String, title : String, png_sticker : ::File | String, emojis : String, contains_masks : Bool | Nil = nil, mask_position : MaskPosition | Nil = nil)
- #delete_chat_photo(chat_id : Int | String)
- #delete_chat_sticker_set(chat_id : Int | String)
- #delete_message(chat_id : Int | String, message_id : Int32) : Message | Bool | Nil
- #delete_sticker_position_in_set(sticker : String)
- #delete_webhook : Bool | Nil
- #download(file : File)
- #download(file_path : String)
- #download(media)
- #edit_message_caption(chat_id : Int | String | Nil = nil, message_id : Int32 | Nil = nil, inline_message_id : String | Nil = nil, caption : String | Nil = nil, reply_markup : InlineKeyboardMarkup | Nil = nil) : Message | Bool | Nil
- #edit_message_live_location(latitude : Float, longitude : Float, chat_id : Int | String | Nil = nil, message_id : Int32 | Nil = nil, inline_message_id : String | Nil = nil, reply_markup : ReplyMarkup | Nil = nil)
- #edit_message_reply_markup(chat_id : Int | String | Nil = nil, message_id : Int32 | Nil = nil, inline_message_id : String | Nil = nil, reply_markup : InlineKeyboardMarkup | Nil = nil) : Message | Bool | Nil
- #edit_message_text(chat_id : Int | String | Nil = nil, message_id : Int32 | Nil = nil, inline_message_id : String | Nil = nil, text : String | Nil = nil, parse_mode : String | Nil = nil, disable_web_page_preview : Bool | Nil = nil, reply_markup : InlineKeyboardMarkup | Nil = nil) : Message | Bool | Nil
- #export_chat_invite_link(chat_id : Int | String)
- #forward_message(chat_id : Int | String, from_chat_id : Int | String, message_id : Int32, disable_notification : Bool | Nil = nil) : Message | Nil
- #get_chat(chat_id : Int | String)
- #get_chat_administrators(chat_id : Int | String)
- #get_chat_member(chat_id : Int | String, user_id : Int32)
- #get_chat_members_count(chat_id : Int | String)
- #get_file(file_id : String) : File
- #get_game_high_scores(user_id : Int32, chat_id : Int | String | Nil = nil, message_id : Int32 | Nil = nil, inline_message_id : String | Nil = nil) : Array(GameHighScore)
- #get_me
- #get_sticker_set(name : String)
- #get_user_profile_photos(user_id : Int32, offset : Int32 | Nil = nil, limit : Int32 | Nil = nil)
-
#handle(message : Message)
handle messages
-
#handle(inline_query : InlineQuery)
handle inline query
-
#handle(chosen_inline_result : ChosenInlineResult)
handle chosen inlien query
-
#handle(callback_query : CallbackQuery)
handle callback query
- #handle_channel_post(message : Message)
-
#handle_edited(message : Message)
handle edited messages
- #handle_edited_channel_post(message : Message)
- #handle_update(u)
- #kick_chat_member(chat_id : Int | String, user_id : Int, until_date : Int | Nil = nil)
- #leave_chat(chat_id : Int | String)
- #pin_chat_message(chat_id : Int | String, message_id : Int32, disable_notification : Bool | Nil)
- #pin_chat_message(chat_id : Int | String, message_id : Int, disable_notification : Bool | Nil = nil)
-
#polling
run long polling in a loop and call handlers for messages
- #promote_chat_member(chat_id : Int | String, user_id : Int, can_change_info : Bool | Nil = nil, can_post_messages : Bool | Nil = nil, can_edit_messages : Bool | Nil = nil, can_delete_messages : Bool | Nil = nil, can_invite_users : Bool | Nil = nil, can_restrict_members : Bool | Nil = nil, can_pin_messages : Bool | Nil = nil, can_promote_members : Bool | Nil = nil)
- #reply(message : Message, text : String) : Message | Nil
- #restrict_chat_member(chat_id : Int | String, user_id : Int, until_date : Int | Nil = nil, can_send_messages : Bool | Nil = nil, can_send_media_messages : Bool | Nil = nil, can_send_other_messages : Bool | Nil = nil, can_add_web_page_previews : Bool | Nil = nil)
- #send_audio(chat_id : Int | String, audio : ::File | String, duration : Int32 | Nil = nil, performer : String | Nil = nil, title : String | Nil = nil, disable_notification : Bool | Nil = nil, reply_to_message_id : Int32 | Nil = nil, reply_markup : ReplyMarkup = nil) : Message | Nil
- #send_chat_action(chat_id : Int | String, action : String)
- #send_contact(chat_id : Int | String, phone_number : String, first_name : String, last_name : String | Nil = nil, reply_to_message_id : Int32 | Nil = nil, reply_markup : ReplyMarkup = nil) : Message | Nil
- #send_document(chat_id : Int | String, document : ::File | String, caption : String | Nil = nil, disable_notification : Bool | Nil = nil, reply_to_message_id : Int32 | Nil = nil, reply_markup : ReplyMarkup = nil) : Message | Nil
- #send_game(chat_id : Int | String, game_short_name : String, disable_notification : Bool | Nil = nil, reply_to_message_id : Int32 | Nil = nil, reply_markup : InlineKeyboardMarkup | Nil = nil) : Message | Nil
- #send_invoice(chat_id : Int, tilte : String, description : String, payload : String, provider_token : String, start_parameter : String, currency : String, prices : Array(LabeledPrice), provider_data : String | Nil = nil, photo_url : String | Nil = nil, photo_size : Int32 | Nil = nil, photo_width : Int32 | Nil = nil, photo_height : Int32 | Nil = nil, need_name : Bool | Nil = nil, need_phone_number : Bool | Nil = nil, need_email : Bool | Nil = nil, need_shipping_address : Bool | Nil = nil, is_flexible : Bool | Nil = nil, disable_notification : Bool | Nil = nil, reply_to_message_id : Int32 | Nil = nil, reply_markup : ReplyMarkup = nil) : Message | Nil
- #send_location(chat_id : Int | String, latitude : Float, longitude : Float, live_period : Int32 | Nil = nil, disable_notification : Bool | Nil = nil, reply_to_message_id : Int32 | Nil = nil, reply_markup : ReplyMarkup = nil) : Message | Nil
- #send_media_group(chat_id : Int | String, media : Array(InputMedia), disable_notification : Bool | Nil = nil, reply_to_message_id : Int32 | Nil = nil) : Message | Nil
- #send_message(chat_id : Int | String, text : String, parse_mode : String | Nil = nil, disable_web_page_preview : Bool | Nil = nil, disable_notification : Bool | Nil = nil, reply_to_message_id : Int32 | Nil = nil, reply_markup : ReplyMarkup = nil) : Message | Nil
-
#send_photo(chat_id : Int | String, photo : ::File | String, caption : String | Nil = nil, disable_notification : Bool | Nil = nil, reply_to_message_id : Int32 | Nil = nil, reply_markup : ReplyMarkup = nil) : Message | Nil
@photo file or file id
- #send_sticker(chat_id : Int | String, sticker : ::File | String, disable_notification : Bool | Nil = nil, reply_to_message_id : Int32 | Nil = nil, reply_markup : ReplyMarkup = nil) : Message | Nil
- #send_venue(chat_id : Int | String, latitude : Float, longitude : Float, title : String, address : String, forsquare_id : String | Nil = nil, disable_notification : Bool | Nil = nil, reply_to_message_id : Int32 | Nil = nil, reply_markup : ReplyMarkup | Nil = nil) : Message | Nil
- #send_video(chat_id : Int | String, video : ::File | String, duration : Int32 | Nil = nil, width : Int32 | Nil = nil, height : Int32 | Nil = nil, caption : String | Nil = nil, disable_notification : Bool | Nil = nil, reply_to_message_id : Int32 | Nil = nil, reply_markup : ReplyMarkup = nil) : Message | Nil
- #send_video_note(chat_id : Int | String, video_note : ::File | String, duration : Int32 | Nil = nil, length : Int32 | Nil = nil, disable_notification : Bool | Nil = nil, reply_to_message_id : Int32 | Nil = nil, reply_markup : ReplyMarkup = nil) : Message | Nil
- #send_voice(chat_id : Int | String, voice : ::File | String, duration : Int32 | Nil = nil, disable_notification : Bool | Nil = nil, reply_to_message_id : Int32 | Nil = nil, reply_markup : ReplyMarkup = nil) : Message | Nil
- #serve(bind_address : String = "127.0.0.1", bind_port : Int32 = 80, ssl_certificate_path : String | Nil = nil, ssl_key_path : String | Nil = nil)
- #set_chat_description(chat_id : Int | String, description : String)
- #set_chat_photo(chat_id : Int | String, photo : ::File)
- #set_chat_sticker_set(chat_id : Int | String, sticker_set_name : String)
- #set_chat_title(chat_id : Int | String, title : String)
- #set_game_score(user_id : Int32, score : Int32, force : Bool | Nil = nil, disable_edit_message : Bool | Nil = nil, chat_id : Int | String | Nil = nil, message_id : Int32 | Nil = nil, inline_message_id : String | Nil = nil) : Message | Bool | Nil
- #set_sticker_position_in_set(sticker : String, position : Int)
- #set_webhook(url : String, certificate : ::File | String | Nil = nil, max_connections : Int32 | Nil = nil, allowed_updates : Array(String) | Nil = @allowed_updates)
- #stop_message_live_location(chat_id : Int | String | Nil = nil, message_id : Int32 | Nil = nil, inline_message_id : String | Nil = nil, reply_markup : ReplyMarkup | Nil = nil)
- #unban_chat_member(chat_id : Int | String, user_id : Int32)
- #unpin_chat_message(chat_id : Int | String)
- #upload_sticker_file(user_id : Int, png_sticker : ::File)
Macro Summary
Constructor Detail
def self.new(name : String, token : String, whitelist : Array(String) | Nil = nil, blacklist : Array(String) | Nil = nil, updates_timeout : Int32 | Nil = nil, allowed_updates : Array(String) | Nil = nil)
#
@name username of the bot @token @whitelist @blacklist @updates_timeout
Instance Method Detail
def add_sticker_to_set(user_id : Int, name : String, png_sticker : ::File | String, emojis : String, mask_position : MaskPosition | Nil = nil)
#
def answer_callback_query(callback_query_id : String, text : String | Nil = nil, show_alert : Bool | Nil = nil, url : String | Nil = nil, cache_time : Int32 | Nil = nil)
#
def answer_inline_query(inline_query_id : String, results : Array(InlineQueryResult), cache_time : Int32 | Nil = nil, is_personal : Bool | Nil = nil, next_offset : String | Nil = nil, switch_pm_text : String | Nil = nil, switch_pm_parameter : String | Nil = nil) : Bool | Nil
#
def answer_pre_checkout_query(pre_checkout_query_id : String, ok : Bool, error_message : String | Nil = nil) : Bool | Message | Nil
#
def answer_shipping_query(shipping_query_id : String, ok : Bool, shipping_option : Array(ShippingOption) | Nil = nil, error_message : String | Nil = nil) : Bool | Message | Nil
#
def create_new_sticker_set(user_id : Int, name : String, title : String, png_sticker : ::File | String, emojis : String, contains_masks : Bool | Nil = nil, mask_position : MaskPosition | Nil = nil)
#
def edit_message_live_location(latitude : Float, longitude : Float, chat_id : Int | String | Nil = nil, message_id : Int32 | Nil = nil, inline_message_id : String | Nil = nil, reply_markup : ReplyMarkup | Nil = nil)
#
def edit_message_reply_markup(chat_id : Int | String | Nil = nil, message_id : Int32 | Nil = nil, inline_message_id : String | Nil = nil, reply_markup : InlineKeyboardMarkup | Nil = nil) : Message | Bool | Nil
#
def edit_message_text(chat_id : Int | String | Nil = nil, message_id : Int32 | Nil = nil, inline_message_id : String | Nil = nil, text : String | Nil = nil, parse_mode : String | Nil = nil, disable_web_page_preview : Bool | Nil = nil, reply_markup : InlineKeyboardMarkup | Nil = nil) : Message | Bool | Nil
#
def forward_message(chat_id : Int | String, from_chat_id : Int | String, message_id : Int32, disable_notification : Bool | Nil = nil) : Message | Nil
#
def get_game_high_scores(user_id : Int32, chat_id : Int | String | Nil = nil, message_id : Int32 | Nil = nil, inline_message_id : String | Nil = nil) : Array(GameHighScore)
#
def get_user_profile_photos(user_id : Int32, offset : Int32 | Nil = nil, limit : Int32 | Nil = nil)
#
def kick_chat_member(chat_id : Int | String, user_id : Int, until_date : Int | Nil = nil)
#
def pin_chat_message(chat_id : Int | String, message_id : Int32, disable_notification : Bool | Nil)
#
def pin_chat_message(chat_id : Int | String, message_id : Int, disable_notification : Bool | Nil = nil)
#
def promote_chat_member(chat_id : Int | String, user_id : Int, can_change_info : Bool | Nil = nil, can_post_messages : Bool | Nil = nil, can_edit_messages : Bool | Nil = nil, can_delete_messages : Bool | Nil = nil, can_invite_users : Bool | Nil = nil, can_restrict_members : Bool | Nil = nil, can_pin_messages : Bool | Nil = nil, can_promote_members : Bool | Nil = nil)
#
def restrict_chat_member(chat_id : Int | String, user_id : Int, until_date : Int | Nil = nil, can_send_messages : Bool | Nil = nil, can_send_media_messages : Bool | Nil = nil, can_send_other_messages : Bool | Nil = nil, can_add_web_page_previews : Bool | Nil = nil)
#
def send_audio(chat_id : Int | String, audio : ::File | String, duration : Int32 | Nil = nil, performer : String | Nil = nil, title : String | Nil = nil, disable_notification : Bool | Nil = nil, reply_to_message_id : Int32 | Nil = nil, reply_markup : ReplyMarkup = nil) : Message | Nil
#
def send_contact(chat_id : Int | String, phone_number : String, first_name : String, last_name : String | Nil = nil, reply_to_message_id : Int32 | Nil = nil, reply_markup : ReplyMarkup = nil) : Message | Nil
#
def send_game(chat_id : Int | String, game_short_name : String, disable_notification : Bool | Nil = nil, reply_to_message_id : Int32 | Nil = nil, reply_markup : InlineKeyboardMarkup | Nil = nil) : Message | Nil
#
def send_invoice(chat_id : Int, tilte : String, description : String, payload : String, provider_token : String, start_parameter : String, currency : String, prices : Array(LabeledPrice), provider_data : String | Nil = nil, photo_url : String | Nil = nil, photo_size : Int32 | Nil = nil, photo_width : Int32 | Nil = nil, photo_height : Int32 | Nil = nil, need_name : Bool | Nil = nil, need_phone_number : Bool | Nil = nil, need_email : Bool | Nil = nil, need_shipping_address : Bool | Nil = nil, is_flexible : Bool | Nil = nil, disable_notification : Bool | Nil = nil, reply_to_message_id : Int32 | Nil = nil, reply_markup : ReplyMarkup = nil) : Message | Nil
#
def send_location(chat_id : Int | String, latitude : Float, longitude : Float, live_period : Int32 | Nil = nil, disable_notification : Bool | Nil = nil, reply_to_message_id : Int32 | Nil = nil, reply_markup : ReplyMarkup = nil) : Message | Nil
#
def send_media_group(chat_id : Int | String, media : Array(InputMedia), disable_notification : Bool | Nil = nil, reply_to_message_id : Int32 | Nil = nil) : Message | Nil
#
def send_message(chat_id : Int | String, text : String, parse_mode : String | Nil = nil, disable_web_page_preview : Bool | Nil = nil, disable_notification : Bool | Nil = nil, reply_to_message_id : Int32 | Nil = nil, reply_markup : ReplyMarkup = nil) : Message | Nil
#
def send_sticker(chat_id : Int | String, sticker : ::File | String, disable_notification : Bool | Nil = nil, reply_to_message_id : Int32 | Nil = nil, reply_markup : ReplyMarkup = nil) : Message | Nil
#
def send_venue(chat_id : Int | String, latitude : Float, longitude : Float, title : String, address : String, forsquare_id : String | Nil = nil, disable_notification : Bool | Nil = nil, reply_to_message_id : Int32 | Nil = nil, reply_markup : ReplyMarkup | Nil = nil) : Message | Nil
#
def send_video_note(chat_id : Int | String, video_note : ::File | String, duration : Int32 | Nil = nil, length : Int32 | Nil = nil, disable_notification : Bool | Nil = nil, reply_to_message_id : Int32 | Nil = nil, reply_markup : ReplyMarkup = nil) : Message | Nil
#
def send_voice(chat_id : Int | String, voice : ::File | String, duration : Int32 | Nil = nil, disable_notification : Bool | Nil = nil, reply_to_message_id : Int32 | Nil = nil, reply_markup : ReplyMarkup = nil) : Message | Nil
#
def serve(bind_address : String = "127.0.0.1", bind_port : Int32 = 80, ssl_certificate_path : String | Nil = nil, ssl_key_path : String | Nil = nil)
#
def set_game_score(user_id : Int32, score : Int32, force : Bool | Nil = nil, disable_edit_message : Bool | Nil = nil, chat_id : Int | String | Nil = nil, message_id : Int32 | Nil = nil, inline_message_id : String | Nil = nil) : Message | Bool | Nil
#
def set_webhook(url : String, certificate : ::File | String | Nil = nil, max_connections : Int32 | Nil = nil, allowed_updates : Array(String) | Nil = @allowed_updates)
#
def stop_message_live_location(chat_id : Int | String | Nil = nil, message_id : Int32 | Nil = nil, inline_message_id : String | Nil = nil, reply_markup : ReplyMarkup | Nil = nil)
#