Re: [Toolserver-l] Two beginner questions

2010-12-10 Thread Alex Brollo
Far from being interested about #irc protocol in general, my interest is focused on irc.wikimedia.org read-only channels, and on parameter segment of specific rows of specific channels (but I see that all channels follow a similar pattern). My idea is to use my very basic listening bot to select r

Re: [Toolserver-l] Two beginner questions

2010-12-10 Thread Platonides
River Tarnell wrote: > PS: I cringe every time I see someone "parsing" IRC lines with things like > strncmp(line, "PRIVMSG ", 8) or strstr(line, " :"). The IRC protocol is very > simple, and tokenising it properly is really not that difficult. (Every > argument is separated by a space; if the fir

Re: [Toolserver-l] Two beginner questions

2010-12-10 Thread River Tarnell
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Михајло Анђелковић: > I was returning the server whatever it was sending to me as a ping. This is > how it worked like two years ago. Has something changed? This is the correct way to do it, but many IRC client implementations are lazy and are writt

Re: [Toolserver-l] Two beginner questions

2010-12-10 Thread River Tarnell
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 MZMcBride: > Gahhh, this list. Nobody suggested just using Python's Twisted? Someone is suggesting it: you. That's pretty much the point of the list; there's more than one person on it. - river. -BEGIN PGP SIGNATURE- Version: GnuPG

Re: [Toolserver-l] Two beginner questions

2010-12-10 Thread Alex Brollo
2010/12/10 MZMcBride > > Gahhh, this list. Nobody suggested just using Python's Twisted?[1] So much > easier than trying to write your own script in Python using sockets and > manual pongs and all that jazz. > Once more, it's amazing to see how different meanings can have the word "easier". :-)

Re: [Toolserver-l] Two beginner questions

2010-12-09 Thread Alex Brollo
2010/12/10 Giftpflanze > > > Gahhh, this list. Nobody suggested just using Python's Twisted?[1] So > > much easier than trying to write your own script in Python using > > sockets and manual pongs and all that jazz. > I'm going to drag as deep as I can into http://krondo.com/?p=1209. Thanks for s

Re: [Toolserver-l] Two beginner questions

2010-12-09 Thread Giftpflanze
MZMcBride schrieb: > Alex Brollo wrote: > > 2. The script bring(s) 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

Re: [Toolserver-l] Two beginner questions

2010-12-09 Thread MZMcBride
Alex Brollo wrote: > 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 > min

Re: [Toolserver-l] Two beginner questions

2010-12-09 Thread Platonides
Sumurai8 (DD) wrote: > Well... you can actually send every 3 minutes a PONG-message without > listening to the IRC-channel and the server will gladly accept that > ^_^ . That's what I did at the time I didn't know about the > timeout-option of a socket :) But most of the time it is just better > to

Re: [Toolserver-l] Two beginner questions

2010-12-09 Thread Platonides
Михајло Анђелковић wrote: > Long ago I have noticed that the irc server is kicking my bot out > after some time from some reason. > > Then I looked closer and noticed there is a server's ping around that > mishaps. Alright, then I just added an ad-hoc pong: > > public void responsePing(Stri

Re: [Toolserver-l] Two beginner questions

2010-12-09 Thread Alex Brollo
Ok. I've my listening bot; at the beginning I've been a little confused by irc color codes, but I realized that they can be used to parse effectively #irc messages. Just the time to mount my "irc color-based parser" then I'll be ready to use data enough for now I presume. Then I'll read agai

Re: [Toolserver-l] Two beginner questions

2010-12-09 Thread Sumurai8 (DD)
You are probably missing a PING-message whilest listening to IRC and then closes the connection when it doesn't receive a PONG in like 180 seconds. 2010/12/9 Михајло Анђелковић : > Long ago I have noticed that the irc server is kicking my bot out > after some time from some reason. > > Then I look

Re: [Toolserver-l] Two beginner questions

2010-12-09 Thread Михајло Анђелковић
Long ago I have noticed that the irc server is kicking my bot out after some time from some reason. Then I looked closer and noticed there is a server's ping around that mishaps. Alright, then I just added an ad-hoc pong: public void responsePing(String line) { try {

Re: [Toolserver-l] Two beginner questions

2010-12-09 Thread Sumurai8 (DD)
Well... you can actually send every 3 minutes a PONG-message without listening to the IRC-channel and the server will gladly accept that ^_^ . That's what I did at the time I didn't know about the timeout-option of a socket :) But most of the time it is just better to follow the rules and end each

Re: [Toolserver-l] Two beginner questions

2010-12-09 Thread Bryan Tong Minh
On Thu, Dec 9, 2010 at 5:36 PM, Platonides wrote: > Sumurai8 (DD) wrote: >> 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 > > According to the protocol, it should be a CRL

Re: [Toolserver-l] Two beginner questions

2010-12-09 Thread Platonides
Sumurai8 (DD) wrote: > 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 According to the protocol, it should be a CRLF (\r\n). Although a bare \n seems to be commonly accepted

Re: [Toolserver-l] Two beginner questions

2010-12-09 Thread Sumurai8 (DD)
It's just a plain idea how you can make an irc bot. Possible solutions are making the buffer bigger or preserving the last message if it doesn't end with a \n. For WikiLinkBot the first solution works just fine (If reading the recent changes every 10 minutes just works fine, making a bigger buffer

Re: [Toolserver-l] Two beginner questions

2010-12-09 Thread Alex Brollo
2010/12/9 Platonides > Alex Brollo wrote: > > 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? > > Yes. Specially

Re: [Toolserver-l] Two beginner questions

2010-12-09 Thread Platonides
Alex Brollo wrote: > 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? Yes. Specially since you presumably want to get *a

Re: [Toolserver-l] Two beginner questions

2010-12-09 Thread Alex Brollo
2010/12/9 Bryan Tong Minh > On Thu, Dec 9, 2010 at 4:54 PM, Alex Brollo wrote: > > 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? :-( > > > Please

Re: [Toolserver-l] Two beginner questions

2010-12-09 Thread River Tarnell
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Sumurai8 (DD): >     text = IRC.recv(1024) >     msgs = text.split('\n') This seems to have a bug: if there's more than 1024 bytes waiting, you could receive only part of the final message; so you will truncate that message, and the next recv will re

Re: [Toolserver-l] Two beginner questions

2010-12-09 Thread Sumurai8 (DD)
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 het volgende geschreven: > irc listening with python is fairly easy; just use a soc

Re: [Toolserver-l] Two beginner questions

2010-12-09 Thread Sumurai8 (DD)
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"

Re: [Toolserver-l] Two beginner questions

2010-12-09 Thread Bryan Tong Minh
On Thu, Dec 9, 2010 at 4:54 PM, Alex Brollo wrote: > 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? :-( > Please give the specific error message. It is har

[Toolserver-l] Two beginner questions

2010-12-09 Thread Alex Brollo
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 trie