01
2021-12-17
jrmu
================================================================================
03
2021-12-17
jrmu
Creating a Greeting Bot
05
2021-12-17
jrmu
In our second lesson, we'll create an IRC bot that greets and interacts
06
2021-12-17
jrmu
with users.
08
2021-12-17
jrmu
Copy the code for autogreet.pl to your home folder:
10
2021-12-17
jrmu
$ cp autogreet.pl ~/autogreet.pl
12
2021-12-17
jrmu
Next, open up autogreet.pl using a text editor and make a few changes.
13
2021-12-17
jrmu
(We recommend vim because it provides syntax highlighting)
15
2021-12-17
jrmu
1. Edit the server in line 89. Replace irc.example.com with the server's
16
2021-12-17
jrmu
real address. NOTE: Only IPv4 is supported.
17
2021-12-17
jrmu
2. Edit line 92 to replace nickname with the nickname you want for the bot.
18
2021-12-17
jrmu
WARNING: The nickname must not already be taken, or else the bot will
19
2021-12-17
jrmu
fail to connect.
20
2021-12-17
jrmu
3. Edit line 93 to replace username with the username you want for the bot.
21
2021-12-17
jrmu
The username is what appears in a /whois on IRC; it can be different
22
2021-12-17
jrmu
from the nickname.
24
2021-12-17
jrmu
Next, you'll want to make the perl script executable:
26
2021-12-17
jrmu
$ chmod u+x ~/autogreet.pl
28
2021-12-17
jrmu
Then run the script:
30
2021-12-17
jrmu
$ ~/autogreet.pl
32
2021-12-17
jrmu
On IRC, /join #perl102
34
2021-12-17
jrmu
Whenever a user joins or parts the channel, the bot will send a message.
35
2021-12-17
jrmu
Try sending a /me action and a notice in the channel tos ee the bot respond.
36
2021-12-17
jrmu
Lastly, try changing your nick or changing the topic in the channel.
37
2021-12-17
jrmu
What happens?
39
2021-12-17
jrmu
================================================================================
41
2021-12-17
jrmu
Understanding AutoGreet
43
2021-12-17
jrmu
Next, take a look at the file called ~/comments to see an explanation of
44
2021-12-17
jrmu
key lines in the program.
46
2021-12-17
jrmu
================================================================================