IRC client in python - python

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

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.

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.

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.

Related

command line websocket client for Raspberry Pi2- no browser required implementation?

Send data read from GPiO to server, not only with WIFI, but also on mobile network outside anywhere. I dont have and dont want to deal with setting a public address for RPi2, so this is why I need RPi2 to be client, sending data thru websockets to server on public address. It could be node.js, python, PHP client - server, as long as it is without of the need for a browser at the client side RPi2. Any suggestions ? Thank you.
Additionally, can you please explain how would "server side node.js client" work ?
An (incomplete) list of libraries with websocket support
For Python, you could look at:
Tornado Web
Twisted Matrix
Autobahn
Crossbar.io
For node.js you could look at:
socket.io
web-socket-js
Also, you should consider editing your question. Just ask one at a time. Your second question you should research yourself, a little googling would get a link or two to a nice article explaining what you would like to know.

MQTT publish message to selected clients

I am working on MQTT and using python paho-mqtt https://pypi.python.org/pypi/paho-mqtt
I am unable to understand how can I publish msg to a specific client or list of clients?
I'll appreciate your help.
This isn't directly possible with strict MQTT, although some brokers may offer that functionality, or you can construct your application so that the topic design works to do what you need.
Although I do agree that in some cases it would be useful to send a message to a particular client (or list of clients) that's simply not how the publish/subscribe messaging paradigm works. Read more on the publish-subscribe pattern on Wikipedia. If all your system needs to do is send messages to unique clients, then I would perhaps suggest thinking of a different architecture for the system you are designing. That being said, you can leverage off pub/sub to achieve what you want using a clever topic design architecture.
For example, let's assume all clients are part of a group (list), you could think of the following topic design:
Unique per client: P2P/< client-name >
List/Group subscription: LIST/< list-name >
For example, P2P/user12345 and LIST/QA where only user12345 subscribes to P2P/user12345 but all users of the QA group subscribe to LIST/QA.
It would be the client's responsibility to ensure that it is subscribed to its own topic(s) (or if your broker allows it, you could also add the topics administratively to non-clean clients).
With this design, a publisher would be able to send a message to a specific user or all members of a defined group (list).

python irc bot ping answer

I'm trying to write a simple IRC bot in Python. My bot would connect to a server, join a channel and then print to the console the messages received by the bot.
I did it, but the server always disconnects me after a while because of ping timeout. I tried to use some libraries (python-irc and oyoyo) and they both ALLEGEDLY handle automatically the ping-pong messages with the server. But I tried with irc.abjects.net and irc.criten.net and with both of them these libraries failed.
Then I made a script based on this one: http://hawkee.com/snippet/9725/. And it failed too. So... I suppose the problem is very stupid and simple, but I jsut can't figure out a solution.
Note: with the library irc3 the ping-pong works fine, but it uses asyncio, which conflicts with some other parts of my code (not related to irc). So I can't use it.

Accept all incoming XMPP chats wokkel python

I have an XMPP client working with Google's GTalk XMPP server. I'd like to make it so that my JID/resource can receive messages from anyone (whether they are subscribed to me or not). Right now, if a client sends a messages to my username without being subscribed, Google's server returns a service-unavailable error (as it should).
<service-unavailable xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
But, I'd like to make it so that the message would go through. The use case here is to provide a public support chat entity so that users can chat me but I don't want them to be subscribed to all my activity (like status messages, etc)
Google Talk explicitly blocks messages from entities you don't share presence with as a spam prevention measure. You can't turn that off, I'm afraid.

Python twisted event based jabber/xmpp/email/irc/chat client that listens and responds to messages

I am looking to have my client "react" to a received message through some xml based communications medium. I was looking into xmpp with google talk, but I just need something that can quickly relay messages on an event based basis (i.e. without having a thread over a "check messages" function.)
I am using twisted to do the rest of my project, so if at all possible, it would be very helpful to use twisted for the rest.
wokkel is an extension of twisted words that makes it super easy to develop clients and components.
Here is echobot as an example.

Categories