abstract class TelegramBot::Bot

Defined in:

telegram_bot/bot.cr

Constant Summary

Log = ::Log.for(self)

Constructors

Instance Method Summary

Macro Summary

Constructor Detail

def self.new(name : String, token : String, allowlist : Array(String) | Nil = nil, blocklist : Array(String) | Nil = nil, updates_timeout : Int32 | Nil = nil, allowed_updates : Array(String) | Nil = nil) #

@name username of the bot @token @allowlist @blocklist @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 delete_chat_photo(chat_id : Int | String) #

def delete_chat_sticker_set(chat_id : Int | String) #

def delete_message(chat_id : Int | String, message_id : Int32) : Message | Bool | Nil #

def delete_sticker_position_in_set(sticker : String) #

def delete_webhook : Bool | Nil #

def download(file : File) #

def download(file_path : String) #

def download(media) #

def 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 #

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 export_chat_invite_link(chat_id : Int | String) #

def forward_message(chat_id : Int | String, from_chat_id : Int | String, message_id : Int32, disable_notification : Bool | Nil = nil) : Message | Nil #

def get_chat(chat_id : Int | String) #

def get_chat_administrators(chat_id : Int | String) #

def get_chat_member(chat_id : Int | String, user_id : Int32) #

def get_chat_members_count(chat_id : Int | String) #

def get_file(file_id : String) : File #

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_me #

def get_my_commands : Array(BotCommand) #

Get the current list of the bot's commands.


def get_sticker_set(name : String) #

def get_user_profile_photos(user_id : Int32, offset : Int32 | Nil = nil, limit : Int32 | Nil = nil) #

def handle(message : Message) #

handle messages


def handle(inline_query : InlineQuery) #

handle inline query


def handle(chosen_inline_result : ChosenInlineResult) #

handle chosen inlien query


def handle(callback_query : CallbackQuery) #

handle callback query


def handle_channel_post(message : Message) #

def handle_edited(message : Message) #

handle edited messages


def handle_edited_channel_post(message : Message) #

def handle_update(u) #

def kick_chat_member(chat_id : Int | String, user_id : Int, until_date : Int | Nil = nil) #

def leave_chat(chat_id : Int | String) #

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 polling #

run long polling in a loop and call handlers for messages


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 reply(message : Message, text : String) : Message | 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_chat_action(chat_id : Int | String, action : String) #

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_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 #

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_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


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(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 #

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_chat_description(chat_id : Int | String, description : String) #

def set_chat_photo(chat_id : Int | String, photo : ::File) #

def set_chat_sticker_set(chat_id : Int | String, sticker_set_name : String) #

def set_chat_title(chat_id : Int | String, title : String) #

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_my_commands(commands : Array(BotCommand)) #

Change the list of the bot's commands.


def set_sticker_position_in_set(sticker : String, position : Int) #

def set_webhook(url : String, certificate : ::File | String | Nil = nil, max_connections : Int32 | Nil = nil, allowed_updates : Array(String) | Nil = @allowed_updates) #

def stop #

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) #

def unban_chat_member(chat_id : Int | String, user_id : Int32) #

def unpin_chat_message(chat_id : Int | String) #

def upload_sticker_file(user_id : Int, png_sticker : ::File) #

Macro Detail

macro def_force_request(name, *args) #

macro def_request(name, *args) #