|
Joined: Jul 2007
Posts: 6
Nutrimatic drinks dispenser
|
OP
Nutrimatic drinks dispenser
Joined: Jul 2007
Posts: 6 |
I'm having some trouble using variables which contain channel names. I need to be able to turn the bot on or off, at will, on a per channel basis. The on and off triggers are working, but could someone please explain what is the proper way to check for the %#channeloff in the on text *example* Thank you!!
ON *:TEXT:!off*:*: {
if ($nick isop $chan) {
set % $+ $chan $+ off
}
}
ON *:TEXT:!on*:*: {
if ($nick isop $chan) {
unset % $+ $chan $+ off
}
}
on !*:TEXT:*example*:#: {
if ($nick !isop $chan) {
if (!% $+ $chan $+ off) {
ban $($+(-ku,1800)) $chan $nick 3 banned!
}
}
}
|
|
|
|
Joined: Dec 2002
Posts: 503
Fjord artisan
|
Fjord artisan
Joined: Dec 2002
Posts: 503 |
Try this:
ON *:TEXT:!off*:*: {
if ($nick isop $chan) {
set % $+ $chan off
}
}
ON *:TEXT:!on*:*: {
if ($nick isop $chan) {
unset % $+ $chan
}
}
on !*:TEXT:*example*:#: {
if ($nick !isop $chan) {
if ($($+(%, $chan), 2) == off) {
ban $($+(-ku,1800)) $chan $nick 3 banned!
}
}
}
|
|
|
|
Joined: Aug 2004
Posts: 7,252
Hoopy frood
|
Hoopy frood
Joined: Aug 2004
Posts: 7,252 |
you need to double evaluate the variable. Here's a re-write of your code that will make it a bit better.
on *:text:*:#:{
if $nick isop $chan {
set $+(%,$network,.,$chan) $iif($1 == !off,$false,$iif($1 == !on,$true))
}
elseif $($+(%,$network,.,$chan),2) && $me isop $chan {
ban -ku1800 $chan $nick 3 banned
}
}
This will track whether the setting on the channel is on or off, and is multi-network ready. Please note: that the way this is done, if the variable is on, then only ops can say anything in the channel without being banned. In both your original code, and Bekar's reply, if the !off or !on commands were sent to the bot via pm (perfectly valid with the * wildcard for the location), then you will get an error when the script tries to check if the nick is an op on the channel, as $chan will return $null under those circumstances.
Last edited by RusselB; 22/10/07 05:23 AM.
|
|
|
|
Joined: Jul 2007
Posts: 6
Nutrimatic drinks dispenser
|
OP
Nutrimatic drinks dispenser
Joined: Jul 2007
Posts: 6 |
Sorry to say that neither of your examples are working for me.
The commands will only be sent in the channel, not by query. Also don't need multi network compatibility.
Thanks!
|
|
|
|
Joined: Feb 2003
Posts: 3,432
Hoopy frood
|
Hoopy frood
Joined: Feb 2003
Posts: 3,432 |
on *:text:*:#:{ <- # sign tells you that it will trigger on a chan message, Replace * with your trigger
on *:text:*:?:{ <- ? sign tells you it will trigger to a query, Replace * with your trigger
on *:text:*:=:{ <- = sign tells you it will trigger on a DCC chat, Replace * with your trigger
on *:text:*:*:{ <- * sign tells you it will trigger on all abow, Replace first * with your trigger
on *:open:?:*:{ <- tells you it will trigger on all querys when created.
Last edited by sparta; 22/10/07 05:46 AM.
if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
|
|
|
|
Joined: Jul 2007
Posts: 6
Nutrimatic drinks dispenser
|
OP
Nutrimatic drinks dispenser
Joined: Jul 2007
Posts: 6 |
Thanks sparta but the problem is somewhere in the variables not the on triggers.
|
|
|
|
Joined: Aug 2004
Posts: 7,252
Hoopy frood
|
Hoopy frood
Joined: Aug 2004
Posts: 7,252 |
Are you running the code yourself or on a bot?
I tested the code I gave you before I posted it, and it is designed for a bot, which is how your original is also designed.
If it's not working, please provide any error messages that you get and/or how you know it's not working.
|
|
|
|
Joined: Jul 2007
Posts: 6
Nutrimatic drinks dispenser
|
OP
Nutrimatic drinks dispenser
Joined: Jul 2007
Posts: 6 |
The code is running in mIRC (is oped) and I'm testing it using two other clients. One is oped and the other is not.
I've used !on and !off successfully and confirmed the variables were set and unset however it ignores the state of the off variable upon the trigger. There are no error messages.
|
|
|
|
Joined: Aug 2004
Posts: 7,252
Hoopy frood
|
Hoopy frood
Joined: Aug 2004
Posts: 7,252 |
It's not ignoring it, you simply didn't give any indication as to what's supposed to happen if the variable is off, so I didn't include anything in the code.
|
|
|
|
Joined: Oct 2004
Posts: 8,330
Hoopy frood
|
Hoopy frood
Joined: Oct 2004
Posts: 8,330 |
Any of the examples should work based on the information you gave, but here's another example:
on *:TEXT:!off:*: {
if ($nick isop $chan) {
set % $+ $chan off
}
}
on *:TEXT:!on:*: {
if ($nick isop $chan) {
unset % $+ $chan
}
}
on *:TEXT:*example*:#: {
if ($nick !isop $chan && $($+(%,$chan),2) != off) {
ban -ku1800 $chan $nick 3 banned!
}
}
If these aren't doing what you want, then you need to be more specific as to what you're trying to accomplish because they do what your example was trying to do.
Invision Support #Invision on irc.irchighway.net
|
|
|
|
|