You are here: Big Brother Bot ForumAdd-OnsConfigurations (Moderator: MordyT)Censor plugins and regex
Pages: [1]   Go Down
  Print  
Author Topic: Censor plugins and regex  (Read 562 times) Bookmark and Share
Newbie
*
OS: Linux
Type: Renting Server, no B3
Gameservers: Urt
Posts: 2
Offline Offline
« on: December 14, 2011, 11:53:43 AM »

Hi there !

I have a problem with regexp and the censor plugins

i try to kick player who choose a name too short or with only dot

For the dot name
i have try to use this
Code:
^[.]$|^[.]{2,9}$

But it seems to doesn't work

i have replace that by that and it do what i want
Code:
<badname name=".">
  <word>.</word>
</badname>
<badname name="...">
  <regexp>[.]{2,9}</regexp>
</badname>

For the second regex i try to kick player with name who have less than 4 characters
i have try it
Code:
^[0-9a-zA-Z]{1,3}$

i have try to replace it by
Code:
<badname name="aaa">
<regexp>[0-9a-zA-Z]{3}\s</regexp> or <regexp>[0-9a-zA-Z]{3}</regexp>
</badname>
or
Code:
<badname name="aaa">
<regexp>^[0-9a-zA-Z]{3}$</regexp>
</badname>
it doesn't work. the first kick everyone, and the second is ignored

It appears that we can't specify the begin or end of a string

I have no error in bot log

Have you got any idea ?
Logged

Newbie
*
OS: Linux
Type: Home user
Gameservers: CoD
Posts: 3
Offline Offline
« Reply #1 on: December 24, 2011, 04:07:42 AM »

the B3 Doesn't respone one anything?
like !register?
Logged
Senior Dev.
*
OS: Linux
Type: Home user
Posts: 3483
Offline Offline
WWW
Support Specialty: B3-Core, UrT/SmG/BFBC2 parsers, Plugin development
« Reply #2 on: December 24, 2011, 08:07:35 AM »

the regular expression for "text composed of a single dot" is :
Code:
^\.$
or
Code:
^[.]$

the regular expression for "text composed of 2 to 9 symbols only" is :
Code:
^.{2,9}$

if you want to combine both rules into one, then the regular expression is :
Code:
^([.]|.{2,9})$
and not
Quote
^[.]$|^.{2,9})$
because the '^' symbol only has the meaning 'start of text' when used as the first character of a regexp, and the '$' symbol only has the meaning 'end of text' when used as the last character of a regexp.

I always work my regular expression using the Kodos software.


Your regular expresion
Code:
^[0-9a-zA-Z]{1,3}$
is correct, the censor plugin v2.2.1 does fail to work properly with it. That's the censor plugin's fault. Current implementation cleans player names and the cleaning process adds a space before and after the name making any regular expression using the '^$' delimiters failling.

I'm working on a new version of the Censor plugin that would not fail is such cases. It is a work in progress, but you can check what I have so far on my github repo in the BF3 branch :
 censor.py
 plugin_censor.xml
Logged

Senior Dev.
*
OS: Linux
Type: Home user
Posts: 3483
Offline Offline
WWW
Support Specialty: B3-Core, UrT/SmG/BFBC2 parsers, Plugin development
« Reply #3 on: December 25, 2011, 05:42:49 PM »

I finished working on the censor plugin.

latest plugin code for you to test :

censor.py
plugin_censor.xml
Logged

Tags:
Pages: [1]   Go Up
  Print  
 
Jump to:  


Rate this page +1 at Google Search


SimplePortal 2.3.1 © 2008-2009, SimplePortal