| View previous topic :: View next topic |
| Author |
Message |
darton Op
Joined: 21 Jan 2006 Posts: 155
|
Posted: Mon May 01, 2006 6:02 am Post subject: Problem with IF |
|
|
Hello!
Look at this script. If the BRenBot is not in that channel, my bot says:"The Servers are down." But it still writes "!gi" in the #admin_chan.
How is it possible that my bot stops writing "!gi" if the BRenBot is not in the #admin_chan?
| Code: | bind pub - !gi pub:gi
proc pub:gi {nick uhost hand chan arg} {
global admin_chan public_chan
if {![onchan BRenBot $admin_chan]} {
putquick "privmsg $chan :The Servers are down!"
}
if {[string equal -nocase $public_chan $chan]} {
putquick "privmsg $admin_chan :!gi"
}
}
|
|
|
| Back to top |
|
 |
De Kus Revered One

Joined: 15 Dec 2002 Posts: 1361 Location: Germany
|
Posted: Mon May 01, 2006 6:32 am Post subject: |
|
|
because the next if is independend from first one. you should use ELSEIF like
| Code: | if {![onchan BRenBot $admin_chan]} {
puthelp "PRIVMSG $chan :The Servers are down!"
} elseif {[string equal -nocase $public_chan $chan]} {
putserv "PRIVMSG $admin_chan :!gi"
} |
to make the 2nd one depend on the previous one. _________________ De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens... |
|
| Back to top |
|
 |
darton Op
Joined: 21 Jan 2006 Posts: 155
|
Posted: Mon May 01, 2006 7:32 am Post subject: |
|
|
| No, I already tried this. If the BRenBot was in the #admin_chan, my bot would not write "!gi" in the #admin_chan. So your script does not work. |
|
| Back to top |
|
 |
De Kus Revered One

Joined: 15 Dec 2002 Posts: 1361 Location: Germany
|
Posted: Mon May 01, 2006 11:39 am Post subject: |
|
|
| darton wrote: | If the BRenBot is not in that channel, my bot says:"The Servers are down." But it still writes "!gi" in the #admin_chan.
How is it possible that my bot stops writing "!gi" if the BRenBot is not in the #admin_chan? |
| darton wrote: | | No, I already tried this. If the BRenBot was in the #admin_chan, my bot would not write "!gi" in the #admin_chan. |
you wrote the opposite in your description. You might want to check spelling (case doesnt matter) of channel and nick. Consider encoding issues of characters above 127. You can also try using 'hand2nick' to also match alternate nicknames, if there is a user entry for the bot.
| darton wrote: | | So your script does not work. |
Assuming your script worked as descripted, my changed if construuction should stop your initialy described problem. _________________ De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens... |
|
| Back to top |
|
 |
darton Op
Joined: 21 Jan 2006 Posts: 155
|
Posted: Mon May 01, 2006 11:59 am Post subject: |
|
|
| Code: | bind pub - !gi pub:gi
proc pub:gi {nick uhost hand chan arg} {
global admin_chan public_chan
if {![onchan BRenBot $admin_chan]} {
putquick "privmsg $chan :The Servers are down!"
}
if {[onchan BRenBot $admin_chan]} {
if {[string equal -nocase $public_chan $chan]} {
putquick "privmsg $admin_chan :!gi"
}
}
} |
With this script it works. |
|
| Back to top |
|
 |
De Kus Revered One

Joined: 15 Dec 2002 Posts: 1361 Location: Germany
|
Posted: Mon May 01, 2006 2:09 pm Post subject: |
|
|
which is equivalent with the code snip I posted, just with some redudant code within the if expressions. _________________ De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens... |
|
| Back to top |
|
 |
|