egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

[Solved] Regexps checking the whole message

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
Fill
Halfop


Joined: 18 Jan 2009
Posts: 80

PostPosted: Tue Apr 07, 2009 8:49 am    Post subject: [Solved] Regexps checking the whole message Reply with quote

Hi, I'm making a spam protection which is similar to this:

Code:

proc spam { nick uhost hand chan text } {
if {[regexp {regexp_here} $text]) { kick blah blah }
}


However it only works if someone sends one-word-message

Example:
<Fill> www.test.net
(worked and kicked me)
<Fill> visit my website www.test.net and comment it!
(didn't work)

I think I'll have to use regsub or something, but I dunno how to use it. Any help will be appreciated.

Fill


Last edited by Fill on Tue Apr 07, 2009 5:53 pm; edited 1 time in total
Back to top
View user's profile Send private message
raider2k
Op


Joined: 01 Jan 2008
Posts: 140

PostPosted: Tue Apr 07, 2009 9:08 am    Post subject: Reply with quote

never had any problems using regex before if you set it correctly, in example to yours:

Code:
if {[regexp -all -nocase -- {www\.test\.(net|com)} $text]} { kick blah blah }


would match

www.test.net
www.test.com
someone knows www.test.net?
on www.test.com there is news

unless you dont put ^ in front of the www and $ behind the (net|com) in my example its going to match either the regex alone or in a sentence.
Back to top
View user's profile Send private message
Fill
Halfop


Joined: 18 Jan 2009
Posts: 80

PostPosted: Tue Apr 07, 2009 11:49 am    Post subject: Reply with quote

thanks, worked Laughing

I had the ^ and $
Back to top
View user's profile Send private message
raider2k
Op


Joined: 01 Jan 2008
Posts: 140

PostPosted: Tue Apr 07, 2009 2:03 pm    Post subject: Reply with quote

Wink

^ and $ are limiters that define a limit where to start and where to end

by the way: add [SOLVED] to your topic if solved please Wink
Back to top
View user's profile Send private message
Fill
Halfop


Joined: 18 Jan 2009
Posts: 80

PostPosted: Tue Apr 07, 2009 5:53 pm    Post subject: Reply with quote

done Wink
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber