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/osrc.py
2013-09-05 15:54:35 +12:00

26 lines
770 B
Python

from util import hook, http, web
from bs4 import BeautifulSoup
api_url = "http://osrc.dfm.io/{}/stats"
@hook.command
def osrc(inp):
"""osrc <github user> -- Gets an Open Source Report Card for <github user>"""
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)