2015-10-05 21:54:38 +00:00
|
|
|
"""List upcoming CTFs"""
|
|
|
|
|
|
|
|
# PYTHON STUFFS #######################################################
|
|
|
|
|
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
|
2015-10-05 21:54:38 +00:00
|
|
|
from nemubot.tools.web import getURLContent, striphtml
|
2015-06-08 12:57:21 +00:00
|
|
|
from more import Response
|
2015-06-08 07:46:01 +00:00
|
|
|
|
|
|
|
|
2015-10-05 21:54:38 +00:00
|
|
|
# GLOBALS #############################################################
|
|
|
|
|
|
|
|
URL = 'https://ctftime.org/event/list/upcoming'
|
2015-06-08 07:46:01 +00:00
|
|
|
|
2015-10-05 21:54:38 +00:00
|
|
|
|
|
|
|
# MODULE INTERFACE ####################################################
|
|
|
|
|
2015-11-02 19:19:12 +00:00
|
|
|
@hook.command("ctfs",
|
2015-10-05 21:54:38 +00:00
|
|
|
help="Display the upcoming CTFs")
|
2015-06-08 07:46:01 +00:00
|
|
|
def get_info_yt(msg):
|
2015-10-05 21:54:38 +00:00
|
|
|
soup = BeautifulSoup(getURLContent(URL))
|
|
|
|
|
|
|
|
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([striphtml(x.text) for x in n]))
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
return res
|