{"id":13764757,"url":"https://github.com/eljojo/telegram_bot","last_synced_at":"2025-05-10T20:31:05.841Z","repository":{"id":34169755,"uuid":"38015820","full_name":"eljojo/telegram_bot","owner":"eljojo","description":"A charismatic Ruby client for Telegram's Bot API","archived":true,"fork":false,"pushed_at":"2023-09-14T21:38:37.000Z","size":50,"stargazers_count":297,"open_issues_count":23,"forks_count":78,"subscribers_count":17,"default_branch":"master","last_synced_at":"2025-05-05T10:12:58.967Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Ruby","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/eljojo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2015-06-24T23:05:33.000Z","updated_at":"2025-04-26T15:36:53.000Z","dependencies_parsed_at":"2024-01-03T06:57:04.099Z","dependency_job_id":"7385bb4e-2db6-4e0d-81c4-ceded41b31ec","html_url":"https://github.com/eljojo/telegram_bot","commit_stats":{"total_commits":52,"total_committers":13,"mean_commits":4.0,"dds":0.3076923076923077,"last_synced_commit":"5df9bed0127147074fa523f77b3e439c13a39102"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eljojo%2Ftelegram_bot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eljojo%2Ftelegram_bot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eljojo%2Ftelegram_bot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eljojo%2Ftelegram_bot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eljojo","download_url":"https://codeload.github.com/eljojo/telegram_bot/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253480380,"owners_count":21915246,"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","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":[],"created_at":"2024-08-03T16:00:28.086Z","updated_at":"2025-05-10T20:31:04.805Z","avatar_url":"https://github.com/eljojo.png","language":"Ruby","funding_links":[],"categories":["Frameworks and libraries","一般机器人（bots）","Bots"],"sub_categories":["Telegram","机器人类库","Bot Libs"],"readme":"# This gem has been archived\n\nHi everyone, I haven't touched this code in a long time and I decided it may be best to archive the repo and put it to rest.  \nI hope this project helped many people get started in bot development, I had fun working on it.\n\nI would recommend using https://github.com/atipugin/telegram-bot-ruby.\n\n# TelegramBot\n\nA charismatic ruby client for [Telegram's Bot API](https://core.telegram.org/bots).\n\nWrite your own Telegram Bot using Ruby! Yay!\n\nCurrently under heavy development.\nPlease [collaborate](https://github.com/eljojo/telegram_bot/issues/new) with your questions, ideas or problems!\n\n## Installation\n\nAdd this line to your application's Gemfile (currently under development):\n\n```ruby\ngem 'telegram_bot'\n```\n\nAnd then execute:\n\n    $ bundle\n\n## Usage\n\nHere's an example:\n\n```ruby\nrequire 'telegram_bot'\n\nbot = TelegramBot.new(token: '[YOUR TELEGRAM BOT TOKEN GOES HERE]')\nbot.get_updates(fail_silently: true) do |message|\n  puts \"@#{message.from.username}: #{message.text}\"\n  command = message.get_command_for(bot)\n\n  message.reply do |reply|\n    case command\n    when /greet/i\n      reply.text = \"Hello, #{message.from.first_name}!\"\n    else\n      reply.text = \"#{message.from.first_name}, have no idea what #{command.inspect} means.\"\n    end\n    puts \"sending #{reply.text.inspect} to @#{message.from.username}\"\n    reply.send_with(bot)\n  end\nend\n```\n\nHere's a sample output:\n\n```\n$ bundle exec ruby bot.rb\n@eljojo: greet\nsending \"Hello, José!\" to @eljojo\n@eljojo: heeeeeeeeya!\nsending \"José, have no idea what \\\"heeeeeeeeya!\\\" means.\" to @eljojo\n```\n\n![Example](http://i.imgur.com/VF8X4CQ.png)\n\n## How do I get a Bot Token\n\nTalk to the [@BotFather](https://telegram.me/botfather).\nYou can find more info [here](https://core.telegram.org/bots).\n\n![How to get Token](http://i.imgur.com/90ya4Oe.png)\n\n## What else can it do?\n\nyou can pass options to the bot initializer:\n```ruby\nbot = TelegramBot.new(token: 'abc', logger: Logger.new(STDOUT), offset: 123, timeout: 20)\n```\n\nif you don't want to start the loop, don't pass a block to ``#get_updates`` and you'll get an array with the latest messages:\n```ruby\nmessages = bot.get_updates(timeout: 30, offset: 123)\n```\n\nBecause things can go wrong sometimes with the API, there's a ``fail_silently`` option that you can pass to ``#get_updates`` like this:\n```ruby\nbot.get_updates(fail_silently: true) do |message|\n  puts message.text\nend\n```\n\nA message has several attributes:\n```ruby\nmessage = bot.get_updates.last\n\n# message data\nmessage.text # \"hello moto\"\nmessage.date # Wed, 01 Jul 2015 09:52:54 +0200 (DateTime)\n\n# reading user\nmessage.from # TelegramBot::User\nmessage.from.first_name # \"Homer\"\nmessage.from.last_name  # \"Simpson\"\nmessage.from.username   # \"mr_x\"\n\n# channel\nmessage.channel.id # 123123123 (telegram's id)\n\n# reply\nmessage.reply do |reply|\n  reply.text = \"homer please clean the garage\"\n  reply.send_with(bot)\nend\n# or\nreply = message.reply\nreply.text = \"i'll do it after going to moe's\"\nbot.send_message(reply)\n```\n\nTo send message to specific channel you could do following:\n\n```ruby\nbot = TelegramBot.new(token: '[YOUR TELEGRAM BOT TOKEN GOES HERE]')\nchannel = TelegramBot::Channel.new(id: channel_id)\nmessage = TelegramBot::OutMessage.new\nmessage.chat = channel\nmessage.text = 'Some message'\n\nmessage.send_with(bot)\n\n```\n\nAlso you may pass additional options described in [API Docs](https://core.telegram.org/bots/api#sendmessage)\n\n```ruby\nmessage.parse_mode = 'Markdown'\n```\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/eljojo/telegram_bot. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](https://www.contributor-covenant.org/) code of conduct.\n\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feljojo%2Ftelegram_bot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feljojo%2Ftelegram_bot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feljojo%2Ftelegram_bot/lists"}