egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Problem with IF

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
darton
Op


Joined: 21 Jan 2006
Posts: 155

PostPosted: Mon May 01, 2006 6:02 am    Post subject: Problem with IF Reply with quote

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
View user's profile Send private message
De Kus
Revered One


Joined: 15 Dec 2002
Posts: 1361
Location: Germany

PostPosted: Mon May 01, 2006 6:32 am    Post subject: Reply with quote

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
View user's profile Send private message MSN Messenger
darton
Op


Joined: 21 Jan 2006
Posts: 155

PostPosted: Mon May 01, 2006 7:32 am    Post subject: Reply with quote

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
View user's profile Send private message
De Kus
Revered One


Joined: 15 Dec 2002
Posts: 1361
Location: Germany

PostPosted: Mon May 01, 2006 11:39 am    Post subject: Reply with quote

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
View user's profile Send private message MSN Messenger
darton
Op


Joined: 21 Jan 2006
Posts: 155

PostPosted: Mon May 01, 2006 11:59 am    Post subject: Reply with quote

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
View user's profile Send private message
De Kus
Revered One


Joined: 15 Dec 2002
Posts: 1361
Location: Germany

PostPosted: Mon May 01, 2006 2:09 pm    Post subject: Reply with quote

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
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber