I lost my rhythm, need to get back into blogging. I did write a devblog for EVE Online - read it here: https://community.eveonline.com/news/dev-blogs/sleeping-beauty/
In a previous blog I started discussing Xmpp and showed how to set up an Xmpp server and connecting to it via Python. In this blog I will dig deeper and show how to implement a simple echo bot. The code for this lives on Github: https://github.com/snorristurluson/xmpp-chatbot Connecting First, let's wrap the network layer. I've picked the Python 3 asyncio for this task. Let's start by looking at firstconnection.py . I've created a class called FirstConnection that inherits from asyncio.Protocol . class FirstConnection ( asyncio . Protocol ): def __init__ ( self , host ): self .host = host self .transport = None def connect ( self ): loop = asyncio.get_event_loop() handler = loop.create_connection( lambda : self , self .host, 5222 ) loop.create_task(handler) def connection_made ( self , transport ): logger.debug( " Connection made " ) self .tra...
Comments
Post a Comment