• 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 BUG found / help needed - addClientToServerGroup

Status
Not open for further replies.

luc4r4t0r

New Member
Hello SinusBot users / developers,

I need your help, because I made a small mistake in my self-coded script ir even found a Bug.
First of all I will describe my script:
It's made for Registering clients TSUUID & an associating them with Groups, which are stored in their User account on my MariaDB/ MySQL server. To do that it sends a http-request to a website coded in php, which does the actual sql-work. To this website it sends as an argument in the url (?tsuid=...) the UUID of the user and gets in exchange users group(s). Not implemented yet:{After that it removes all of the users groups...} ... and associates the groups which are assigned to that user with it.

The actual problem is the the final step of association:
the Method addClientToServerGroup()

as an example the association of an admin:

Code:
if(res.data=='admin'){
                        addClientToServerGroup(ev.clientId, '6');
                        addClientToServerGroup(ev.clientId, '7');
                        addClientToServerGroup(ev.clientId, '19');
}

Everytime the Code above is executet nothing except an error-message in the log happens.
this error-message says:

2016/11/05 17:43:42 8391d171 dc6a0699 DEBUG Found Callback PR:{a0c4e082-aac1-4167-8aeb-1e12d4a3348f}:261/SGRA
2016/11/05 17:43:42 8391d171 dc6a0699 DEBUG TS/ERR 2561 e'duplicate entry' x'' r'PR:{a0c4e082-aac1-4167-8aeb-1e12d4a3348f}:261/SGRA'
2016/11/05 17:43:42 8391d171 dc6a0699 INFO Could not add client to group: duplicate entry
2016/11/05 17:43:42 8391d171 dc6a0699 DEBUG Awaiting Callback (1): PR:{a0c4e082-aac1-4167-8aeb-1e12d4a3348f}:262/SGRA

And I think that is very strange not had any groups associated on join which should
exclude duplicate groups.

Sorry for my bad English and thank you beforehand.

LUC4R4T0R
 

luc4r4t0r

New Member
This script engine, which you are using is deprecated. Use this engine, which was integrated in the 0.9.15++: sinusbot.com/docs/scripting/
Than kyou for that recommendation but now I have another Problem:

Now I am trying out the new engine with a little code snippet, but there is an error in the function event#chat() it says the # is unexpected.
Code:
registerPlugin({
    name: 'Unknown test',
    version: '2.0',
    description: 'The Bot will register users TS3 ID at the Server Database',
    author: 'LUC4R4T0R',
    vars: {
    }
}, function(sinusbot, config) {
var event = require('event');
event#chat(msg: Message){
    Message.client.chat('lueppt');
}
});
 
Last edited:

mxschmitt

Moderator
Staff member
is awesome!
V.I.P.
is uber awesome!
Contributor
Insider
Than kyou for that recommendation but now I have another Problem:

Now I am trying out the new engine with a little code snippet, but there is an error in the function event#chat() it says the # is unexpected.
Code:
registerPlugin({
    name: 'Unknown test',
    version: '2.0',
    description: 'The Bot will register users TS3 ID at the Server Database',
    author: 'LUC4R4T0R <[email protected]>',
    vars: {
    }
}, function(sinusbot, config) {
var event = require('event');
event#chat(msg: Message){
    Message.client.chat('lueppt');
}
});
That is completely false. Here is the right coding:
Code:
registerPlugin({
    name: 'Unknown test',
    version: '2.0',
    description: 'The Bot will register users TS3 ID at the Server Database',
    author: 'LUC4R4T0R <[email protected]>',
    vars: []
}, function(sinusbot, config) {
    var event = require('event');
    event.on('chat', function(ev) {
        ev.client.chat('Hi, ' + ev.client.name() + ', you just wrote: ' + ev.text);
    });
});
 

luc4r4t0r

New Member
That is completely false. Here is the right coding:
Code:
registerPlugin({
    name: 'Unknown test',
    version: '2.0',
    description: 'The Bot will register users TS3 ID at the Server Database',
    author: 'LUC4R4T0R <[email protected]>',
    vars: []
}, function(sinusbot, config) {
    var event = require('event');
    event.on('chat', function(ev) {
        ev.client.chat('Hi, ' + ev.client.name() + ', you just wrote: ' + ev.text);
    });
});
Sorry but i think that this code is also not right. It replys this error:
Code:
2016/11/08 20:58:19 3c6d7992 775a1cd2 ERROR  Error running JS-Wrap: TypeError: 'on' is not a function
    at main (test.js:9:5)
    at ScriptRunner (<anonymous>:237:4)
    at <unknown>
 

mxschmitt

Moderator
Staff member
is awesome!
V.I.P.
is uber awesome!
Contributor
Insider
Which Sinusbot version are you using?
You need to use 0.9.15+
 

irgendwr

no longer active, "retired" staff member
is awesome!
V.I.P.
is uber awesome!
Contributor
Insider
Code:
if(res.data=='admin'){
addClientToServerGroup(ev.clientId, '6');
addClientToServerGroup(ev.clientId, '7');
addClientToServerGroup(ev.clientId, '19');
}
shouldn't you pass the group ID as an integer instead of a char?

Code:
addClientToServerGroup(ev.clientId, 6);
addClientToServerGroup(ev.clientId, 7);
addClientToServerGroup(ev.clientId, 19);
 

mxschmitt

Moderator
Staff member
is awesome!
V.I.P.
is uber awesome!
Contributor
Insider
Nope, it's ok that the is using a string for that :)
 
Last edited:
Status
Not open for further replies.
Top