[Toolserver-l] Two beginner questions

Sumurai8 (DD) sumurai8 at gmail.com
Thu Dec 9 16:06:37 UTC 2010


Oops, forgot to put a return after the pongmsg, like this:
IRC.send("PONG %s\n" % pong)

The IRC-server will try to process the line after it finds a \n in your msg

Op 9 december 2010 17:04:24 UTC+1 heeft Sumurai8
<Sumurai8 at wikiweet.nl> het volgende geschreven:
> 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