Dusting modules
This commit is contained in:
parent
b5e4acdb70
commit
4bc8bc3c12
2 changed files with 21 additions and 23 deletions
|
|
@ -9,7 +9,7 @@ from nemubot.event import ModuleEvent
|
||||||
from nemubot.hooks import hook
|
from nemubot.hooks import hook
|
||||||
from nemubot.tools.countdown import countdown_format
|
from nemubot.tools.countdown import countdown_format
|
||||||
|
|
||||||
nemubotversion = 3.4
|
nemubotversion = 4.0
|
||||||
|
|
||||||
from more import Response
|
from more import Response
|
||||||
|
|
||||||
|
|
@ -54,7 +54,7 @@ def cmd_newyear(msg, yr):
|
||||||
|
|
||||||
@hook("cmd_rgxp", data=yrn, regexp="^[0-9]{4}$")
|
@hook("cmd_rgxp", data=yrn, regexp="^[0-9]{4}$")
|
||||||
def cmd_timetoyear(msg, cur):
|
def cmd_timetoyear(msg, cur):
|
||||||
yr = int(msg.cmds[0])
|
yr = int(msg.cmd)
|
||||||
|
|
||||||
if yr == cur:
|
if yr == cur:
|
||||||
return None
|
return None
|
||||||
|
|
|
||||||
|
|
@ -1,35 +1,33 @@
|
||||||
import urllib.request
|
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
|
from urllib.parse import quote
|
||||||
|
|
||||||
from nemubot.hooks import hook
|
from nemubot.hooks import hook
|
||||||
|
from nemubot.tools.web import getURLContent
|
||||||
from more import Response
|
from more import Response
|
||||||
|
|
||||||
nemubotversion = 3.4
|
"""CVE description"""
|
||||||
|
|
||||||
def help_tiny():
|
nemubotversion = 4.0
|
||||||
return "CVE description"
|
|
||||||
|
|
||||||
def help_full():
|
BASEURL_MITRE = 'http://cve.mitre.org/cgi-bin/cvename.cgi?name='
|
||||||
return "No help "
|
|
||||||
|
|
||||||
|
|
||||||
|
def get_cve(cve_id):
|
||||||
|
search_url = BASEURL_MITRE + quote(cve_id.upper())
|
||||||
|
|
||||||
|
soup = BeautifulSoup(getURLContent(search_url))
|
||||||
|
desc = soup.body.findAll('td')
|
||||||
|
|
||||||
|
return desc[17].text.replace("\n", " ") + " Moar at " + search_url
|
||||||
|
|
||||||
@hook("cmd_hook", "cve")
|
@hook("cmd_hook", "cve")
|
||||||
def get_cve_desc(msg):
|
def get_cve_desc(msg):
|
||||||
DESC_INDEX = 17
|
res = Response(channel=msg.channel)
|
||||||
BASEURL_MITRE = 'http://cve.mitre.org/cgi-bin/cvename.cgi?name='
|
|
||||||
|
|
||||||
cve_id = ''
|
for cve_id in msg.args:
|
||||||
|
if cve_id[:3].lower() != 'cve':
|
||||||
|
cve_id = 'cve-' + cve_id
|
||||||
|
|
||||||
if msg.cmds[1][:3].lower() == 'cve':
|
res.append_message(get_cve(cve_id))
|
||||||
cve_id = msg.cmds[1]
|
|
||||||
|
|
||||||
else:
|
return res
|
||||||
cve_id = 'cve-' + msg.cmds[1]
|
|
||||||
|
|
||||||
search_url = BASEURL_MITRE + cve_id.upper()
|
|
||||||
|
|
||||||
url = urllib.request.urlopen(search_url)
|
|
||||||
soup = BeautifulSoup(url)
|
|
||||||
|
|
||||||
desc = soup.body.findAll('td')
|
|
||||||
|
|
||||||
return Response(desc[DESC_INDEX].text.replace("\n", " ") + " Moar at " + search_url, msg.channel)
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue