Fill help in some modules

This commit is contained in:
nemunaire 2015-10-05 23:54:38 +02:00
parent e1310516fa
commit a6a10b78d1
6 changed files with 150 additions and 97 deletions

View file

@ -1,25 +1,34 @@
"""List upcoming CTFs"""
# PYTHON STUFFS #######################################################
from bs4 import BeautifulSoup
from nemubot.hooks import hook
from nemubot.tools.web import getURLContent
from nemubot.tools.web import getURLContent, striphtml
from more import Response
"""List upcoming CTFs"""
nemubotversion = 4.0
# GLOBALS #############################################################
@hook("cmd_hook", "ctfs")
URL = 'https://ctftime.org/event/list/upcoming'
# MODULE INTERFACE ####################################################
@hook("cmd_hook", "ctfs",
help="Display the upcoming CTFs")
def get_info_yt(msg):
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])
return res
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