class Telegram::Bot::Botan

Constants

API_URL

Public Class Methods

new(token = nil) click to toggle source
# File lib/telegram/bot/botan.rb, line 5
def initialize(token = nil)
  @token = token || Telegram::Bot.configuration.botan_token
end

Public Instance Methods

track(uid, message, name) click to toggle source
# File lib/telegram/bot/botan.rb, line 9
def track(uid, message, name)
  begin
    response = Faraday.new(url: API_URL).post do |req|
      req.url "/track?token=#{@token}&uid=#{uid}&name=#{name}"
      req.headers['Content-Type'] = 'application/json'
      req.body = JSON.dump({text: message})
    end

    JSON.parse(response.body)
  rescue => e
    raise Telegram::Bot::BotanError.new(e.message)
  end
end