class Onebot::Client

Attributes

client[R]
server[R]

Public Class Methods

new(host, token = nil, **options) click to toggle source
# File lib/onebot/client.rb, line 11
def initialize(host, token = nil, **options)
  @server = host || "http://localhost:5700"
  @token = token || options[:token]
  Excon.defaults[:headers].merge({"Authorization" => "Bearer #{@token}"}) if @token
  @client = Excon.new(@server)
end

Public Instance Methods

request(action, body = {}) click to toggle source
# File lib/onebot/client.rb, line 18
def request(action, body = {})
  pp body
  response = client.get(path: action, query: body)
  # raise self.class.error_for_response(response) if response.status >= 300
  JSON.parse(response.body)
end