Raspberry Pi A User Manual page 210

Hide thumbs Also See for Raspberry Pi A:
Table of Contents

Advertisement

194
These are IRC status codes, provided by the server to indicate when particular operations have
completed. These are used by the program to know when it has received the required list of
names from the IRC server. Next, set up the variables for the server connection by entering
the following lines:
irc = {
}
The first line tells Python to create a dict data type. Short for dictionary, this allows multiple
variables to be stored in a single master variable—in this case,
ables can then be recalled later in the program. Although you could write this program with-
out using dicts to store variables, it would make the program significantly more difficult to
read. The dict begins with the opening curly brace, and ends with the closing curly brace on
the final line.
The
to which the program will connect. In this example,
you want to customise the program to use a different server, change the domain name here.
The
be 6667. The
users, while
users, measured in seconds.
Set up a second dict to store the user-specific variables by typing in the following lines:
user = {
}
As with
variables pertain to which section. The
program will use. Don't use your usual nickname if you're planning to connect to the IRC
server at the same time; instead, try appending
P A R T I I I
P R O G R A M M I N G W I T H T H E R A S P B E R R Y P I
'host' : 'chat.freenode.net',
'port' : 6667,
'channel' : '#raspiuserguide',
'namesinterval' : 5
variable should be set to the fully qualified domain name (FQDN) of the IRC server
host
variable tells the program which network port IRC is running on, which will usually
port
variable tells Python which channel to join in order to monitor the
channel
namesinterval
'nick' : 'botnick',
'username' : 'botuser',
'hostname' : 'localhost',
'servername' : 'localhost',
'realname' : 'Raspberry Pi Names Bot'
, all these variables are stored within a dict called
irc
chat.freenode.net
controls how long the program waits to refresh the list of
variable should be set to the IRC nickname the
nick
t to the end of your name to make it
-bo
. These individual vari-
irc
is used, but if
to make it clear which
user

Hide quick links:

Advertisement

Table of Contents
loading

Related Products for Raspberry Pi Raspberry Pi A

This manual is also suitable for:

Raspberry pi b

Table of Contents