This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

setudef and channel set problem

Help for those learning Tcl or writing their own scripts.
Post Reply
x
x-treem
Voice
Posts: 9
Joined: Mon Jul 21, 2008 11:13 am

setudef and channel set problem

Post by x-treem »

hi, i'm tryign to make it work but i'm not able to get it. I have a script

Code: Select all

bind pub * !info sendinfo
setudef flag sendinfo
channel set #infochan +sendinfo
proc info {nick uhost hand chan arg} {

if {[channel get $chan sendinfo]} {
....
} else {
return
}
but it's never triggering the if. [channel get $chan sendinfo] is always 0.
if i give a .chanset #infochan +sendinfo from the party line instead, it works....
is there a way to make it work with channel set?
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

Yes and no...
This is due to the channels-file feature in eggdrops.
Basically, it is an automatically generated tcl-script containing dynamic settings for all added channels, which is executed at the end of eggdrop's startup-cycle. Unfortunately, this means it will be executed after all scripts have been loaded, and will overrule any settings you specify in your script.

A workaround may be to use timer/utimer to delay the setting until everything has been loaded. Another option would be to not use the channels-file, with the drawback that any changes to channel-settings during runtime will be lost upon the next restart/rehash.
NML_375
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

Code: Select all

channel set #infochan +sendinfo 
Get rid of that in the script, and instead put that line @ the end (after the source scripts section) of your eggdrop.conf and it'll work. But a person has to ask, why can't you simply .chanset #infochan +sendinfo on the partyline once that script is running? As that is the purpose of .chanset, to allow dynamic channel control while the script is running, without a need to .rehash or .restart ...
x
x-treem
Voice
Posts: 9
Joined: Mon Jul 21, 2008 11:13 am

Post by x-treem »

because i wanted to make the script "handly" to change adding a list of channels with that flag in just one line to have the script run also for that chan as needed instead of having to write it 10thousand times in the party line .chanset #chan1 blah blah .chanset #chan2 blah blah etc
x
x-treem
Voice
Posts: 9
Joined: Mon Jul 21, 2008 11:13 am

Post by x-treem »

speechles wrote:

Code: Select all

channel set #infochan +sendinfo 
Get rid of that in the script, and instead put that line @ the end (after the source scripts section) of your eggdrop.conf and it'll work. But a person has to ask, why can't you simply .chanset #infochan +sendinfo on the partyline once that script is running? As that is the purpose of .chanset, to allow dynamic channel control while the script is running, without a need to .rehash or .restart ...
i tryed, now the end of my eggdrop.conf looks like

Code: Select all

# uncomment (remove # in front of line) next line to activate
# source scripts/winident1.2.tcl

source scripts/infochan.tcl

channel set #testing +sendinfo
but it still doesnt work. channel get #testing addpre is always returning 0
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

x-treem wrote:because i wanted to make the script "handly" to change adding a list of channels with that flag in just one line to have the script run also for that chan as needed instead of having to write it 10thousand times in the party line .chanset #chan1 blah blah .chanset #chan2 blah blah etc
Wait, I'm not following..
.chanset * +sendinfo
That turns it on for every single channel your bot is in.
.chanset #thischan -sendinfo
That turns it off, for that single channel. Which if you used * above, will allow you to remove a few channels you don't want enabled. This is what you should be doing or remove that check entirely since you always want the script to work...

And what exactly is "handly"? A surname? A malapropism of "handy"? A foreign language term not immediately recognizable?

You mean you load the same script, except, multiple times with embedded chanset commands to activate each for each different channel? OMG.. wow, that is too much work my man. You are drowning your bot in redundant data (aka, slowing it down). Talk about doing things backwards. You have just defined that statement.
x
x-treem
Voice
Posts: 9
Joined: Mon Jul 21, 2008 11:13 am

Post by x-treem »

mmm cant understand why of your answer. I'm new to TCL programming so i dont really know the "best" way to program a script right now i made a solution using times as you said before.

Code: Select all

set infochan {"#testing" "#testing1"}
setudef flag sendinfo
set timerID [utimer 15 setchanflag]

proc setchanflag {} {
global timerID infochan
       foreach tchan $infochan {
               putlog "infochan - Setting flag for $tchan"
               channel set $tchan +sendinfo
       }
}
right now next expansion would be getting chanlist from a file and using some other command from chat to add channames to that filelist and automate everything.

thanks for your time
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

x-treem wrote:mmm cant understand why of your answer. I'm new to TCL programming so i dont really know the "best" way to program a script right now i made a solution using times as you said before.

Code: Select all

set infochan {"#testing" "#testing1"}
setudef flag sendinfo
set timerID [utimer 15 setchanflag]

proc setchanflag {} {
global timerID infochan
       foreach tchan $infochan {
               putlog "infochan - Setting flag for $tchan"
               channel set $tchan +sendinfo
       }
}
right now next expansion would be getting chanlist from a file and using some other command from chat to add channames to that filelist and automate everything.

thanks for your time
you realize, the timer doesn't need to call that script.

Code: Select all

set timerID1 [utimer 15 [list channel set #testing +sendinfo]]
set timerID2 [utimer 15 [list channel set #testing2 +sendinfo]]
The script itself should do the 'set udef' part. You do not need to do this again if the script is already loaded. You should be doing this all using the partyline and learning how to control eggdrop via it's normal methods, not scripting clumsy work arounds.. ;)
Post Reply