[cvslog] Module eggdrop1.7: Change committed

cvslog cvs at tsss.org
Thu Oct 18 19:48:00 CST 2001


CVSROOT    : /usr/local/cvsroot
Module     : eggdrop1.7
Commit time: 2001-10-19 00:47:56 UTC
Commited by: stdarg <stdarg at techmonkeys.org>

Modified files:
     doc/tcl-commands.doc

Added files:
     doc/howto/README doc/howto/first_script.txt doc/howto/timers.txt

Log message:

Documentation updates.

---------------------- diff included ----------------------
Index: eggdrop1.7/doc/howto/README
diff -u /dev/null eggdrop1.7/doc/howto/README:1.1
--- /dev/null	Thu Oct 18 19:47:56 2001
+++ eggdrop1.7/doc/howto/README	Thu Oct 18 19:47:46 2001
@@ -0,0 +1,5 @@
+This directory contains files to help you with eggdrop scripting.
+
+first_script.txt - Contains a very simple, profusely commented script
+setudef.txt - How to use user-defined int, flag, and string channel settings
+timers.txt - How to use timers in eggdrop (timer, rtimer, killtimer)
Index: eggdrop1.7/doc/howto/first_script.txt
diff -u /dev/null eggdrop1.7/doc/howto/first_script.txt:1.1
--- /dev/null	Thu Oct 18 19:47:56 2001
+++ eggdrop1.7/doc/howto/first_script.txt	Thu Oct 18 19:47:46 2001
@@ -0,0 +1,89 @@
+YOUR FIRST EGGDROP SCRIPT
+
+So you want to write an eggdrop script, but you don't really know where to
+begin. This file will give you a very basic idea about what eggdrop scripting
+is like. There are far too many topics to be covered all at once, but this may
+help you get started with your own scripts.
+
+This guide assumes you know a bit about eggdrops and irc. You should have
+already installed eggdrop. The bot should not be on any important or busy
+channels (development bots can be annoying if your script has bugs). If you
+plan on doing a lot of development, enable the .tcl and .set commands and
+make sure nobody else has access to your bot. The .tcl and .set commands are
+helpful in debugging and testing your code.
+
+First, read through the script. You may be unfamiliar with some of the commands,
+especially if you haven't at least browsed through tcl-commands.doc. You may
+find it helpful to open up tcl-commands.doc in another window so that you can
+immediately look up commands you don't know.
+
+Then, open up another window and copy the script into its own file. If you have
+the .tcl command enabled, you can type '.tcl source scripts/yourfile.tcl' to
+load it. Otherwise, add it to your config file like normal and '.rehash' or
+'.restart' your bot.
+
+From your own irc client, join the bot's channel and type some lines that start
+with "hello". Example: hello I love you won't you tell me your name
+
+After your thrill abates, try playing around with your copy of the script. Get
+it to change the text it says, make it send notices instead of messages. Try
+changing the names of some variables (uhost -> userhost maybe).
+
+
+#
+# Here's the start of the script.
+# The '#' in tcl means this line is a comment and doesn't get executed.
+#
+
+#
+# Most scripts start off with a configuration section.
+#
+
+# Change this to the channel you want this script to work on.
+set our_chan "#baa"
+
+# After configuration, scripts generally do a bit of initialization work.
+# This could include checking the validity of the config variables, setting
+# timers, loading helper scripts, establishing database connections, or
+# most frequently, creating our eggdrop binds.
+#
+# A bind lets you attach your script to events that eggdrop encounters. Events
+# include irc events (someone joining a channel, talking, etc), botnet events,
+# and internal events (like receiving signals via the kill command).
+#
+
+# This bind will make eggdrop call "my_talk_handler" whenever someone
+# says hello on one of our channels.
+bind pub - hello my_talk_handler
+
+# Here is where we define "my_talk_handler"
+proc my_talk_handler {nick uhost hand chan text} {
+	#
+	# nick - the person's nickname
+	# uhost - the person's user at host
+	# hand - the person's bothandle (if he is a valid user)
+	# chan - the channel this event happened on
+	# text - the text the person said (not counting the trigger word)
+	#
+	# You can name these variables any way you want, but these names
+	# are pretty much standard.
+	#
+
+	# The 'global' command imports global variables into our local scope.
+	# Any variable set outside of a procedure (like in the config section)
+	# is a global variable.
+	global our_chan
+
+	# We only want to respond on the $our_chan channel.
+	if {$chan != $our_chan} {
+		return 0
+	}
+
+	# The putserv commands lets us send text to the server.
+	putserv "privmsg $chan :$text too!"
+
+	# All done! Log this command by returning 1.
+	return 1
+}
+
+# Here's the end of the script.
Index: eggdrop1.7/doc/howto/timers.txt
diff -u /dev/null eggdrop1.7/doc/howto/timers.txt:1.1
--- /dev/null	Thu Oct 18 19:47:57 2001
+++ eggdrop1.7/doc/howto/timers.txt	Thu Oct 18 19:47:46 2001
@@ -0,0 +1,65 @@
+CREATING TIMERS
+
+Creating a timer in eggdrop is easy. There are three basic commands you need to
+know: timer, rtimer, and killtimer.
+
+timer <seconds> <microseconds> <command>
+rtimer <seconds> <microseconds> <command>
+killtimer <timer-id>
+
+The timer and rtimer commands both create timers. They return a timer-id, which
+you can either ignore, or use to kill the timer later. The only difference
+between the two commands is that 'timer' creates a one-time timer, and 'rtimer'
+creates a repeating timer. The repeating timer will execute until you stop it
+with 'killtimer' or restart the bot.
+
+Why the <seconds> and <microseconds> fields you ask? A microsecond is
+1/1000000 of a second. So you can use the microsecond field to specify a
+fraction of a second. Like if you want your script to execute after 3.5 seconds
+you would do:
+
+	timer 3 500000 yourscript
+
+3 seconds + 500000 microseconds = 3.5 seconds, which is what you wanted. If you
+try to do 'timer 3.5 0 yourscript' it will not work.
+
+The killtimer command lets you stop a timer before it runs. You just pass it
+the timer-id of the timer you want to stop.
+
+Ok, let's have an example. This is a basic script that uses 'rtimer' and
+'killtimer' to display a simple ad on all your channels.
+
+# Example script -- a periodic ftp ad
+set ad_freq 100 ;# Seconds between ads
+set ad_text "Hey come check out my cool ftp site! You can see my vacation photos. ftp://pictures.of.sheep.com"
+
+# This part creates our repeating timer -- if it doesn't exit.
+if {![info exists ad_timer]} {
+	# This code will be executed every time the bot starts, because
+	# the ad_timer variable won't exist until after we set it here.
+	#
+	# We want a repeating timer that executes every $ad_freq seconds.
+	#                    <sec>     <usec>   <cmd>
+	set ad_timer [rtimer $ad_freq  0        ad_display]
+} else {
+	# If it already exists, check if the frequency has changed.
+	if {$ad_freq != $last_ad_freq} {
+		# Yup, kill the old timer and restart it.
+		killtimer $ad_timer
+		set ad_timer [rtimer $ad_freq 0 ad_display]
+	}
+}
+
+# Save the current timer frequency in "last_ad_freq"
+set last_ad_freq $ad_freq
+
+# Actual display procedure that gets called by the timer.
+proc ad_display {} {
+	global ad_text
+	foreach chan [chanlist] {
+		puthelp "privmsg $chan :$ad_text"
+	}
+	return 0
+}
+
+# The end!
Index: eggdrop1.7/doc/tcl-commands.doc
diff -u eggdrop1.7/doc/tcl-commands.doc:1.58 eggdrop1.7/doc/tcl-commands.doc:1.59
--- eggdrop1.7/doc/tcl-commands.doc:1.58	Mon Aug 27 18:31:17 2001
+++ eggdrop1.7/doc/tcl-commands.doc	Thu Oct 18 19:47:46 2001
@@ -841,30 +841,18 @@
     returns: hostmask for the string given ("n!u at 1.2.3.4" -> "*!u at 1.2.3.*",
       "n!u at lame.com" -> "*!u at lame.com", "n!u at a.b.edu" -> "*!u@*.b.edu")
 
-  timer <minutes> <tcl-command>
-    executes the tcl command after a certain number of minutes have passed
+  timer <seconds> <microseconds> <script>
+    executes the script after the specified time
     returns: a timerID
 
-  utimer <seconds> <tcl-command>
-    executes the tcl command after a certain number of seconds have passed
+  rtimer <seconds> <microseconds> <script>
+    creates a repeating timer that executes the script once per interval
+    until cancelled
     returns: a timerID
 
-  timers
-    returns: list of active minutely timers; each entry in the list contains
-      the number of minutes left till activation, the command that will be
-      executed, and the timerID
-
-  utimers
-    returns: list of active secondly timers, identical in format to the
-      output from 'timers'
-
   killtimer <timerID>
-    removes a minutely timer from the list
-    returns: nothing
-
-  killutimer <timerID>
-    removes a secondly timer from the list
-    returns: nothing
+    cancels a normal or repeating timer based on its id
+    returns: 0 if successful, 1 if the timerID is invalid
 
   unixtime
     returns: a long integer which is the current time according to unix
----------------------- End of diff -----------------------



More information about the Changes mailing list