You should 'split' the $text and take what you need from it with 'lindex'
if {[onchan $nick #opers] == 1 && [isop $nick #opers] == 1} {
there's no need to check bouth, stick with just the isop as it wil return 1 if that user is on the channel and has op, else will return 0.
Also, here's another tip:
Code: Select all
if {$something} {
will do this part if $something is equal with 1
}
if {!$something} {
will do this part if $something is equal with 0
}
if {$text == "on"} {
You should start using either [string tolower $text] or [string match -nocase $text "on"] (same thing for "off" and "check") as "ON" isn't the same thing as 'on' and the script won't work
I would replace:
Code: Select all
if {$text != "on" && $text != "off" && $text != "check"} {
putquick "NOTICE $nick : syntax is .tssync on/off/check"
}
with something easier to change:
Code: Select all
set commands [list "on" "off" "check"]
if {![lsearch -exact $commands $text]} {
putquick "NOTICE $nick : syntax is .tssync on/off/check"
}
OR use 'switch -nocase -- $text' like i did on the
other topic that would take care of other inputs for you.
Code: Select all
switch -nocase -- [lindex [split $text] 0] {
"on" {
# on stuff here
}
"off" {
# off stuff here
}
"check" {
# check stuff here
}
default {
# any other command goes here
}
}
Move the 'if' check that sends this message:
Code: Select all
putmsg #opers "Sorry \00310$nick\003, you dont have access to use that command"
at top and return after like this:
Code: Select all
if {![isop $nick "#opers"]} {
putserv "PRIVMSG #opers :Sorry \00310$nick\003, you dont have access to use that command"
return
}
Here's my version of your code with 'switch':
Code: Select all
bind pub - ".tssync" pub:tssync
proc pub:tssync {nick uhost hand chan text} {
global tss
if {![isop $nick "#opers"]} {
putserv "PRIVMSG $chan :Sorry \00310$nick\003, you dont have access to use that command"
return
}
switch -nocase -- [lindex [split $text] 0] {
"on" {
set tss "on"
putserv "PRIVMSG $chan :TSSync turned \0034\002ON\002\003 by \00310$nick\003."
bind cron - "* */1 * * *" cron:tssync
}
"off" {
set tss "off"
putserv "PRIVMSG $chan :TSSync turned \0034\002OFF\002\003 by \00310$nick\003."
unbind cron - "* */1 * * *" cron:tssync
}
"check" {
putserv "PRIVMSG $chan :TSSync is currently $tss"
}
default {
putserv "NOTICE $nick : syntax is .tssync on/off/check"
}
}
}
proc cron:tssync {min hour day month weekday} {
putserv "PRIVMSG OperServ :tssync"
}
Edit: Fixed minor typos and added the missing bind.
Once the game is over, the king and the pawn go back in the same box.