Compare commits

...
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.

6 Commits

Author SHA1 Message Date
Luke Rogers 16210639bc Fixed another issue. 2013-02-07 19:50:00 +13:00
Luke Rogers 8d8260a2f7 Edited Snowy Evening plugin. 2013-02-07 11:50:33 +13:00
Luke Rogers 971e8e4066 Merge branch 'develop' of https://github.com/nasonfish/CloudBot into feature/snowyevening 2013-02-07 11:19:16 +13:00
nasonfish 64974dc355 more work on the snowy plugin. 2013-01-31 08:02:27 -07:00
nasonfish 560f2e7516 cleanup, don't raise the error if you catch it 2013-01-28 00:09:59 -07:00
nasonfish b648706bfd Added a plugin to get data from snowy-evening.com with a regex when a link is sent. 2013-01-28 00:01:58 -07:00
2 changed files with 29 additions and 2 deletions

View File

@ -9,6 +9,8 @@ def answer(inp):
result = web.query(query, {"query": inp.strip()}).one()
short_url = web.isgd(result["Link"])
answer = text.truncate_str(result["ChosenAnswer"], 80)
return u"\x02{}\x02 {} - {}".format(result["Subject"], answer, short_url)
# we split the answer and .join() it to remove newlines/extra spaces
answer = text.truncate_str(" ".join(result["ChosenAnswer"].split()), 80)
return u"\x02{}\x02 \"{}\" - {}".format(result["Subject"], answer, short_url)

25
plugins/snowy-evening.py Normal file
View File

@ -0,0 +1,25 @@
from util import hook, http, text
import json, urllib2
import re
snowy_re = (r'(?:snowy-evening.com/)'
'([-_a-zA-Z0-9/]+)', re.I)
@hook.regex(*snowy_re)
def snowy(match, nick="", reply=""):
owner, name, id, blankSpace = match.group(1).split("/")
soup = http.get_soup("https://snowy-evening.com/%s/%s/%s" % (owner, name, id))
header = soup.find('section', {'class': 'container'}).header.h2(text=True)[1].split(" ", 1)[1]
reply("Project {} by {}: Issue #{}: {}".format(name, owner, id, text.truncate_str(header, 150)))
stats = soup.find('ul', {'id':'stats'}).find_all('strong')
if len(stats) == 6:
priority, number, type, status, age, assignee = [i.contents[0].lower() for i in stats]
else:
priority, number, type, status, age = [i.contents[0].lower() for i in stats]
if status == "assigned":
reply("This issue has a priority of \x02{}\x02. It's age is \x02{}\x02 and it is a \x02{}\x02. This issue is \x02{}\x02 to \x02{}\x02.".format(priority, age, type, status, assignee))
else:
reply("This issue has a priority of \x02{}\x02. It's age is \x02{}\x02 and it is a \x02{}\x02. It's status is \x02{}\x02.".format(priority, age, type, status))