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 

booleans with TCL?

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


Joined: 26 Nov 2006
Posts: 5

PostPosted: Tue Nov 28, 2006 10:35 am    Post subject: booleans with TCL? Reply with quote

i have a message forwarding script, so when someone pm's my bot it does xxx. Im getting other bots pming my bot and spamming crap into my selected channel to which the private messages get sent Neutral

How can i use booleans with TCL?

As in

Declare Forward as a variable.

if (forward == true) send stuff to my channel
if (forward == false) dont send stuff to my channel?

Heres the code that needs to contain the trigger for the bool

Quote:

bind pub - !dothis pub_dothis
proc pub_dothis {nick host hand chan lang text} {
SET BOOLEAN TO TRUE
putserv "PRIVMSG #mychannel : say something lalalalal"
}



heres the forward script, how can i convert this to switch on and off?

I run

Quote:

bind msgm - "*" proc:laina

set chan "#myprivatechannel"
proc proc:laina {nick uhost hand arg} {
global chan
set line [string trim $arg]
if {$nick == "SeenServ"} {
puthelp "privmsg $chan :SeenServ returned: $line"
return 0
}

puthelp "PRIVMSG $chan :\0034 \002$nick : $line\002 ::\0032 /msg $nick"
puthelp "PRIVMSG $nick : Your message is logged, ill get back to you in a minute"
}
return 0



My ultimate goal would be to have both of those scripts contained within the same TCL file, can anyone help?

Cheers!

reddy
Back to top
View user's profile Send private message
reddy
Voice


Joined: 26 Nov 2006
Posts: 5

PostPosted: Tue Nov 28, 2006 1:54 pm    Post subject: Reply with quote

This compiles, but it doesnt work. can anyone help? please?

Quote:

global var
set var TRUE

bind pub - !start pub_start
proc pub_start {nick host hand chan lang text} {
global var
set var TRUE
putserv "PRIVMSG #channel : FORWARD TURNED ON"
}

bind pub - !stop pub_stop
proc pub_stop {nick host hand chan lang text} {
global var
set var FALSE
putserv "PRIVMSG #channel : FORWARD TURNED OFF"
}


#########################

if {$var} {
bind msgm - "*" proc:laina
set chan "#channel"
proc proc:laina {nick uhost hand arg} {
global chan
set line [string trim $arg]
if {$nick == "SeenServ"} {
puthelp "privmsg $chan :SeenServ returned: $line"
return 0
}
puthelp "PRIVMSG $chan :\0034 \002$nick : $line\002 ::\0032 /msg $nick"
puthelp "PRIVMSG $nick :hey, Im the manager bot! Your message is logged, a member may, or may not contact you with a reply to your query. Thanks!"
}
}

if {!$var} {
putserv "PRIVMSG #channel : GO AWAY!"
}
Back to top
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Tue Nov 28, 2006 2:16 pm    Post subject: Reply with quote

First of all, tcl does'nt compile..
As for the proc command, it only cares that it is given three arguments ("name", "header", and "body", where header is a list of arguments for the created proc and body it's contents). No parsing or checking other than the normal expansions is performed.

To find out wether there's any syntactical error within your proc, you'll have to make sure that part of the proc is executed once the proc itself has been defined.

Also, the idea behind your code is flawed. It seems you assume the whole script will be run every time you issue a command; that is not true. The script will only be evaluated when it's loaded with "script path/to/file". You'll have to check the value of your "var" inside any proc that uses it as a conditional, trying to put proc definitions within such a conditional would only affect wether that proc is (re)defined when the script is evaluated (usually only when your bot is (re)started or rehashed).

You probably want something like this:
Code:
set cond true
bind msgm - * myproc
proc myproc {nick host hand text} {
 global cond
 if {$cond} {
  puthelp "PRIVMSG $nick :Message sent"
  ...
 }
}

_________________
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