1
0
зеркало из https://github.com/glebtv/telegram-bot.git synced 2026-09-03 17:55:52 +03:00

Add server option for client to support local bot API servers

Этот коммит содержится в:
Max Melentiev
2020-11-27 18:47:47 +00:00
родитель f654071c4c
Коммит 4b9eedb5a2
4 изменённых файлов: 38 добавлений и 12 удалений

Просмотреть файл

@@ -5,7 +5,8 @@ require 'httpclient'
module Telegram
module Bot
class Client
URL_TEMPLATE = 'https://api.telegram.org/bot%<token>s/'.freeze
SERVER = 'https://api.telegram.org'.freeze
URL_TEMPLATE = '%<server>s/bot%<token>s/'.freeze
autoload :TypedResponse, 'telegram/bot/client/typed_response'
prepend Async
@@ -61,11 +62,11 @@ module Telegram
attr_reader :client, :token, :username, :base_uri
def initialize(token = nil, username = nil, **options)
def initialize(token = nil, username = nil, server: SERVER, **options)
@client = HTTPClient.new
@token = token || options[:token]
@username = username || options[:username]
@base_uri = format(URL_TEMPLATE, token: self.token)
@base_uri = format(URL_TEMPLATE, server: server, token: self.token)
end
def request(action, body = {})