Seuntjies DiceBot

DiceBot => Programmer Mode => Topic started by: alerin on October 15, 2019, 10:24:23 pm

Title: HTTP Request
Post by: alerin on October 15, 2019, 10:24:23 pm
Hello,

I need make an http request at DiceBot code, i tried this:

hc = require('httpclient').new()
res = hc:get('https://freebitco.in/cf_stats_public/?f=updating2')
if res.body then
  print(res.body)
else
  print(res.err)
end

But returns this error:

LUA ERROR!!
Index was outside the bounds of the array.

I downloaded the httpclient on it: https://github.com/lusis/lua-httpclient/tree/master/src

Please help

Thank you.
Title: Re: HTTP Request
Post by: Seuntjie on October 22, 2019, 08:19:42 pm
Hello,

I need make an http request at DiceBot code, i tried this:

hc = require('httpclient').new()
res = hc:get('https://freebitco.in/cf_stats_public/?f=updating2')
if res.body then
  print(res.body)
else
  print(res.err)
end

But returns this error:

LUA ERROR!!
Index was outside the bounds of the array.

I downloaded the httpclient on it: https://github.com/lusis/lua-httpclient/tree/master/src

Please help

Thank you.

I'm not sure the version of lua the bot uses supports the require function. If you have the lua files for the http client, try using dofile with the file it references instead. I can't guarantee it'll work though.