This repository has been archived on 2023-04-13. You can view files and clone it, but cannot push or open issues or pull requests.
CloudBot/plugins/osrc.py

28 lines
827 B
Python
Raw Normal View History

2013-09-05 05:54:35 +02:00
from util import hook, http, web
from bs4 import BeautifulSoup
api_url = "http://osrc.dfm.io/{}/stats"
2013-09-05 06:01:01 +02:00
user_url = "http://osrc.dfm.io/{}"
2013-09-05 05:54:35 +02:00
@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"])
2013-11-12 07:06:06 +01:00
response["work_time"] = soup.find("a", {"href": "#day"}).contents[0]
2013-09-05 05:54:35 +02:00
2013-09-05 06:01:01 +02:00
response["short_url"] = web.try_isgd(user_url.format(user_nick))
2013-09-05 05:54:35 +02:00
return "{nick} is a {lang_user}. {nick} is a {hacker_type} " \
"who seems to {work_time} - {short_url}".format(**response)