Created
June 15, 2016 22:20
-
-
Save MaksimAbramchuk/f32cd9606ff7cd237488684a9fe9bec9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require ‘telegram/bot’ | |
module BotCommand | |
class Base | |
attr_reader :user, :message, :api | |
def initialize(user, message) | |
@user = user | |
@message = message | |
token = Rails.application.secrets.bot_token | |
@api = ::Telegram::Bot::Api.new(token) | |
end | |
def should_start? | |
raise NotImplementedError | |
end | |
def start | |
raise NotImplementedError | |
end | |
protected | |
def send_message(text, options={}) | |
@api.call(‘sendMessage’, chat_id: @user.telegram_id, text: text) | |
end | |
def text | |
@message[:message][:text] | |
end | |
def from | |
@message[:message][:from] | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment