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 

combining if text

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


Joined: 07 Jul 2012
Posts: 26

PostPosted: Thu Jul 12, 2012 5:38 am    Post subject: combining if text Reply with quote

hi,

How to make

if ($text = *.id) { echo x } else { echo z }; in tcl ?

everyting they do !whois domain.id go to first x and else goto z

thanks
Back to top
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Thu Jul 12, 2012 1:47 pm    Post subject: Reply with quote

In tcl, that would be something along these lines:
Code:
if {test} {
  code if test is TRUE
} {
  code if test is FALSE
}


In order to do string comparisons, the simplest approach would be to use the string command with the match option:
Code:
string match "*.id" $text


In order to evaluate and test the string match command, we need to use command substitutions, which is done using brackets [ ]

Code:
if {[string match "*.id" $text]} {
  ...
} {
  ...
}


Printing text to stdout is done using the puts command, though that won't make much sense with eggdrops. In order to send text to the irc server, you can use the puthelp and putserv commands; if you'd rather like to log the message, use putlog for that:

Code:
if {[string match "*.id" $text]} {
  puthelp "PRIVMSG #Somechannel :The string \"${text}\" matches!"
} {
  putlog "The string \"${text}\" does not match the test!"
}


Next, in order to use this with a public trigger, we need a binding, and place the above code in a proc:

Code:
bind pub !whois - pubWhois

proc pubWhois {nick host handle channel text} {
  if {[string match "*.id" $text]} {
    puthelp "PRIVMSG #Somechannel :The string \"${text}\" matches!"
  } {
    putlog "The string \"${text}\" does not match the test!"
  }
}

_________________
NML_375, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
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