{"id":13764748,"url":"https://github.com/ssut/telegram-rb","last_synced_at":"2025-05-10T20:31:04.852Z","repository":{"id":34588891,"uuid":"38536023","full_name":"ssut/telegram-rb","owner":"ssut","description":"A Ruby wrapper that communicates with the Telegram-CLI.","archived":true,"fork":false,"pushed_at":"2018-12-06T15:23:09.000Z","size":93,"stargazers_count":80,"open_issues_count":5,"forks_count":23,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-05-10T16:12:05.916Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://github.com/ssut/telegram-rb","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/ssut.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}},"created_at":"2015-07-04T14:13:50.000Z","updated_at":"2024-04-11T01:50:46.000Z","dependencies_parsed_at":"2022-08-29T09:20:22.214Z","dependency_job_id":null,"html_url":"https://github.com/ssut/telegram-rb","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ssut%2Ftelegram-rb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ssut%2Ftelegram-rb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ssut%2Ftelegram-rb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ssut%2Ftelegram-rb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ssut","download_url":"https://codeload.github.com/ssut/telegram-rb/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:27.916Z","updated_at":"2025-05-10T20:31:03.648Z","avatar_url":"https://github.com/ssut.png","language":"Ruby","funding_links":[],"categories":["一般机器人（bots）","Bots"],"sub_categories":["机器人类库","Bot Libs"],"readme":"# Telegram API for Ruby!\n\n[![DUB](https://img.shields.io/dub/l/vibe-d.svg)](http://opensource.org/licenses/MIT)\n[![Gem Version](https://badge.fury.io/rb/telegram-rb.svg)](http://badge.fury.io/rb/telegram-rb)\n[![Code Climate](https://codeclimate.com/github/ssut/telegram-rb/badges/gpa.svg)](https://codeclimate.com/github/ssut/telegram-rb)\n[![Inline docs](http://inch-ci.org/github/ssut/telegram-rb.svg?branch=master)](http://inch-ci.org/github/ssut/telegram-rb)\n\n[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/ssut/telegram-rb?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge)\n\nA Ruby wrapper that communicates with the [Telegram-CLI](https://github.com/vysheng/tg).\n\n## Installation\n\n### Requirements\n\n* You need to install the [Telegram-CLI](https://github.com/vysheng/tg) version 1.3.0 or higher first.\n\n### RubyGems\n\nIn order to use the telegram-rb you will need to install the gem (either manually or using Bundler), and require the library in your Ruby application:\n\n```bash\n$ gem install telegram-rb\n```\n\nor in your `Gemfile`: \n\n```ruby\n# latest stable\ngem 'telegram-rb', require: 'telegram'\n\n# or track master repo\ngem 'telegram-rb', github: 'ssut/telegram-rb', require: 'telegram'\n```\n\n## Usage\n\nThe library uses EventMachine, so the logic is wrapped in `EM.run`.\n\n```ruby\n# When using Bundler, let it load all libraries\nrequire 'bundler' \nBundler.require(:default) \n\n# Otherwise, require 'telegram', which will load its dependencies\n# require 'telegram'\n\nEM.run do\n  telegram = Telegram::Client.new do |cfg, auth|\n    cfg.daemon = '/path/to/tg/bin/telegram-cli'\n    cfg.key = '/path/to/tg/tg-server.pub'\n    cfg.config_file = '/path/to/config' # optional, default file will be used if not set\n    cfg.profile = 'user2' # optional, the profiles must be configured in ~/.telegram-cli/config\n    cfg.logger = Logger.new(STDOUT) # optional, default logger will be created if not set\n\n    # optional properties, could be used for authorization/registration telegram accounts\n    auth.phone_number = '\u003cvalid phone number\u003e'\n    auth.confirmation_code = -\u003e { '\u003creceived confirmation code via sms or call\u003e' }\n    auth.register = { # required in case with registration new telegram account\n      first_name: '\u003cuser first name\u003e',\n      last_name: '\u003cuser last name\u003e'\n    }\n  end\n\n  telegram.connect do\n    # This block will be executed when initialized.\n    \n    # See your telegram profile\n    puts telegram.profile\n\n    telegram.contacts.each do |contact|\n      puts contact\n    end\n    \n    telegram.chats.each do |chat|\n      puts chat\n    end\n    \n    # Event listeners\n    # When you've received a message:\n    telegram.on[Telegram::EventType::RECEIVE_MESSAGE] = Proc.new do |event|\n      # `tgmessage` is TelegramMessage instance\n      puts event.tgmessage\n    end \n\n    # When you've sent a message:\n    telegram.on[Telegram::EventType::SEND_MESSAGE] = Proc.new do |event|\n      puts event\n    end\n\n    # When connection is closed:\n    telegram.on_disconnect = Proc.new do\n      puts 'Connection with telegram-cli is closed'\n    end\n  end\nend\n```\n\n### Documentation\n\n**You can check documentation from [here](http://www.rubydoc.info/github/ssut/telegram-rb)!**\n\nMy goal is to have the code fully documentated for the project, so developers can use this library easily!\n\n## Coverage (TODO)\n\n- [ ] Messaging/Multimedia\n    - [x] Send typing signal to specific user or chat\n    - [x] Send a message to specific user or chat\n    - [x] Send an image to specific user or chat\n    - [x] Send a video to specific user or chat\n    - [x] Mark as read all received messages\n    - [ ] Download an image of someone sent\n    - [ ] Forward a message to specific user\n    - [ ] Set profile picture\n- [ ] Group chat options\n    - [x] Add a user to the group\n    - [x] Remove a user from the group\n    - [x] Leave from the group\n    - [x] Create a new group chat\n    - [ ] Set group chat photo\n    - [ ] Rename group chat title\n- [ ] Search\n    - [ ] Search for specific message from a conversation\n    - [ ] Search for specific message from all conversions\n- [ ] Secret chat\n    - [x] Reply message in secret chat\n    - [ ] Visualize of encryption key of the secret chat\n    - [ ] Create a new secret chat\n- [ ] Stats and various info\n    - [x] Get user profile\n    - [x] Get chat list\n    - [x] Get contact list\n    - [ ] Get history and mark it as read\n- [ ] Card\n    - [ ] export card\n    - [ ] import card\n\n## Contributing\n\nIf there are bugs or things you would like to improve, fork the project, and implement your awesome feature or patch in its own branch, then send me a pull request here!\n\n## License\n\n**telegram-rb** is licensed under the MIT License.\n\n```\nThe MIT License (MIT)\n\nCopyright (c) 2015 SuHun Han\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fssut%2Ftelegram-rb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fssut%2Ftelegram-rb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fssut%2Ftelegram-rb/lists"}