IRC client in python
Asked Answered
B

3

8

I'm writing python code for IRC client.

I want to understand how IRC client and server communicating each other.

Can anyone give me good tutorial or IRC communication architecture to understand it in depth?

Thanks

Bioscopy answered 10/11, 2010 at 17:54 Comment(0)
S
10

If you want to reinvent the wheel, then you have to implement the RFC and do everything from scratch.

If you don't want to do that and would require some level of abstraction to ease your development (and which you should), then see Twisted.

There is also a Python IRC client library.

Stylish answered 10/11, 2010 at 18:10 Comment(0)
A
12

The IRC RFC documentation is an important reference, but the most helpful first introduction I've found on communication between IRC client and server was really simple.

First, you need access to a *nix shell (e.g. ssh into your web host running Linux).

In the command line, open up a direct connection to an IRC server using the program 'nc'. Then you can type RFC commands directly, and see the response. Try typing

$ nc wright.freenode.net 6667
PASS whateveryoulike
NICK yournick
USER username 0 * :Real Name

There is output from the server amidst this, but now you've logged into and "registered" your user. Note: your nick isn't registered (ala NickServ), I'm referring to registering a user as outlined in section 3.1 of the RFC 2812 IRC Client Protocol.

You can now join a channel:

JOIN #yourtestchannel

See who's in the channel:

WHO #yourtestchannel

Send yourself a msg:

PRIVMSG yournick Message Text Here

Chat into the channel (send the channel a msg):

PRIVMSG #yourtestchannel Message Text Here

This is especially helpful if you're connected to the same server and channel with a different nick in a real IRC client. You can chat with yourself and msg one nick to the other, and see the "raw" IRC output that you'll have to parse to write your own client or bot.

For example, someone chatting in a channel looks something like this:

:SomeDude28!SomeDude28@hoststring-with_various_parts PRIVMSG #channel :Hey guys, what's up?

Using the RFC, you can play around with whatever functionality you want, and, more importantly, figure out how you'll need to parse things.

Oh, and don't forget to PONG occasionally, or when prompted with a PING, to avoid ping timeout.

Amadeo answered 7/4, 2012 at 18:59 Comment(0)
S
10

If you want to reinvent the wheel, then you have to implement the RFC and do everything from scratch.

If you don't want to do that and would require some level of abstraction to ease your development (and which you should), then see Twisted.

There is also a Python IRC client library.

Stylish answered 10/11, 2010 at 18:10 Comment(0)
R
5

For most protocols a good way to start is to look for a document called RFC. There's one for many protocols and it defines - in depth - how it should behave.

You can find the one for IRC here.

Rout answered 10/11, 2010 at 17:55 Comment(1)
@EgorSmolyakov The answer is 8 years old :-) RFC 1459 covers IRC. I updated the link for your convenience.Rout

© 2022 - 2024 — McMap. All rights reserved.