• If you need help or want to discuss things, you now can also join us on our Discord Server!
  • A first preview of the unlimited version of SinusBot can be found in the Upcoming Changes thread. A version for Windows will follow, but we don't have a release date, yet.

EN Help with http response

CaS5

New Member
I'm making an attempt at fixing the steam servers information script that was broken with the http update. I've already fixed the obsolete sinusbot.http code, but I'm returning an undefined response. I'm assuming it's because I'm using simpleRequest? Do I need to use simpleRequestCallback? It's returning engine.log('Response Undefined');

JavaScript:
    function update() {
        const engine = require('engine');
        const http = require('http');
        const backend = require('backend');
        if (backend.isConnected()){
            http.simpleRequest({
              "method": "GET",
              "url":    "https://crowbar.steamstat.us/Barney",
              "timeout": 6000,
              "headers": {"User-Agent": "curl/7.47.0"}
            }, function (error, response) {
                if (typeof response != 'undefined' && response.statusCode == 200) {
                    var serverInformation = JSON.parse(response.data);
                    if (typeof serverInformation != 'undefined') {
                        if (typeof serverInformation.error != 'undefined') {
                            engine.log("API Error: " + serverInformation.error);
                        }
                        processServers(config, serverInformation);
                    } else {
                  engine.log("ERROR: invalid response: " + response.data);
                }
              }else{
                if (typeof response != 'undefined'){
                    engine.log('Response Undefined');
                }else{
                    engine.log('Response ERROR: '+response.statusCode);
                }
              }
            });
        }
    }
 

DrWarpMan

Well-Known Member
Contributor
Insider
I'm making an attempt at fixing the steam servers information script that was broken with the http update. I've already fixed the obsolete sinusbot.http code, but I'm returning an undefined response. I'm assuming it's because I'm using simpleRequest? Do I need to use simpleRequestCallback? It's returning engine.log('Response Undefined');

JavaScript:
    function update() {
        const engine = require('engine');
        const http = require('http');
        const backend = require('backend');
        if (backend.isConnected()){
            http.simpleRequest({
              "method": "GET",
              "url":    "https://crowbar.steamstat.us/Barney",
              "timeout": 6000,
              "headers": {"User-Agent": "curl/7.47.0"}
            }, function (error, response) {
                if (typeof response != 'undefined' && response.statusCode == 200) {
                    var serverInformation = JSON.parse(response.data);
                    if (typeof serverInformation != 'undefined') {
                        if (typeof serverInformation.error != 'undefined') {
                            engine.log("API Error: " + serverInformation.error);
                        }
                        processServers(config, serverInformation);
                    } else {
                  engine.log("ERROR: invalid response: " + response.data);
                }
              }else{
                if (typeof response != 'undefined'){
                    engine.log('Response Undefined');
                }else{
                    engine.log('Response ERROR: '+response.statusCode);
                }
              }
            });
        }
    }
I tried to fix this script 3 months ago, and I have also discussed this with Sinusbot staff and we came to an end, that the site is using cloudflare, and that is the reason why do you get undefined, because cloudflare blocks your IP address. For some reason, we can open the page normally, but not through a VPS (like mine or yours I guess).

TL;DR
"You can't do much about a cloudflare ban/block, except contacting them" - said @irgendwr 3 months ago :D
 
Top