Ruby Telegram Client
Telepost is a simple gateway to Telegram, which can post messages and respond to primitive requests.
First, get your token from @BotFather.
Then, install it:
gem install telepost
Then, use it like this:
require 'telepost'
tp = Telepost.new('..token..')
Thread.start do
tp.run do |chat, msg|
tp.post(chat, 'Thanks for talking to me!')
end
end
tp.post(12345, 'How are you?', 'How are you doing?')
All lines you provide to the post() method will be concatenated
with a space between them.
Or you can pre-configure it to talk to certain list of chats. Your bot has to be an admin of the channel, in order to post there. Here is how you "spam":
tp = Telepost.new('..token..', chats: [12345])
tp.spam('How are you?')
You can also attach a file (sent as a Telegram document). The
file argument accepts a path or an already-open IO/File,
and caption: is optional:
tp = Telepost.new('..token..')
tp.attach(12345, '/tmp/dump.sql', caption: 'Today is dump')
That's it.
How to contribute
Read these guidelines. Make sure your build is green before you contribute your pull request. You will need to have Ruby 3.2+ and Bundler installed. Then:
bundle update
bundle exec rake
If it's clean and you don't see any error messages, submit your pull request.