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.

Eggdrop v's Windrop

Old posts that have not been replied to for several years.
Locked
s
spyda
Halfop
Posts: 64
Joined: Mon Aug 12, 2002 2:22 am
Location: Australia

Eggdrop v's Windrop

Post by spyda »

Hey peoples. I am writing a status TCL that will work with Eggdrop and Windrops. Just got a little problem with the trigger!

I am running eggdrop 1.6.9 (Lunix 2.4.7-10) and windrop 1.6.6-handle32 (winXp). Both running that TCL but with different triggers. eg: `status and !status

But when you load both eggdrop and windrop into the same chan and write either of them two triggers. Both bots exec the TCL, so you could say I have a little problem!! I will paste a little just to see if you guys can see where I went wrong (I cant find it).

Code: Select all

### What is the trigger that you like???
### Default: set asus(trig) "!"
set asus(trig) "`"

### What flag is needed to trigger
### Default: set asus(flag) "m"
set asus(flag) "m"

bind pub $asus(flag) $asus(trig)status asus_pub_status
bind msg $asus(flag) status asus_msg_status

proc asus_pub_status {nick uhost hand chan vasus} {
 global asus botnick
 asus_status $nick $uhost $hand $chan $vasus
}

proc asus_msg_status {nick uhost hand vasus} {
 global asus botnick
 set chan [lindex [split $vasus] 0]
 if {$asus(msgtype) == "2"} {
  if {[lindex $vasus 0] == ""} {
   puthelp "NOTICE $nick :Usage: /msg $botnick status <#chan>"
   return 0
   }
  }	
 asus_status $nick $uhost $hand $chan $vasus
}
So if I change the asus(trig) to another symbol it does the same. Thanx in Advance

--------------
ThePope
User avatar
slennox
Owner
Posts: 593
Joined: Sat Sep 22, 2001 8:00 pm
Contact:

Post by slennox »

If you change the trigger and just do a rehash, the new trigger will be bind but the old one will still be there as well. Do a restart to clear old binds.
e
egghead
Master
Posts: 481
Joined: Mon Oct 29, 2001 8:00 pm
Contact:

Post by egghead »

If you change the trigger and just do a rehash, the new trigger will be bind but the old one will still be there as well. Do a restart to clear old binds.
A bit off-topic, but under script development conditions, I've found it cumbersome to .restart the bot everytime. Especially if the bot connects slowly to a server, in which case one has to wait with testing a script until the bot has reconnected to the server and rejoined a channel. I'm even not sure if it is desired behaviour that the bot keeps old bindings after a .rehash.

Under script development conditions, I'm now using and testing a script that purges packages/procedures/bindings upon a .rehash. Maybe purging of all "listen"s should be added too. Any feedback is appreciated.

http://members.fortunecity.com/eggheadt ... nt.tcl.txt
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

The current .restart and .rehash behaviours are correct.

.rehash is designed to refresh what is contained in the user, channel, notes and config files. IE just re-read file changes.

.restart is designed to clear memory as well. Due to this, all information regarding connections to servers, userfile information and scripts are lost, thus eggdrop clears up any connections first, avoiding painful timeouts and so on.

While a .restart is painful to developers on slow connections, they should also be aware, that re-connections can help locate bugs.
e
egghead
Master
Posts: 481
Joined: Mon Oct 29, 2001 8:00 pm
Contact:

Post by egghead »

ppslim wrote:The current .restart and .rehash behaviours are correct.

.rehash is designed to refresh what is contained in the user, channel, notes and config files. IE just re-read file changes.
The current .rehash leads to undesired (i.e. confusing) situations, where binds are not purged. Given the fact that the config file and all tcl scripts are reread, there is no reason to retain old bindings. Thus, the current behaviour is fairly incorrect behaviour, which can lead to error messages with eggdrop complaining that it can't find procedures etc. etc.

Another serious and very incorrect situation is that on a rehash it appears that the bot doesn't recognise users for the period between "Writing user file..." and the "Userfile loaded, unpacking..." (at least in 1.6.9 :) )
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

Egghead, I agree mostly that .rehash is pretty dumb. Another thing that would be nice is an .unload command for scripts that will cancel timers, binds, etc that it produced. It might be kind of tricky, but I think it would be pretty nice.

Just a suggestion for your freshmint, you might want to kill timers as well.
e
egghead
Master
Posts: 481
Joined: Mon Oct 29, 2001 8:00 pm
Contact:

Post by egghead »

stdragon wrote:Egghead, I agree mostly that .rehash is pretty dumb. Another thing that would be nice is an .unload command for scripts that will cancel timers, binds, etc that it produced. It might be kind of tricky, but I think it would be pretty nice.

Just a suggestion for your freshmint, you might want to kill timers as well.
Thanks for the suggestion to kill timers too. I've looked briefly into writing an .unload script. It seems the way to go is to parse out any proc definition, binding, timer etc. from the plain text file and then removing it.

Just as a warning for those who may want to use the freshmint script: when implementing and testing the purging of timers upon a .rehash, some (somewhat old ;) ) scripts produced errors.

It can happen as follows: somewhere in a script the following statement occurs:

Code: Select all

set timervar [timer 10 procedure]
i.e. the variable "timervar" contains the timerID.

Then somewhere else in the script the following statement is found:

Code: Select all

if {[info exists timervar]} { killtimer $timervar }
i.e. if the variable timervar (containing the timerID) exists, it is assumed that the timerID exists and the associated timer is subsequently killed.

The following situation may occur however: a timer is started and the variable "timervar" is set. Then upon a rehash the freshmint script purges the timer.
But the statement [info exists timervar] still does evaluate to 1 (TRUE) however, since the variable still exists even though the associated timer was already purged. The statement "killtimer $timervar" subsequently will produce errors.
The way to avoid such error, is to iterate on the list of timers itself and see if the timerid is in it instead of testing on the existence of a variable :)
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

I think you could it by creating a new tcl source command called eggsource for use only in the config file:

1. Create a new namespace for the script to load into (or maybe a slave interpreter?)
2. Import all of the eggdrop vars + procs into that namespace
3. Overwrite the "global" command so that it uses namespace vars instead
4. Overwrite the bind, unbind, timer, killtimer, etc, so that it keeps track of all binds and timers that exist in that namespace
5. Load the script into the new namespace (with a catch {} so that errors do not crash the bot)

Then the unload command would:

1. Find the namespace associated with that script
2. Delete all timers + binds using the recorded information
3. Delete the namespace, so that all the script's variables are reset

I've been thinking about writing something like this for a while, but haven't gotten around to it. It's part of an "eggdrop package manager" I was thinking about. People could use it to automatically download and install scripts, and then easiliy unload them if they suck.
s
spyda
Halfop
Posts: 64
Joined: Mon Aug 12, 2002 2:22 am
Location: Australia

Eggdrop v's Windrop

Post by spyda »

Thanx for all the help.. I looked up about triggers and found my answer!

Now for the next problem.. Status.tcl v1.0.0 uptime

Code: Select all

 asus_msg $asus_who "Online for [asus_time $uptime]"
Now when I write status I get:
(10:37am) <Asustek> Online for 0
I am not sure what is going on.. I have look around for a TCL that does it.. But I dont get the idea of it..

This is the proc asus_time

Code: Select all

proc asus_time {time} {
	set ltime [expr [unixtime] - $time]
	set seconds [expr $ltime % 60]
	set ltime [expr ($ltime - $seconds) / 60]
	set minutes [expr $ltime % 60]
	set ltime [expr ($ltime - $minutes) / 60]
	set hours [expr $ltime % 24]
	set days [expr ($ltime - $hours) / 24]
}
Thanx to anyone that can help me!!

------------
ThePope
s
spyda
Halfop
Posts: 64
Joined: Mon Aug 12, 2002 2:22 am
Location: Australia

Eggdrop v's Windrop

Post by spyda »

Sorry I forgot something to..

I know there is a way, but have no idea about doing it!

So when the bot says the uptime it says it as

eg : Online for 1 day 2 hours 23 minutes 13seconds

and when the bot goes to 2 days it or 2 minutes it changes the (s)

eg :Online for 4 days 13 hours 1 minute 2 seconds

Thanx in Advance

------------
ThePope
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

You've gotta put together a string and return it in your time proc. You calculate all the values, but you don't use them hehe.
s
spyda
Halfop
Posts: 64
Joined: Mon Aug 12, 2002 2:22 am
Location: Australia

Eggdrop v's Windrop

Post by spyda »

Yes I understand that stdragon!

But how do I go around to doing this???

I have messed around with

Code: Select all

proc asus_time {time} {
	set ltime [expr [unixtime] - $time]
	set seconds [expr $ltime % 60]
	set ltime [expr ($ltime - $seconds) / 60]
	set minutes [expr $ltime % 60]
	set ltime [expr ($ltime - $minutes) / 60]
	set hours [expr $ltime % 24]
	set days [expr ($ltime - $hours) / 24]
	set asus_times ""
                if {$day < "1"} {
                 set assus_day "days "
                } else {
                 set sday_day "day "
               return $day $asus_day
}

But I am still a little lost

------------
ThePope
              
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

You have to make a string together, to return.

Tcl can't return multiple arguements from a proc, as such, you have to make one.

IE

Code: Select all

return "$day $month $year"
s
spyda
Halfop
Posts: 64
Joined: Mon Aug 12, 2002 2:22 am
Location: Australia

Eggdrop v's Windrop

Post by spyda »

Yep.. I was looking in the TCL docs on my computer and I found this.

Append - To add to a string as a list (myhelpme.file)
So I played with it for a while and got this:

Code: Select all

 set asus_times ""
 if {$days} {
  append asus_times "$days "
  if {$days == "1"} {
   append asus_times "day "
   } else {
    append asus_times "days "
    }
   }
  if {$hours} {
   append asus_times "$hours "
   if {$hours == "1"} {
    append asus_times "hour "
    } else {
     append asus_times "hours "
    }
   }
 return $asus_times
}
And so on for days minutes hours seconds.. Thanx for all the help guys.. keep it up.

------------
ThePope
Locked