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

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

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


Revision 1.1.1.1 - (show annotations) (download) (vendor branch)
Wed Aug 25 01:01:56 2004 UTC (14 years, 8 months ago) by wcc
Branch: eggdrop
CVS Tags: eggdrop1_7
Changes since 1.1: +0 -0 lines
* Starting 1.7 tree based off of 1.6.18 CVS as of August 24, 2004.

1 $Id: FIRST-SCRIPT,v 1.4 2004/07/25 03:56:58 wcc Exp $
2
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 First, read through the script. You may be unfamiliar with some of the
24 commands, especially if you haven't at least browsed through
25 tcl-commands.doc. You may find it helpful to open up tcl-commands.doc in
26 another window so that you can immediately look up commands you don't know.
27
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 Copyright (C) 2003, 2004 Eggheads Development Team

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23