/[cvs]/eggdrop1.7/doc/FIRST-SCRIPT
ViewVC logotype

Annotation of /eggdrop1.7/doc/FIRST-SCRIPT

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.4 - (hide annotations) (download)
Mon Nov 20 13:53:24 2006 UTC (12 years, 6 months ago) by tothwolf
Branch: MAIN
CVS Tags: HEAD
Changes since 1.3: +2 -2 lines
* Updated copyright dates for 2006 (better late than never).

1 tothwolf 1.4 $Id: FIRST-SCRIPT,v 1.3 2005/01/21 01:43:37 wcc Exp $
2 wcc 1.1
3     Your First Eggdrop Script
4     Last revised: December 07, 2003
5     _____________________________________________________________________
6    
7     Your First Eggdrop Script
8    
9    
10    
11     So you want to write an Eggdrop script, but you don't really know where
12     to begin. This file will give you a very basic idea about what Eggdrop
13     scripting is like. There are far too many topics to be covered all at
14     once, but this may help you get started with your own scripts.
15    
16     This guide assumes you know a bit about Eggdrops and IRC. You should have
17     already installed Eggdrop. The bot should not be on any important or busy
18     channels (development bots can be annoying if your script has bugs). If you
19     plan on doing a lot of development, enable the .tcl and .set commands, and
20     make sure nobody else has access to your bot. The .tcl and .set commands
21     are helpful in debugging and testing your code.
22    
23 wcc 1.2 First, read through the script. You may be unfamiliar with a few commands,
24     especially if you haven't at least browsed through doc/TCL-COMMANDS. You may
25     find it helpful to open up doc/TCL-COMMANDS in another window so that you
26     can immediately look up commands you don't know.
27 wcc 1.1
28     Then, open up another window and copy the script into its own file. If you
29     have the .tcl command enabled, you can type '.tcl source scripts/file.tcl'
30     to load it. Otherwise, add it to your config file like normal and '.rehash'
31     or '.restart' your bot.
32    
33     From your own IRC client, join the bot's channel and type some lines that
34     start with "hello". Example: hello I love you won't you tell me your name
35    
36     After your thrill abates, try playing around with your copy of the script.
37     Get it to change the text it says, make it send notices instead of messages.
38     Try changing the names of some variables (uhost -> userhost maybe).
39    
40    
41     #
42     # Here's the start of the script.
43     # The '#' in Tcl means this line is a comment and doesn't get executed.
44     #
45    
46     #
47     # Most scripts start off with a configuration section.
48     #
49    
50     # Change this to the channel you want this script to work on.
51     set our_chan "#baa"
52    
53     # After configuration, scripts generally do a bit of initialization work.
54     # This could include checking the validity of the config variables, setting
55     # timers, loading helper scripts, establishing database connections, or
56     # most frequently, creating our Eggdrop binds.
57     #
58     # A bind lets you attach your script to events that Eggdrop encounters. Events
59     # include IRC events (someone joining a channel, talking, etc), botnet events,
60     # and internal events (like receiving signals via the kill command).
61     #
62    
63     # This bind will make Eggdrop call "my_talk_handler" whenever someone
64     # says hello on one of our channels.
65     bind pub - hello my_talk_handler
66    
67     # Here is where we define "my_talk_handler"
68     proc my_talk_handler {nick uhost hand chan text} {
69     #
70     # nick - the person's nickname
71     # uhost - the person's user@host
72     # hand - the person's bothandle (if he is a valid user)
73     # chan - the channel this event happened on
74     # text - the text the person said (not counting the trigger word)
75     #
76     # You can name these variables any way you want, but these names
77     # are pretty much standard.
78     #
79    
80     # The 'global' command imports global variables into our local scope.
81     # Any variable set outside of a procedure (like in the config section)
82     # is a global variable.
83     global our_chan
84    
85     # We only want to respond on the $our_chan channel.
86     # The string tolower command converts a string to lowercase.
87     if {[string tolower $chan] != $our_chan} {
88     return 0
89     }
90    
91     # The putserv commands lets us send text to the server.
92     putserv "privmsg $chan :$text too!"
93    
94     # All done! Log this command by returning 1.
95     return 1
96     }
97    
98     # Here's the end of the script.
99     _____________________________________________________________________
100    
101 tothwolf 1.4 Copyright (C) 2003 - 2006 Eggheads Development Team

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23