[Tutor] How to interact with users on IRC using Python

Walter Prins wprins at gmail.com
Mon Apr 16 19:11:15 CEST 2012


On 16 April 2012 17:11, Surya K <suryak at live.com> wrote:

>  Actually, I am writing a small IRC bot for a game (A Multiplayer one).
> This how my code looks. (I this code, I am just trying to read from IRC
> client and send a message to it..)
> <snip>

> s.send("NICK %s\r\n" % NICK)
> s.send("USER %s %s bla :%s\r\n" % (IDENT, HOST, REALNAME))
> s.send("JOIN ##MyChannel\n")
> while 1:
>     readbuffer=readbuffer+s.recv(1024)
>     print readbuffer
>     s.send("text:")
>     .... # MY Code goes like this.
> <snip>

Am I right in thinking this is based on the code here? :

Does it work for you?  It appears to demonstrate the basic ability to
ping/pong a message.

Actually, I am not even aware of IRC commands.. so I thought to take some
> help to carry on

OK its many years since I've used IRC, but anyhow, I suggest you learn how
IRC works and what commands you can use -- Here's a link from a google

> This is what I require:

> As my game is quite simple, I just need to transfer a small string from
> each player to another.
> My game will have a two players.. so, Each user will join my
> ##myExampleChannel.
> Say, a player (or a IRC user) "p1" wants to play with "p2". They simply
> have to exchange private messages from each other.
> So, what IRC commands should I use and how do I typically implement them?

Probably the "/join" an the "/msg" commands.  As for how to implement it, I
found the following tutorials/pages from a google search:


Also see this library which turned up in the same search:

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20120416/74f95f58/attachment-0001.html>

More information about the Tutor mailing list