class

Autobot::Channels::TelegramChannel

Inherits Autobot::Channels::Channel < Reference < Object

Telegram channel using long polling via the Bot API.

Features:

  • Long polling (no webhook/public IP needed)
  • Built-in commands (/start, /reset, /help)
  • Custom commands (macros + bash scripts)
  • Media handling (photos, voice, documents)
  • Typing indicators
  • Markdown-to-Telegram HTML conversion
  • Allow list for access control

Constants

CHAT_LOG_KEEP_LINES = 100
CHAT_LOG_MAX_BYTES = 64000
DOCUMENT_CAPTION_LIMIT = 1024
EMPTY_MESSAGE_LABEL = "[empty message]"
GENERAL_TOPIC = 1_i64
GETME_MAX_ATTEMPTS = 5
GETME_RETRY_DELAY = 2.seconds
Log = ::Log.for("channels.telegram")
MAX_IMAGE_SIZE = (20 * 1024) * 1024
MEDIA_LOG_LABEL = "[media]"
MULTIPART_BOUNDARY = "----AutobotMediaBoundary"
PHOTO_CAPTION_LIMIT = 1024
POLL_TIMEOUT = 30
READ_CHUNK_SIZE = 4096
SCRIPT_OUTPUT_LIMIT = 4000
SERVICE_FIELDS = ["new_chat_members", "left_chat_member", "new_chat_title", "new_chat_photo", "delete_chat_photo", "group_chat_created", "supergroup_chat_created", "channel_chat_created", "message_auto_delete_timer_changed", "migrate_to_chat_id", "migrate_from_chat_id", "pinned_message", "forum_topic_created", "forum_topic_edited", "forum_topic_closed", "forum_topic_reopened", "general_forum_topic_hidden", "general_forum_topic_unhidden", "video_chat_scheduled", "video_chat_started", "video_chat_ended", "video_chat_participants_invited", "proximity_alert_triggered", "write_access_allowed", "boost_added", "chat_background_set"] of ::String
TELEGRAM_API_BASE = "https://api.telegram.org"
TOPIC_SEPARATOR = ':'
TYPING_INTERVAL = 4.0

Constructors

new(bus : Bus::MessageBus, token : String, allow_from : Array(String) = [] of String, proxy : String | Nil = nil, topics : Array(Int64) = [] of Int64, custom_commands : Config::CustomCommandsConfig = Config::CustomCommandsConfig.new, session_manager : Session::Manager | Nil = nil, transcriber : Transcriber | Nil = nil, cron_service : Cron::Service | Nil = nil, inbox : Media::Inbox | Nil = nil)
Source

Instance methods

send_message(message : Bus::OutboundMessage) : Nil

Send an outbound message through this channel.

Source
start

Start the channel and begin listening for messages.

Source
stop

Stop the channel and clean up resources.

Source
turn_ended(chat_id : String) : Nil
Source

Nested types