Author Topic: Сan't configure BadNicknameCheck function  (Read 9198 times)

Pavel

  • Newbie
  • *
  • Posts: 2
    • View Profile
Сan't configure BadNicknameCheck function
« on: February 07, 2014, 02:28:04 PM »
Hi all, I can't configure BadNicknameCheck function to work properly.
OS: CentOS 6.5 | J3TS v. 5.0 RC 3 | TS Server v. 3.0.10.2

JTS3ServerMod_server1.cfg
ts3_server_address = 127.0.0.1
ts3_server_query_port = 10011
ts3_server_query_login = serveradmin
ts3_server_query_password = *******
ts3_virtualserver_id = -1
ts3_virtualserver_port = 9987

bot_channel_id = -1
bot_slowmode = 0
bot_check_interval = 1
bot_messages_encoding = UTF-8
bot_clientdblist_cache = 1
bot_server_query_name = TheIdealSiesta
bot_server_query_name_2 = Siesta TS Server
bot_date_pattern = dd-MM-yyyy HH:mm:ss
bot_connect_forever = 1
bot_admin_list =Xt2A**g4o***M=

bot_functions = BadNicknameCheck:bk
bk_kick = yes
bk_add_complain = no
bk_group_list =2,9
bk_group_list_mode = ignore
bk_message_mode = poke
bk_file = config/badnickname.cfg


badnickname.cfg
Code: [Select]
[b][color=red]Next symbols only: "a-z, A-Z, _" ![/color][/b][^a-zA-Z0-9_]

JTS3ServerMod_InstanceManager.cfg
bot_fulladmin_list =Xt2A**g4o***M=
bot_command_exec = 0
1.instance_enable = 1
1.instance_name = siest
1.instance_config_path = config/JTS3ServerMod_server1.cfg
1.instance_logfile_path = JTS3ServerMod_server1.log
1.instance_csvloginlog_path = JTS3ServerMod_server1_login.csv

So, I want to make that bot kicks all users, who have a nickname contains extra characters, except English uppercase and lowercase letters, numbers and the underscore character (rule [^ a-zA-Z0-9_] I checked on the Open Regular Expression tester, as describe in readme, it works).

But on practise, when some user is connected, which has extra characters other than the above, bot will do not anything to him, although should kick user with a text warning. Tried different options after each change in the config did 'java-jar JTS3ServerMod.jar-updateconfig', then
'screen -d -m -S ts3bot java -jar JTS3ServerMod.jar', i see that bot successfully connects, on request '!botinfo' says that everything is OK, all need access rights given to him, but I did not BadNickNameCheck work.

Please, help me with advice - what's wrong with my configs and how to make badnickname kick works?
Thanks.

Stefan1200

  • Administrator
  • *****
  • Posts: 2244
    • View Profile
Re: Сan't configure BadNicknameCheck function
« Reply #1 on: February 07, 2014, 08:43:56 PM »
Well, that is not a bug of the bot, that's just the little bit different implementation of regex matching in the Java programming language. Java always matches the whole String (in this case the whole nickname). PHP or JavaScript implementations don't have to.

Java is reading your regex while matching this way:
^[^a-zA-Z0-9_]$
And that way it works different also in PHP or JavaScript.

Currently after searching 30 minutes a way to find a better regex for your usage I stopped and just find a small workaround, which is already working for you.

Just write the following two lines into your badnickname.cfg below your kick message line:
Code: [Select]
.*\W.*
.*\s.*

It kicks if the following is found:
- A whitespace character: [ \t\n\x0B\f\r]
- A non-word character: [^\w]
Definition of word character: [a-zA-Z_0-9]

Pavel

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Сan't configure BadNicknameCheck function
« Reply #2 on: February 07, 2014, 09:35:30 PM »
Ok, now it's clear - my own mistake, thank You very much for help and fast feedback!
All works fine!
« Last Edit: February 07, 2014, 10:13:48 PM by Pavel »