Hey, check out my latest project: Kouio RSS reader

Gnotty 0.2 Released

December 25, 2012  /  Home

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.

What’s New

Here’s a list of the new features in 0.2:

Push and Pull

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.

Here’s an example bot that implements a timer event. It uses Mark Pilgrim’s feedparser library to consume my blog’s RSS feed, posting new items to the IRC channel as they’re discovered:

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.

Thank you

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.

Do you have an idea for a cool feature Gnotty could provide? Go right ahead and send a pull request on either GitHub or Bitbucket!

Keywords  /  Home