Raspberry Pi User Manual page 189

Hide thumbs Also See for Raspberry Pi:
Table of Contents

Advertisement

C H A P T E R 1 1
This tells Python that when the
complete list of names to the standard output before blanking the
line—
—is important: without it, each time the loop runs it will add users'
names = []
names to the list even though they already exist from an earlier run .
Finally, finish the program by entering the following lines:
time.sleep(irc['namesinterval'])
s.send('NAMES %(channel)s\r\n' % irc)
This tells Python to wait the
request for user names and beginning the loop again . Be careful to set
reasonable value—if the IRC server receives too many requests in too short a space of time,
it may forcibly disconnect you for flooding .
Save the program as
ircuserlist.py
option in the Run menu or from the terminal by typing
the program first runs, it may take a while to connect to the server; once connected, how-
ever, the list of names (see Figure 11-7) should refresh quickly . To quit the program, press
CRTL + C .
A N I N T R O D U C T I O N T O P Y T H O N
response has been received, it should print out the now-
366
number of seconds before sending another
namesinterval
, and run it either by using IDLE's Run Module
list again . This last
names
namesinterval
python ircuserlist.py
177
to a
. When
Figure 11-7:
Using Python to
list users in an
IRC channel

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents