Code: Select all
regexp -options { pattern } text -> match
Code: Select all
regexp -options { pattern } text -> match
Code: Select all
#-----------------------------------------------------------------------------------
---------------------------------#
# BAD NICK SCRIPT BY RANA USMAN #
#--------------------------------------------------------------------------------------------------------------------#
#Author : RANA USMAN
#Email : coolguy_rusman@yahoo.com
#URL : www.ranausman.tk
#Version : 1.2
#Catch me on UNDERNET @ #VASTEYE my nick is ^Rana^Usman
###################
# Version History #
###################
#The version before was not supporting Wildcards like ** ?? etc etc
#So now in this version you can use wild cards too
###########################
#- CONFIGURATION SECTION -#
###########################
########################################################################################
#- Enter the Bad nicks Below on which you want your bot to BAN (Wild Cards Supported)-#
########################################################################################
set bnick {
"somenick"
"badnick"
}
#########################################################################################################
## SET The channel on which you want this script to work ##
## Channels Separted by space...and if you want this script to work on all channels leave it as "" ##
#########################################################################################################
set bchan ""
################
#- Set Reason -#
################
set kickreason "4Bad Nick Detected"
#--------------------------------------------------------------------------------------------------------------------#
# SCRIPT STARTS FROM HERE...MAKE IT BETTER WITH YOUR SKILLS IF YOU CAN.I DONT RESTRICT YOU TO NOT TO TOUCH CODE! #
#--------------------------------------------------------------------------------------------------------------------#
bind join - * join:RanaUsman
bind nick - * nick:tvrsh
proc nick:tvrsh {nick uhost hand chan newnick} {
join:RanaUsman $newnick $uhost $hand $chan
}
proc join:RanaUsman {nick uhost hand chan} {
global bnick bchan kickreason temp
regsub -all -- {(.)\1+} $nick {\1} nick2
if {[lsearch -nocase $bchan $chan] || ![llength $bchan]} {
set temp 0
foreach i [string tolower $bnick] {
regexp -options { i } text -> match
if {[string match -nocase *$match* $nick2] && ![string match -nocase *guest* $nick2]} {
set badpart $match
set temp 1
}
}
}
if {!$temp} { return } {
putquick "MODE $chan +b *$badpart*!*@*"
putquick "KICK $chan $nick :$kickreason"
}
}
putlog "=-\002 LOADED BAD NICK BY RANA USMAN (www.ranausman.tk)\002 -="
#Author : RANA USMAN
Code: Select all
global bnick bchan kickreason temp
Code: Select all
global something
Code: Select all
set something(one) "1"
set something(two) "2"
# and so on.. you get the idea
Code: Select all
if {[lsearch -nocase $bchan $chan] || ![llength $bchan]} {
# execute stuff
}
Code: Select all
IF we can find a case in-sensitive match of the channel name in that list OR the list has at least one element THEN { execute this code }
Code: Select all
% set chan "foo"
foo
% set channels "something else in here"
something else in here
% lsearch -nocase $channels $chan
-1
% llength $channels
4
% if {[lsearch -nocase $channels $chan] || ![llength $channels]} { puts "I'm in" }
I'm in
Code: Select all
foreach i [string tolower $bnick] {
Code: Select all
if {!$temp} { return } {
putquick "MODE $chan +b *$badpart*!*@*"
putquick "KICK $chan $nick :$kickreason"
}
Code: Select all
if $temp equals 0 we return ELSE execute this code
I agree with caesar because of a pratical reason: if you use several scripts, you'll probably have variables with the same name but with a different usage.caesar wrote:As a general rule of thumb generally it's a good idea to:
1. have variables inside an array, so you won't end up with stuff like this:instead of having a cleaner:Code: Select all
global bnick bchan kickreason temp
where something for example holds the following variables:Code: Select all
global something
Code: Select all
set something(one) "1" set something(two) "2" # and so on.. you get the idea