Apply v3.3 changes on various modules
This commit is contained in:
parent
dc52593953
commit
d58afa9419
@ -7,7 +7,7 @@ from datetime import date
|
||||
|
||||
from xmlparser.node import ModuleState
|
||||
|
||||
nemubotversion = 3.2
|
||||
nemubotversion = 3.3
|
||||
|
||||
def load(context):
|
||||
global DATAS
|
||||
@ -24,10 +24,10 @@ def help_full ():
|
||||
|
||||
|
||||
def findName(msg):
|
||||
if len(msg.cmd) < 2 or msg.cmd[1].lower() == "moi" or msg.cmd[1].lower() == "me":
|
||||
if len(msg.cmds) < 2 or msg.cmds[1].lower() == "moi" or msg.cmds[1].lower() == "me":
|
||||
name = msg.nick.lower()
|
||||
else:
|
||||
name = msg.cmd[1].lower()
|
||||
name = msg.cmds[1].lower()
|
||||
|
||||
matches = []
|
||||
|
||||
|
@ -18,7 +18,7 @@
|
||||
|
||||
from networkbot import NetworkBot
|
||||
|
||||
nemubotversion = 3.2
|
||||
nemubotversion = 3.3
|
||||
NODATA = True
|
||||
|
||||
def getserver(toks, context, prompt):
|
||||
|
@ -65,7 +65,7 @@ class WFASearch:
|
||||
|
||||
|
||||
def getPage(terms):
|
||||
conn = http.client.HTTPConnection("api.wolframalpha.com", timeout=5)
|
||||
conn = http.client.HTTPConnection("api.wolframalpha.com", timeout=15)
|
||||
try:
|
||||
conn.request("GET", "/v2/query?input=%s&appid=%s" % (quote(terms), CONF.getNode("wfaapi")["key"]))
|
||||
except socket.gaierror:
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
import imp
|
||||
|
||||
nemubotversion = 3.2
|
||||
nemubotversion = 3.3
|
||||
|
||||
from . import DDGSearch
|
||||
from . import WFASearch
|
||||
@ -38,12 +38,12 @@ def reload():
|
||||
|
||||
|
||||
def define(msg):
|
||||
if len(msg.cmd) <= 1:
|
||||
if len(msg.cmds) <= 1:
|
||||
return Response(msg.sender,
|
||||
"Indicate a term to define",
|
||||
msg.channel, nick=msg.nick)
|
||||
|
||||
s = DDGSearch.DDGSearch(' '.join(msg.cmd[1:]))
|
||||
s = DDGSearch.DDGSearch(' '.join(msg.cmds[1:]))
|
||||
|
||||
res = Response(msg.sender, channel=msg.channel)
|
||||
|
||||
@ -53,12 +53,12 @@ def define(msg):
|
||||
|
||||
|
||||
def search(msg):
|
||||
if len(msg.cmd) <= 1:
|
||||
if len(msg.cmds) <= 1:
|
||||
return Response(msg.sender,
|
||||
"Indicate a term to search",
|
||||
msg.channel, nick=msg.nick)
|
||||
|
||||
s = DDGSearch.DDGSearch(' '.join(msg.cmd[1:]))
|
||||
s = DDGSearch.DDGSearch(' '.join(msg.cmds[1:]))
|
||||
|
||||
res = Response(msg.sender, channel=msg.channel, nomore="No more results",
|
||||
count=" (%d more results)")
|
||||
@ -75,17 +75,18 @@ def search(msg):
|
||||
|
||||
|
||||
def calculate(msg):
|
||||
if len(msg.cmd) <= 1:
|
||||
if len(msg.cmds) <= 1:
|
||||
return Response(msg.sender,
|
||||
"Indicate a calcul to compute",
|
||||
msg.channel, nick=msg.nick)
|
||||
|
||||
s = WFASearch.WFASearch(' '.join(msg.cmd[1:]))
|
||||
s = WFASearch.WFASearch(' '.join(msg.cmds[1:]))
|
||||
|
||||
if s.success:
|
||||
res = Response(msg.sender, channel=msg.channel, nomore="No more results")
|
||||
for result in s.nextRes:
|
||||
res.append_message(result)
|
||||
if (len(res.messages) > 0):
|
||||
res.messages.pop(0)
|
||||
return res
|
||||
else:
|
||||
@ -93,16 +94,16 @@ def calculate(msg):
|
||||
|
||||
|
||||
def wiki(msg):
|
||||
if len(msg.cmd) <= 1:
|
||||
if len(msg.cmds) <= 1:
|
||||
return Response(msg.sender,
|
||||
"Indicate a term to search",
|
||||
msg.channel, nick=msg.nick)
|
||||
if msg.cmd[0] == "w" or msg.cmd[0] == "wf" or msg.cmd[0] == "wfr":
|
||||
if msg.cmds[0] == "w" or msg.cmds[0] == "wf" or msg.cmds[0] == "wfr":
|
||||
lang = "fr"
|
||||
else:
|
||||
lang = "en"
|
||||
|
||||
s = Wikipedia.Wikipedia(' '.join(msg.cmd[1:]), lang)
|
||||
s = Wikipedia.Wikipedia(' '.join(msg.cmds[1:]), lang)
|
||||
|
||||
res = Response(msg.sender, channel=msg.channel, nomore="No more results")
|
||||
for result in s.nextRes:
|
||||
@ -112,5 +113,5 @@ def wiki(msg):
|
||||
return res
|
||||
else:
|
||||
return Response(msg.sender,
|
||||
"No information about " + msg.cmd[1],
|
||||
"No information about " + msg.cmds[1],
|
||||
msg.channel)
|
||||
|
@ -7,7 +7,7 @@ from xml.dom.minidom import parseString
|
||||
from event import ModuleEvent
|
||||
from xmlparser.node import ModuleState
|
||||
|
||||
nemubotversion = 3.2
|
||||
nemubotversion = 3.3
|
||||
|
||||
def load(context):
|
||||
global DATAS
|
||||
@ -86,12 +86,12 @@ def print_station_status(msg, station):
|
||||
def ask_stations(msg):
|
||||
"""Hook entry from !velib"""
|
||||
global DATAS
|
||||
if len(msg.cmd) > 5:
|
||||
if len(msg.cmds) > 5:
|
||||
return Response(msg.sender,
|
||||
"Demande-moi moins de stations à la fois.",
|
||||
msg.channel, nick=msg.nick)
|
||||
elif len(msg.cmd) > 1:
|
||||
for station in msg.cmd[1:]:
|
||||
elif len(msg.cmds) > 1:
|
||||
for station in msg.cmds[1:]:
|
||||
if re.match("^[0-9]{4,5}$", station):
|
||||
return print_station_status(msg, station)
|
||||
elif station in DATAS.index:
|
||||
|
Loading…
Reference in New Issue
Block a user