{"id":13693322,"url":"https://github.com/hangyas/telegram_bot","last_synced_at":"2025-10-12T22:34:22.875Z","repository":{"id":83586197,"uuid":"45257420","full_name":"hangyas/telegram_bot","owner":"hangyas","description":"(deprecated) see https://github.com/protoncr/tourmaline instead","archived":false,"fork":false,"pushed_at":"2020-04-14T17:06:11.000Z","size":131,"stargazers_count":74,"open_issues_count":0,"forks_count":16,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-10-01T01:47:57.362Z","etag":null,"topics":["bot","crystal","telegram","telegram-bot"],"latest_commit_sha":null,"homepage":"","language":"Crystal","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hangyas.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2015-10-30T14:56:25.000Z","updated_at":"2025-08-27T12:08:09.000Z","dependencies_parsed_at":"2023-07-07T21:45:13.648Z","dependency_job_id":null,"html_url":"https://github.com/hangyas/telegram_bot","commit_stats":null,"previous_names":["hangyas/telegrambot"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/hangyas/telegram_bot","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hangyas%2Ftelegram_bot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hangyas%2Ftelegram_bot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hangyas%2Ftelegram_bot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hangyas%2Ftelegram_bot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hangyas","download_url":"https://codeload.github.com/hangyas/telegram_bot/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hangyas%2Ftelegram_bot/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279013280,"owners_count":26085250,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-12T02:00:06.719Z","response_time":53,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bot","crystal","telegram","telegram-bot"],"created_at":"2024-08-02T17:01:08.421Z","updated_at":"2025-10-12T22:34:22.816Z","avatar_url":"https://github.com/hangyas.png","language":"Crystal","funding_links":[],"categories":["Third-party APIs"],"sub_categories":[],"readme":"❌❌❌❌❌❌❌❌\n\n# Deprecation Notice\n\nPlease consider using [tourmaline](https://github.com/protoncr/tourmaline) instead\n\nI'll try to keep this library compatible with the future versions of Crystal, but tourmaline is a well designed and maintained library which is superior in every way while sharing the same basics, thus I don't see any value in implementing the same improvements and fragmenting the community\n\nBug fixes are still welcomed\n\n❌❌❌❌❌❌❌❌\n\n# TelegramBot\n\n[Telegram Bot API](https://core.telegram.org/bots/api) (3.2) wrapper for Crystal\n\n## Current features\n\napi methods and types:\n\n- [x] basic message types\n- [x] stickers\n- [x] inline mode\n- [x] payments\n- [x] games\n\ngetting updates:\n\n- [x] long polling\n- [x] webhooks\n\nadditional features:\n\n- [x] white \u0026 black lists\n- [x] command handler\n\n## Usage\n\nCreate your bot by inheriting from `TelegramBot::Bot`.\n\n### Commands\n\nDefine which commands your bot handles via the `cmd` method in the `CmdHandler` module. For example, respond `world` to `/hello` and perform simple calculation with `/add`:\n\n```crystal\nrequire \"telegram_bot\"\n\nclass MyBot \u003c TelegramBot::Bot\n  include TelegramBot::CmdHandler\n\n  def initialize\n    super(\"MyBot\", TOKEN)\n\n    cmd \"hello\" do |msg|\n      reply msg, \"world!\"\n    end\n\n    # /add 5 7 =\u003e 12\n    cmd \"add\" do |msg, params|\n      reply msg, \"#{params[0].to_i + params[1].to_i}\"\n    end\n  end\nend\n\nmy_bot = MyBot.new\nmy_bot.polling\n```\n\n### Logging\n\n```crystal\nMyBot::Log.level = :debug\nMyBot::Log.backend = ::Log::IOBackend.new\n\nmy_bot = MyBot.new\nmy_bot.polling\n```\n\n### Custom handlers\n\nOverride any of the following `handle` methods to handle Telegram updates, be it [messages](https://core.telegram.org/bots/api#message), [inline queries](https://core.telegram.org/bots/api#inlinequery), [chosen inline results](https://core.telegram.org/bots/api#choseninlineresult) or [callback queries](https://core.telegram.org/bots/api#callbackquery):\n\n```crystal\ndef handle(message : Message)\n\ndef handle(inline_query : InlineQuery)\n\ndef handle(chosen_inline_result : ChosenInlineResult)\n\ndef handle(callback_query : CallbackQuery)\n\ndef handle_edited(message : Message)\n\ndef handle_channel_post(message : Message)\n\ndef handle_edited_channel_post(message : Message)\n```\n\nFor example, to echo all messages sent to the bot:\n\n```crystal\nclass EchoBot \u003c TelegramBot::Bot\n  def handle(message : Message)\n    if text = message.text\n      reply message, text\n    end\n  end\nend\n\nEchoBot.new.polling\n```\n\nOr to answer inline queries with a list of articles:\n\n```crystal\nclass InlineBot \u003c TelegramBot::Bot\n  def handle(inline_query : TelegramBot::InlineQuery)\n    results = Array(TelegramBot::InlineQueryResult).new\n\n    content = InputTextMessageContent.new \"Article details\"\n    results \u003c\u003c TelegramBot::InlineQueryResultArticle.new(\"article/1\", \"My first article\", content)\n\n    answer_inline_query(inline_query.id, results)\n  end\nend\n\nInlineBot.new.polling\n```\n\nRemember to [enable inline mode](https://core.telegram.org/bots/api#inline-mode) in BotFather to support inline queries.\n\n### Webhooks\n\nAll the examples above use the [`getUpdates`](https://core.telegram.org/bots/api#getupdates) method, constantly polling Telegram for new updates, by invoking the `polling` method on the bot.\n\nAnother option is to use the [`setWebhook`](https://core.telegram.org/bots/api#setwebhook) method to tell Telegram where to POST any updates for your bot. Note that you __must__ use HTTPS in this endpoint for Telegram to work, and you can use a self-signed certificate, which you can provide as part of the `setWebhook` method:\n\n```crystal\n# Certificate has the contents of the certificate, not the path to it\nbot.set_webhook(url, certificate)\n```\n\nAfter invoking `setWebhook`, have your bot start an HTTPS server with the `serve` command:\n\n```crystal\nbot.serve(\"0.0.0.0\", 443, \"path/to/ssl/certificate\", \"path/to/ssl/key\")\n```\n\nIf you run your bot behind a proxy that performs SSL offloading (ie the proxy presents the certificate to Telegram, and then forwards the request to your app using plain HTTP), you may skip the last two parameters, and the bot will listen for HTTP requests instead of HTTPS.\n\nWhen running your bot in `serve` mode, the bot will favour executing any methods by sending a response as part of the Telegram request, rather than executing a new request.\n\n### White/blacklists\n\nHowever it's not part of the API you can set black or white lists in the bot's constructor to filter your users by username.\n\n`whitelist`: if user is not present on the list (or doesn't have username) the message won't be handled\n\n`blacklist`: if user is present on the list the message won't be handled\n\n## Installation\n\nAdd this to your application's `shard.yml`:\n\n```yaml\ndependencies:\n  telegram_bot:\n    github: hangyas/telegram_bot\n```\n\n## Contributing\n\n__Contributing is very welcomed!__\n\n1. Fork it ( https://github.com/hangyas/TelegramBot/fork )\n2. Create your feature branch (git checkout -b my-new-feature)\n3. Commit your changes (git commit -am 'Add some feature')\n4. Push to the branch (git push origin my-new-feature)\n5. Create a new Pull Request\n\n## Contributors\n\n- [hangyas](https://github.com/hangyas) Krisztián Ádám - creator, maintainer\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhangyas%2Ftelegram_bot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhangyas%2Ftelegram_bot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhangyas%2Ftelegram_bot/lists"}