[Toolserver-l] Two beginner questions
Sumurai8 (DD)
Sumurai8 at wikiweet.nl
Thu Dec 9 16:04:39 UTC 2010
irc listening with python is fairly easy; just use a socket
import socket
IRC = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
IRC.connect(('irc.freenode.net', 6667))
while True:
text = IRC.recv(1024)
msgs = text.split('\n')
for msg in msgs:
if msg.split(' ', 1)[0] == "PING":
pong = msg.split(' ', 1)[1]
IRC.send("PONG %s" % pong)
print msg
If you want to do periodically things, like writing the output to a
file very 10 minutes, you have to set a timeout. Otherwise the script
will wait at the recv-line till it receives data
2010/12/9 Alex Brollo <alex.brollo at gmail.com>
>
> 1. I'm testing my skill and I run my script under cron. The python script begin with these rows (and it runs):
>
> # -*- coding: utf-8 -*-
> #!/usr/bin/python
> import os,sys
> if not sys.platform=="win32":
> sys.path.append('/home/alebot/pywikipedia')
> os.chdir("/home/alebot/scripts")
>
> Then I tried to move to batch job sheduling, but... my script gives an error: now the server dislikes sys.path row. Why? I obviously have to study more: but what/where have I sto study? :-(
> 2. The script bring into life a python bot, who reads RecentChanges at 10 minutes intervals by a cron routine. Is perhaps more efficient a #irc bot listening it.wikisource #irc channel for recent changes in your opinion? Where can I find a good python script to read #irc channels?
> Thanks - I apologize for so banal questions.
> Alex
>
>
>
> _______________________________________________
> Toolserver-l mailing list (Toolserver-l at lists.wikimedia.org)
> https://lists.wikimedia.org/mailman/listinfo/toolserver-l
> Posting guidelines for this list: https://wiki.toolserver.org/view/Mailing_list_etiquette
More information about the Toolserver-l
mailing list