Skip to content

yegor256/telepost

Repository files navigation

EO principles respected here DevOps By Rultor.com We recommend RubyMine

Build Status Gem Version Maintainability Yard Docs

Hits-of-Code

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: ['my_channel'])
tp.spam('How are you?')

That's it.

How to contribute

Read these guidelines. Make sure you build is green before you contribute your pull request. You will need to have Ruby 2.3+ 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.