class Telecr::Core::Bot

Overview

Main bot class that users interact with

Defined in:

core/bot.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(token : String) #

Initialize a new bot with your Telegram token


[View source]

Instance Method Detail

def chat_boost(&block) #

Handle chat boosts


[View source]
def chat_join_request(&block) #

Handle chat join requests


[View source]
def client : Telecr::Api::Client #

Core components


[View source]
def command(name : String, &block) #

Register a command handler (e.g. /start)


[View source]
def composer : Composer #

[View source]
def contact(**options, &block) #

Handle contact sharing


[View source]
def create_forum_topic(chat_id, name, **options) #

Create a forum topic


[View source]
def error(&block) #

Set custom error handler


[View source]
def get_user_profile_audios(user_id : String, **options) #

Get user's profile audios


[View source]
def hears(pattern, &block) #

Register a handler for messages matching a pattern


[View source]
def location(&block) #

Handle location messages


[View source]
def message_reaction(&block) #

Handle message reactions


[View source]
def message_reaction_count(&block) #

Handle message reaction counts


[View source]
def on(type, **filters, &block) #

Generic handler registration


[View source]
def poll_answer(&block) #

Handle poll answers


[View source]
def pre_checkout_query(&block) #

Handle pre-checkout queries


[View source]
def process(update_data) #

Process raw update data (useful for webhooks)


[View source]
def remove_my_profile_photo #

Remove bot profile photo


[View source]
def removed_chat_boost(&block) #

Handle removed chat boosts


[View source]
def running : Bool #

[View source]
def set_my_profile_photo(photo, **options) #

Set bot profile photo


[View source]
def shipping_query(&block) #

Handle shipping queries


[View source]
def shutdown #

Gracefully stop the bot


[View source]
def start_polling #

Start bot in polling mode (runs in background)


[View source]
def start_webhook(path : String = "/webhook", port : Int32 | Nil = nil, host : String = "0.0.0.0", ssl : Bool | Hash(Symbol, String) | Nil = nil, secret_token : String | Nil = nil, logger : Logger | Nil = nil) #

Start bot in webhook mode


[View source]
def stop_webhook #

Stop webhook server


[View source]
def use(middleware : Middleware) #

Add middleware to the chain


[View source]
def web_app_data(&block) #

Handle web app data


[View source]
def webhook_path : String | Nil #

[View source]
def webhook_server : Webhook::Server | Nil #

[View source]