2015-06-08 07:46:01 +00:00
|
|
|
from bs4 import BeautifulSoup
|
|
|
|
|
2015-06-08 12:57:21 +00:00
|
|
|
from nemubot.hooks import hook
|
|
|
|
from nemubot.tools.web import getURLContent
|
|
|
|
from more import Response
|
2015-06-08 07:46:01 +00:00
|
|
|
|
2015-06-08 12:57:21 +00:00
|
|
|
"""List upcoming CTFs"""
|
2015-06-08 07:46:01 +00:00
|
|
|
|
2015-06-08 12:57:21 +00:00
|
|
|
nemubotversion = 4.0
|
2015-06-08 07:46:01 +00:00
|
|
|
|
|
|
|
@hook("cmd_hook", "ctfs")
|
|
|
|
def get_info_yt(msg):
|
2015-06-08 12:57:21 +00:00
|
|
|
soup = BeautifulSoup(getURLContent('https://ctftime.org/event/list/upcoming'))
|
|
|
|
res = Response(channel=msg.channel, nomore="No more upcoming CTF")
|
|
|
|
for line in soup.body.find_all('tr'):
|
|
|
|
n = line.find_all('td')
|
|
|
|
if len(n) == 5:
|
|
|
|
try:
|
|
|
|
res.append_message("\x02%s:\x0F from %s type %s at %s. %s" % tuple([x.text.replace("\n", " ").strip() for x in n]))
|
|
|
|
except:
|
|
|
|
import sys
|
|
|
|
import traceback
|
|
|
|
exc_type, exc_value, _ = sys.exc_info()
|
|
|
|
sys.stderr.write(traceback.format_exception_only(exc_type, exc_value)[0])
|
2015-06-08 07:46:01 +00:00
|
|
|
return res
|