plugins/freshmeat_plugin.py
author Mikael Berthe <mikael@lilotux.net>
Sat, 19 May 2007 15:22:09 +0200
changeset 38 a81dc352e96e
parent 17 069f7fd5545d
permissions -rw-r--r--
rss_plugin: remove trailing whitespace

#$ neutron_plugin 01

import urllib
from xml.dom.minidom import parse, parseString

def getVal(dom, var):
    return dom.getElementsByTagName(var)[0].childNodes[0].nodeValue

def handler_fm(type, source, pn):
    data = urllib.urlopen('http://freshmeat.net/projects-xml/' + pn).read()
    try:
        dom = parseString(data)
        reply = "*" + getVal(dom, "projectname_full")
        reply += "* (" + getVal(dom, "rating") + ") "
        reply += getVal(dom, "desc_full") + " " + getVal(dom, "url_homepage")
    except:
        reply = "This project not found on FreshMeat.net, sorry"
    smsg(type, source, reply)

register_command_handler(handler_fm, '!fm', 0, 'Gives information about program from FreshMeat.net', '!fm program', ['!fm', '!fm Gajim'])