зеркало из
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
Этот коммит содержится в:
@@ -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 = {})
|
||||
|
||||
Ссылка в новой задаче
Block a user