• 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.

YouTube Search does not work.

Band -.-

Active Member
I do not know if this is the right place to report errors of this plugins I have SinusBot 1.0.0-alpha.4-661f4ab at the moment use the plugins youtube search via command! Youtube does not work and throws this error.

Captura.PNG

SinusBot 1.0.0-alpha.4-661f4ab /TS Client teamspeak3 3.2.1 /Server teamspeak3 3.5.1
System: Debian 8 Jessie
 

olokos

Insider
Insider
Ping failed is unrelated to this
This error comes up because of changes in script engine made in alpha. sinusbot class doesn't exist anymore
I tried fixing this with following change as per documentation
Code:
const http = require("http")
            http.simpleRequest({
                method: options.method,
                url: options.url,
                timeout: 6000,
                headers: options.headers
            }, function (err, res) {
                if (err || res.statusCode !== 200) {
                    engine.log('Request error [{error}] Code: [{code}] Data: [{data}]'.format({
                        error: err,
                        data: res.data,
                        code: res.statusCode
                    }));
                    options.error_callback(err);
                } else {
                    var json = JSON.parse(res.data);
                    options.callback(json);
                }
            });

but this results in
Code:
sty 18 20:44:38 urserver.lol sinusbot[5116]: 2019/01/18 20:44:38 dfc7bbde ff9121dd PLUGIN missing privilege for module http
sty 18 20:44:38 urserver.lol sinusbot[5116]: 2019/01/18 20:44:38 dfc7bbde ff9121dd PLUGIN error on callback func: Uncaught exception: TypeError: Cannot read property 'simpleRequest' of undefined
sty 18 20:44:38 urserver.lol sinusbot[5116]: at youtube:333:17
sty 18 20:44:38 urserver.lol sinusbot[5116]:               http.simpleRequest({
sty 18 20:44:38 urserver.lol sinusbot[5116]:                    ^
sty 18 20:44:38 urserver.lol sinusbot[5116]: Stack trace: TypeError: Cannot read property 'simpleRequest' of undefined
sty 18 20:44:38 urserver.lol sinusbot[5116]:     at Object.getJSON (youtube:333:18)
sty 18 20:44:38 urserver.lol sinusbot[5116]:     at Object.search (youtube:365:25)
sty 18 20:44:38 urserver.lol sinusbot[5116]:     at Object.callback (youtube:549:33)
sty 18 20:44:38 urserver.lol sinusbot[5116]:     at youtube:1206:30
@irgendwr
 

irgendwr

no longer active, "retired" staff member
is awesome!
V.I.P.
is uber awesome!
Contributor
Insider
You need to specify requiredModules in registerPlugin.

...
requiredModules: ["http"],
...
 

olokos

Insider
Insider
Right, I did that, but now there's another error that I'm trying to figure out
Code:
sty 19 00:26:51 urserver.lol sinusbot[13218]: 2019/01/19 00:26:51 dfc7bbde ff9121dd INFO   PRIVATE-CHAT [olokos] play garrix
sty 19 00:26:52 urserver.lol sinusbot[13218]: 2019/01/19 00:26:52 dfc7bbde ff9121dd PLUGIN error on callback func: Uncaught exception: Error: function must be called on original object
sty 19 00:26:52 urserver.lol sinusbot[13218]: at youtube:494:28
sty 19 00:26:52 urserver.lol sinusbot[13218]:                       options.chat(options.text);
sty 19 00:26:52 urserver.lol sinusbot[13218]:                               ^
sty 19 00:26:52 urserver.lol sinusbot[13218]: Stack trace: Error: function must be called on original object
sty 19 00:26:52 urserver.lol sinusbot[13218]:     at parse_msg (youtube:494:29)
sty 19 00:26:52 urserver.lol sinusbot[13218]:     at Object.msg (youtube:501:25)
sty 19 00:26:52 urserver.lol sinusbot[13218]:     at msg (youtube:892:29)
sty 19 00:26:52 urserver.lol sinusbot[13218]:     at Object.video_message (youtube:941:25)
sty 19 00:26:52 urserver.lol sinusbot[13218]:     at Object.callback (youtube:574:63)
sty 19 00:26:52 urserver.lol sinusbot[13218]:     at youtube:349:29

I see there was some dirty stuff done to get it working initially and I think it's now becoming an issue, but I can't find the right solution

Here's the code I made (not much of a difference but this time I'm using simpleRequest as intended.
https://pastebin.com/kYqsz7d7

flyth has mentioned res.data.toString() but I'm not that fluent in javascript to figure out which function should be replace

We were speaking about this bit of code:
Code:
            const http = require("http")
            http.simpleRequest({
                method: options.method,
                url: options.url,
                timeout: 6000,
                headers: options.headers
            }, function (err, res) {
                if (err || res.statusCode !== 200) {
                    engine.log('Request error [{error}] Code: [{code}] Data: [{data}]'.format({
                        error: err,
                        code: res.statusCode,
                        data: res.data
                    }));
                    options.error_callback(err);
                } else {
                    var json = JSON.parse(res.data);
                    options.callback(json);
                }
            });
 

flyth

is reticulating splines
Staff member
Developer
Contributor
Line 503: chat: options.client.chat => chat: options.client.chat.bind(options.client)
Line 514: chat: options.channel.chat => chat: options.channel.chat.bind(options.channel)
Line 524: chat: options.backend.chat => chat: options.backend.chat.bind(options.backend)

Native functions need to be called on their objects - you can't just take a function off it's object anymore like in that code where "chat" was taken away. I've not checked if that happens on other lines as well though.
 

olokos

Insider
Insider
@flyth
I love you mate, that did the trick. Those lines that you listed were the only occurences and the script works perfect once again!
Should I create another topic with fixed script in resources or post it at latest post in existing thread?
 

flyth

is reticulating splines
Staff member
Developer
Contributor
I think posting it to the existing thread would be best. If the author doesn't fix it, at least people can fix it themselves for now. Thanks!
 
Top