• 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 Check if user is member of a specific Servergroup

Status
Not open for further replies.

good_live

Active Member
Tier III
is awesome!
V.I.P.
Contributor
Insider
Hey guys,
im still a noob in scripting ^^, but i tried to check if a user who sends a command to the bot is a member of a specific Servergroup:

Code:
        if(ev.msg.indexOf('!private') == 0){
            chatPrivate(ev.clientId, 'Test 1 ' + groupid);
            if(ev.clientServerGroups.indexOf(groupid) >= 0){
                chatPrivate(ev.clientId, 'Test 2 ' + groupid);
            }
        }
Result:
When i send "!private" to the bot i only recieve the Test 1 message.
Yes the client im sending the message from is a member of the Servergroup that is needed.
Yes the bot hast the permissions to recieve the ServerGroups.


What's wrong about this code?
Is there a better way to deal with it?
 

flyth

is reticulating splines
Staff member
Developer
Contributor
clientServerGroups is an array that looks like this:

Code:
[
    { i: 10, n: "Groupname" },
    { i: 11, n: "Groupname2" }
]

This example should list all the groups the user is in.
Code:
if (ev.clientServerGroups) {
    ev.clientServerGroups.forEach(function(group) {
        log('Group found: ' + group.n + ', #' + group.i);
    });
} else {
    log('No groups found.');
}
 

good_live

Active Member
Tier III
is awesome!
V.I.P.
Contributor
Insider
Just tried out with the new dev tools.
The ServerGroup array is empty:
Code:
{"channel":92,"clientId":39,"clientNick":"good_live","clientServerGroups":[],"clientUid":"319EN4I/TuSji8VPdK7drJtELn0=","mode":1,"msg":"test"}
and yes as the bot has ServerAdmin permissions he's able to see the Server Groups.
 

flyth

is reticulating splines
Staff member
Developer
Contributor
There are two reasons that may cause this:
1. Anti-Spam kicks in (you could whitelist the bot)
2. Delay after start (it just takes a while)

However, I will try to optimize this further. :/
 

good_live

Active Member
Tier III
is awesome!
V.I.P.
Contributor
Insider
1. The bot runs on the same server as the ts3server, so he should be whitelisted by default. However i just added the orginial ip to the whitelist aswell.
2. The instance is running now for more than 30 minutes, but the array is still empty.

I hope you can fix it :) (or tell me what im doing wrong :D)
 

flyth

is reticulating splines
Staff member
Developer
Contributor
This doesn't have anything to do with the serverquery whitelist but with the antispam that is bound to users/groups afaik (something like Ignore Anti-Flood in the permission settings).
 

good_live

Active Member
Tier III
is awesome!
V.I.P.
Contributor
Insider
Okay my fault ^^. However b_client_ignore_antiflood is set to 1 aswell and it still dont work :/
 

Raphraph

Donor
is awesome!
Contributor
Insider
-- Keeping this thread opened for future response or bug fixes --
 
Status
Not open for further replies.
Top