Got something new here that is doing my head in.
I made a small script, where as the trigger is based on a few specific types of letters/numbers.
an example would be:
.test 5 10 5 n:sp
So far i got it to work all smoothly the way i want, but now what IF a user types in for example:
.test abc def ghi 10:5
I need the script to make sure that the first 3 inputs are NUMBERS ONLY, and the last part can ONLY be the LETTERS n, kb, sp, either single or combined with a : as a separator (such as n:kb:sp or just kb or even n:sp etc..).
If one of the first 3 inputs is NOT a number, i would like it to return an error, and if the last part (modes) is NOT one of the allowed letters, to have it return an error as well.
In addition to this, there are a total of 4 arguments. If the arguments are more than 4, return an error, and if the arguments are less than 4, to return an error as well. BUT, if the argument is just 1, as i have defined in the script below (-help or off), to not count this as an error.
Code: Select all
proc test {nick host hand channel text} {
set modes [lrange [split $text] 0 end]
set help [lindex [split $text] 0]
set h "-help"
set o off
if {$modes == ""} {
putserv "NOTICE $nick :Missing arguements. Please type \002.test -help\002 for information on how to use this command."
return 1
}
if {$help == $h} {
putserv "NOTICE $nick :Set & Activate TEST"
putserv "NOTICE $nick :This is the help description of the command \002test\002."
### I have subsituted the meanings with num1, num2, num3 to show you that the value MUST be only numerical digits, whereas <modes> must and only be either a sp, kb, n or a combination like sp:kb or n:kb, or even sp:kb:n ###
putserv "NOTICE $nick :usage: .test <num1> <num2> <num3> <modes>"
putserv "NOTICE $nick :example: .test 5 20 5 n:sp"
putserv "NOTICE $nick : "
putserv "NOTICE $nick Valid modes are sp for sapart, kb for kickban, n for notify"
putserv "NOTICE $nick :To dectivate TEST type: .test off"
return 1
}
if {$help == $o} {
putserv "NOTICE $nick :TEST have been de-activated for channel $channel"
return 1
}
putserv "NOTICE $nick :Channel TEST features for channel $channel have been set to \002[lindex [split $text] 0] [lindex [split $text] 1] [lindex [split $text] 2] [lindex [split $text] 3]\002"
putserv "NOTICE $nick :In english this means, <num1> = \002[lindex [split $text] 0]\002, l<num2> = \002[lindex [split $text] 1]\002, <num3> = \002[lindex [split $text] 2]\002, and finally the <modes> = \002[lindex [split $text] 3]\002"
return 1
}
Any help would be be appreciated.
Cheers. 3