Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save MaksimAbramchuk/f32cd9606ff7cd237488684a9fe9bec9 to your computer and use it in GitHub Desktop.
Save MaksimAbramchuk/f32cd9606ff7cd237488684a9fe9bec9 to your computer and use it in GitHub Desktop.
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