added open source report card plugin
This commit is contained in:
parent
6247409906
commit
80dd3ad573
1 changed files with 26 additions and 0 deletions
26
plugins/osrc.py
Normal file
26
plugins/osrc.py
Normal file
|
@ -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 <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)
|
Reference in a new issue