Class: CQHttp::Utils

Inherits:
Object
  • Object
show all
Defined in:
lib/Bot/Utils.rb

Class Method Summary collapse

Class Method Details

.httpPost(*args) ⇒ Object



8
9
10
11
12
13
14
15
16
# File 'lib/Bot/Utils.rb', line 8

def httpPost(*args)
  url = URI.parse args[0]
  req = Net::HTTP::Post.new(url.path, { 'Content-Type' => 'application/json' })
  req.body = args[1]
  res = Net::HTTP.start(url.hostname, url.port) do |http|
    http.request(req)
  end
  res.body
end

.log(time, status, str) ⇒ Object



4
5
6
# File 'lib/Bot/Utils.rb', line 4

def log(time, status, str)
  puts "[#{time.strftime('%Y-%m-%d %H:%M:%S')}][#{status}]: #{str}"
end