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

[Scripting] Empty configs / No events captured

ScriptUser

Active Member
Hello, i'm starting to make some scripts, read some manuals and faced several problems.
Using stable 0.10 and tried beta 0.13 versions.
In native dev script when i'm using:
JavaScript:
engine.log('DEV/Config', console)
it returns:
JavaScript:
2018/02/17 15:34:13 f06ed557 2a09aa05 PLUGIN dev       :30   Engine LOG: DEV/Config {"1":0,"adminUids":"Lgp3Rn9c7VUlnHh8QIrOEimxUsY="}
Even if i delete vars from source code, it anyway (!!!) gives me the same result. BUT in the web the config became empty as expected.
I've tried to add var "test", after several restarts the result is this one:
Code:
2018/02/17 15:34:13 f06ed557 2a09aa05 PLUGIN dev       :30   Engine LOG: DEV/Config {"1":0,"2":0,"adminUids":"Lgp3Rn9c7VUlnHh8QIrOEimxUsY="}
So, i can't even debug events ON because var names are incorrect and i don't undestand from where they are read. If i edit the

I've tried to install Bad_NickName_Check and the same strange results:
Code:
2018/02/17 15:34:13 f06ed557 2a09aa05 INFO   Loading script Bad_Nickname_Check
2018/02/17 15:34:13 f06ed557 2a09aa05 PLUGIN Bad_Nickname_Check:42   bad nickname config
2018/02/17 15:34:13 f06ed557 2a09aa05 PLUGIN Bad_Nickname_Check:43   {
2018/02/17 15:34:13 f06ed557 2a09aa05 PLUGIN Bad_Nickname_Check:43       "1": 0
2018/02/17 15:34:13 f06ed557 2a09aa05 PLUGIN Bad_Nickname_Check:43   }

Also, it seems not capturing "chat" event, but successfully captures "clientMove" event.
What i'm doing wrong and how to fix and start coding without bugs?
 

flyth

is reticulating splines
Staff member
Developer
Contributor
engine.log('DEV/Config', console)
What is that console variable there? Did you mean config?

Even if i delete vars from source code, it anyway (!!!) gives me the same result.
Those vars get saved when you press "Save" in the webinterface. Whatever is stored at the time the script gets started, will be in your config variable. Config does not get sanitized at all.

So, i can't even debug events ON because var names are incorrect and i don't undestand from where they are read. If i edit the
I don't get that what you're trying to do there.

"chat" should work just fine. How about you post what you've got and we can have a look at it? Also, please only use 0.13.x so we're on the same page.
 

ScriptUser

Active Member
Sorry, configs works now, it seems that it is showing 1:0, 2:0 when the variable is not set (empty value).
But events are still unavailable for me to hook.
I've enabled Dev and ShowCase plugin.
Thats part of log:
Code:
2018/02/17 16:43:25 f06ed557 2a09aa05 PLUGIN [dev] DEV/Logging enabled
2018/02/17 16:43:25 f06ed557 2a09aa05 PLUGIN dev       :41   adminUids: [Lgp3Rn9c7VUlnHh8QIrOEimxUsY=]
2018/02/17 16:43:25 f06ed557 2a09aa05 PLUGIN REGISTER / dev / chat
2018/02/17 16:43:25 f06ed557 2a09aa05 PLUGIN REGISTER / dev / api:reload
2018/02/17 16:43:25 f06ed557 2a09aa05 INFO   Loading script showcase
2018/02/17 16:43:25 f06ed557 2a09aa05 PLUGIN showcase  :9    [b]starting API ShowCase[/b]
2018/02/17 16:43:25 f06ed557 2a09aa05 PLUGIN REGISTER / showcase / chat
2018/02/17 16:43:25 f06ed557 2a09aa05 PLUGIN REGISTER / showcase / poke
2018/02/17 16:43:25 f06ed557 2a09aa05 PLUGIN REGISTER / showcase / timer
2018/02/17 16:43:25 f06ed557 2a09aa05 PLUGIN REGISTER / showcase / clientServergroupAdd
2018/02/17 16:43:25 f06ed557 2a09aa05 PLUGIN REGISTER / showcase / clientServergroupDel
2018/02/17 16:43:25 f06ed557 2a09aa05 PLUGIN REGISTER / showcase / talkerCount
2018/02/17 16:43:25 f06ed557 2a09aa05 PLUGIN REGISTER / showcase / botMove
2018/02/17 16:43:25 f06ed557 2a09aa05 PLUGIN REGISTER / showcase / connect
2018/02/17 16:43:25 f06ed557 2a09aa05 PLUGIN REGISTER / showcase / disconnect
2018/02/17 16:43:25 f06ed557 2a09aa05 PLUGIN REGISTER / showcase / clientMove
2018/02/17 16:43:25 f06ed557 2a09aa05 PLUGIN REGISTER / showcase / clientJoin
2018/02/17 16:43:25 f06ed557 2a09aa05 PLUGIN REGISTER / showcase / nick
2018/02/17 16:43:25 f06ed557 2a09aa05 PLUGIN REGISTER / showcase / track
2018/02/17 16:43:25 f06ed557 2a09aa05 PLUGIN REGISTER / showcase / record
2018/02/17 16:43:25 f06ed557 2a09aa05 PLUGIN REGISTER / showcase / channelCreate
2018/02/17 16:43:25 f06ed557 2a09aa05 PLUGIN REGISTER / showcase / channelUpdate
2018/02/17 16:43:25 f06ed557 2a09aa05 PLUGIN REGISTER / showcase / channelMove
2018/02/17 16:43:25 f06ed557 2a09aa05 PLUGIN REGISTER / showcase / channelDelete

The part of source is:
JavaScript:
registerPlugin({
    name: 'API Showcase',
    version: '1.0',
    description: 'This just demonstrated many of the available/exposed function calls.',
    author: 'Michael Friese <[email protected]>',
    vars: {}
}, function(sinusbot, config) {
    var engine = require('engine')
    engine.log('starting API ShowCase')
    sinusbot.on('chat', function(ev) {
    engine.log('chat event')
    engine.log(ev)
So, it is working, event is registered and should be logged.
But when i'm doing any events - private chat message, poking, adding bot to group etc - the only log is this:
Code:
2018/02/17 16:52:53 f06ed557 2a09aa05 INFO   PRIVATE-CHAT [Ergamon] 123
2018/02/17 16:52:59 f06ed557 2a09aa05 INFO   TS |INFO    |ClientUI      |1  |Ignored poke by Ergamon: 123
I switched off all the plugins except showcase but the situation was the same. In console it prints that plugin is started and there are no errors.

After short investigation further i found that in plugin alonemode (2.0) is triggering at events! I've registered there 'chat' event it correctly shows me chat and its default clientMove event too. What am I doing wrong?
UPD I've found where is the problem.
This code used in most plugins is not working:
JavaScript:
sinusbot.on('chat', ...)
To trigger events it is required to have
JavaScript:
var event = require('events')
event.on('chat', ...)

I think you should fix this in all default plugins because sinusbot.on probably can only handle connect/disconnect events.
 
Last edited:

flyth

is reticulating splines
Staff member
Developer
Contributor
Damn, is that old stuff still bundled with the bot?
All sinusbot.on(...) is from the old deprecated script engine. You should only use event.on(), where event is imported via require('event').
I'll check that later and remove/update those old scripts.

You can find the documentation for the new engine version here.
 

ScriptUser

Active Member
It seems, that i had some old version of sinusbot downloaded probably in November.
But it is not asking for any updates.
At download page the actual link is on beta-version.
Thanks anyway, now I can start coding!)

p.s. Beta version doesn't have all plugins that were with stable. At least, you should add dev/showcase plugins since they are useful for those like me.
 

ScriptUser

Active Member
One more question about API.
I did not found the ability to delete channel, only create and update.
But how to delete channel like in badchan old script?
 

ScriptUser

Active Member
Also, i've found that event 'load' is never fired as well as 'talkerCount'.
Would be nice if 'load' is fired after the script is loaded and reloaded too, so it is possible to make rechecks with new config.
I don't really understand, how is working talkerCount but i'm entering/leaving the channel where the bot is sitting and nothing is happening, while I expect this event to be triggered.
 
Top