This repository has been archived on 2023-04-13. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
CloudBot/plugins/rss.py
Luke Rogers 3b5fe6f4bb .
2012-10-17 11:24:25 +13:00

33 lines
893 B
Python

from util import hook, web, text
@hook.command("feed")
@hook.command
def rss(inp, say=None):
limit = 3
# preset news feeds
strip = inp.lower().strip()
if strip == "bukkit":
feed = "http://dl.bukkit.org/downloads/craftbukkit/feeds/latest-rb.rss"
limit = 1
elif strip == "xkcd":
feed = "http://xkcd.com/rss.xml"
elif strip == "ars":
feed = "http://feeds.arstechnica.com/arstechnica/index"
else:
feed = inp
query = "SELECT title, link FROM rss WHERE url=@feed LIMIT @limit"
result = web.query(query, {"feed": feed, "limit": limit})
for row in result.rows:
title = text.truncate_str(row["title"], 100)
link = web.isgd(row["link"])
say(u"{} - {}".format(title, link))
@hook.command
def rb(inp, say=None):
"rb -- Shows the latest Craftbukkit recommended build"
rss("bukkit", say)