I’ve just released Gnotty 0.2 with a handful of new features which I thought would be worthwhile writing about. I wrote in greater detail about Gnotty when it was first released, but if you missed that and are wondering what it is, it’s an open source Python web application for managing an IRC channel. It provides a chat interface using WebSockets and searchable message archive - both which support mobile devices using responsive design. It also comes with programmable bots you can use to build services around the IRC channel.
Here’s a list of the new features in 0.2:
gnottify_runserverDjango management command, for running both the web and WebSocket servers together during development.
timerevent type has been added to the bot framework, for running periodic events.
The new timer events are quite simple on their own, but very interesting for Gnotty as a whole. As a feature, they simply provide the mechanism for bots to run events repeatedly at a given time interval. For Gnotty, this comes full circle in building bots that interact with external services and APIs. Since Gnotty’s first release, it has supported having data pushed to it via webhooks - custom HTTP endpoints used to send data to Gnotty, that a bot then acts upon. Now with timer events, data can be pulled by Gnotty from external sources as well.
from feedparser import parse from gnotty.bots import BaseBot, events class RSSBot(BaseBot): def __init__(self, *args, **kwargs): # Store of retrieved feed items, so we only post them once. self.feed_items = set() # Consume initial feed items without posting them. self.parse_feed(message_channel=False) super(RSSBot, self).__init__(*args, **kwargs) # Runs every 60 seconds @events.on("timer", seconds=60) def parse_feed(self, message_channel=True): for item in parse("http://blog.jupo.org/atom.xml").entries: if item["id"] not in self.feed_items: self.feed_items.add(item["id"]) if message_channel: self.message_channel("%(title)s: %(id)s" % item) return
The above example is actually included in Gnotty with the 0.2 release, with a bit more functionality implemented around error handling, as well as supporting multiple feeds.
The best validation an open source project can receive is when other developers find the project useful enough to freely contribute back to it. Gnotty is off to a good start in this regard, and a big thanks goes to Philip Neustrom, Mike Waites, and Ken Bolton for contributing features and fixes to Gnotty since its first release.