Class: Luogu::AIUI

Inherits:
Base
  • Object
show all
Defined in:
lib/luogu/aiui.rb

Class Method Summary collapse

Methods inherited from Base

#config, #logger

Class Method Details

.request(text: nil, uid: SecureRandom.hex(16)) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/luogu/aiui.rb', line 11

def request(text: nil, uid: SecureRandom.hex(16))
  response = HTTP.post(config.request_url, json: {
    appid: config.id,
    appkey: config.key,
    uid: uid,
    text: text
  })
  if response.code == 200
    config.parse.call(response)
  else
    raise RequestError, response.body.to_s
  end
end