
Security News
CISA Rebuffs Funding Concerns as CVE Foundation Draws Criticism
CISA denies CVE funding issues amid backlash over a new CVE foundation formed by board members, raising concerns about transparency and program governance.
Ruby wrapper for Telegram's Bot API.
Add this line to your application's Gemfile:
gem 'telegram-ruby'
And then execute:
$ bundle
Or install it yourself as:
$ gem install telegram-ruby
All types and methods of the Telegram Bot API 3.5 are supported.
First of all you need create your own bot and obtain a token
Then you can configure Telegram::Bot in config/initializers/telegram.rb
require 'telegram/bot'
Telegram::Bot.configure do |conf|
conf.token = 'Here your token'
conf.raise_exceptions = false #By default true
conf.name = '@MyBot'
conf.botan_token = 'Botan token' #If using botan.io
end
You can use Telegram::Bot::Api stand alone
api = Telegram::Bot::Api.new([Token key])
api.getMe
Or by using Telegram::Bot::Client to receive updates from Telegram
Create handler class
class MyHandler
include Telegram::Bot::ClientAccessors
# this method will be called if /test string was found in message text
def cmd_test
api.sendMessage(message.chat.id, 'Yes, it is test')
end
# this method will be called if no command found
def cmd_fallback
# log message
end
end
In your controller add
def create
client = Telegram::Bot::Client.new(MyHandler)
client.handle(params)
end
In your handler you can use helper accessors
api - Telegram::Bot::Api instance
update - This object represents an incoming update.
message - This object represents a message.
command - Current command if found in message text (without prefix cmd_)
botan - This object represents a botan integration
From url
api.sendPhoto([Chat id], [Url to image], {caption: 'Image caption'})
From server
api.sendPhoto([Chat id], Faraday::UploadIO.new([patg to image], 'image/png', 'my_image.png'), {caption: 'Image caption'})
The most advanced analytics for your Telegram bot. See more information on botan.io
Usage
botan = Telegram::Bot::Botan([appmetrica-token])
uid = 123
message = 'text'
name = 'search'
botan.track(uid, message, name)
Bug reports and pull requests are welcome on GitHub at https://github.com/Stajor/telegram-ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
The gem is available as open source under the terms of the MIT License.
FAQs
Unknown package
We found that telegram-ruby demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISA denies CVE funding issues amid backlash over a new CVE foundation formed by board members, raising concerns about transparency and program governance.
Product
We’re excited to announce a powerful new capability in Socket: historical data and enhanced analytics.
Product
Module Reachability filters out unreachable CVEs so you can focus on vulnerabilities that actually matter to your application.