From 80dd3ad5737115fd81387ca8399a072957fac9c7 Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Thu, 5 Sep 2013 15:54:35 +1200 Subject: [PATCH] added open source report card plugin --- plugins/osrc.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 plugins/osrc.py diff --git a/plugins/osrc.py b/plugins/osrc.py new file mode 100644 index 0000000..a5b911e --- /dev/null +++ b/plugins/osrc.py @@ -0,0 +1,26 @@ +from util import hook, http, web +from bs4 import BeautifulSoup + +api_url = "http://osrc.dfm.io/{}/stats" + + +@hook.command +def osrc(inp): + """osrc -- Gets an Open Source Report Card for """ + + user_nick = inp.strip() + url = api_url.format(user_nick) + + try: + response = http.get_json(url) + except (http.HTTPError, http.URLError): + return "Couldn't find any stats for this user." + + response["nick"] = user_nick + soup = BeautifulSoup(response["summary"]) + response["work_time"] = soup.find("a", {"href" : "#day"}).contents[0] + + response["short_url"] = web.try_isgd(url) + + return "{nick} is a {lang_user}. {nick} is a {hacker_type} " \ + "who seems to {work_time} - {short_url}".format(**response)