Apply v3.3 changes on various modules

This commit is contained in:
Némunaire 2012-11-04 04:39:54 +01:00
parent dc52593953
commit d58afa9419
5 changed files with 94 additions and 93 deletions

View File

@ -7,7 +7,7 @@ from datetime import date
from xmlparser.node import ModuleState from xmlparser.node import ModuleState
nemubotversion = 3.2 nemubotversion = 3.3
def load(context): def load(context):
global DATAS global DATAS
@ -24,10 +24,10 @@ def help_full ():
def findName(msg): 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() name = msg.nick.lower()
else: else:
name = msg.cmd[1].lower() name = msg.cmds[1].lower()
matches = [] matches = []

View File

@ -18,7 +18,7 @@
from networkbot import NetworkBot from networkbot import NetworkBot
nemubotversion = 3.2 nemubotversion = 3.3
NODATA = True NODATA = True
def getserver(toks, context, prompt): def getserver(toks, context, prompt):

View File

@ -65,7 +65,7 @@ class WFASearch:
def getPage(terms): def getPage(terms):
conn = http.client.HTTPConnection("api.wolframalpha.com", timeout=5) conn = http.client.HTTPConnection("api.wolframalpha.com", timeout=15)
try: try:
conn.request("GET", "/v2/query?input=%s&appid=%s" % (quote(terms), CONF.getNode("wfaapi")["key"])) conn.request("GET", "/v2/query?input=%s&appid=%s" % (quote(terms), CONF.getNode("wfaapi")["key"]))
except socket.gaierror: except socket.gaierror:

View File

@ -2,7 +2,7 @@
import imp import imp
nemubotversion = 3.2 nemubotversion = 3.3
from . import DDGSearch from . import DDGSearch
from . import WFASearch from . import WFASearch
@ -38,12 +38,12 @@ def reload():
def define(msg): def define(msg):
if len(msg.cmd) <= 1: if len(msg.cmds) <= 1:
return Response(msg.sender, return Response(msg.sender,
"Indicate a term to define", "Indicate a term to define",
msg.channel, nick=msg.nick) 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) res = Response(msg.sender, channel=msg.channel)
@ -53,12 +53,12 @@ def define(msg):
def search(msg): def search(msg):
if len(msg.cmd) <= 1: if len(msg.cmds) <= 1:
return Response(msg.sender, return Response(msg.sender,
"Indicate a term to search", "Indicate a term to search",
msg.channel, nick=msg.nick) 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", res = Response(msg.sender, channel=msg.channel, nomore="No more results",
count=" (%d more results)") count=" (%d more results)")
@ -75,17 +75,18 @@ def search(msg):
def calculate(msg): def calculate(msg):
if len(msg.cmd) <= 1: if len(msg.cmds) <= 1:
return Response(msg.sender, return Response(msg.sender,
"Indicate a calcul to compute", "Indicate a calcul to compute",
msg.channel, nick=msg.nick) msg.channel, nick=msg.nick)
s = WFASearch.WFASearch(' '.join(msg.cmd[1:])) s = WFASearch.WFASearch(' '.join(msg.cmds[1:]))
if s.success: if s.success:
res = Response(msg.sender, channel=msg.channel, nomore="No more results") res = Response(msg.sender, channel=msg.channel, nomore="No more results")
for result in s.nextRes: for result in s.nextRes:
res.append_message(result) res.append_message(result)
if (len(res.messages) > 0):
res.messages.pop(0) res.messages.pop(0)
return res return res
else: else:
@ -93,16 +94,16 @@ def calculate(msg):
def wiki(msg): def wiki(msg):
if len(msg.cmd) <= 1: if len(msg.cmds) <= 1:
return Response(msg.sender, return Response(msg.sender,
"Indicate a term to search", "Indicate a term to search",
msg.channel, nick=msg.nick) 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" lang = "fr"
else: else:
lang = "en" 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") res = Response(msg.sender, channel=msg.channel, nomore="No more results")
for result in s.nextRes: for result in s.nextRes:
@ -112,5 +113,5 @@ def wiki(msg):
return res return res
else: else:
return Response(msg.sender, return Response(msg.sender,
"No information about " + msg.cmd[1], "No information about " + msg.cmds[1],
msg.channel) msg.channel)

View File

@ -7,7 +7,7 @@ from xml.dom.minidom import parseString
from event import ModuleEvent from event import ModuleEvent
from xmlparser.node import ModuleState from xmlparser.node import ModuleState
nemubotversion = 3.2 nemubotversion = 3.3
def load(context): def load(context):
global DATAS global DATAS
@ -86,12 +86,12 @@ def print_station_status(msg, station):
def ask_stations(msg): def ask_stations(msg):
"""Hook entry from !velib""" """Hook entry from !velib"""
global DATAS global DATAS
if len(msg.cmd) > 5: if len(msg.cmds) > 5:
return Response(msg.sender, return Response(msg.sender,
"Demande-moi moins de stations à la fois.", "Demande-moi moins de stations à la fois.",
msg.channel, nick=msg.nick) msg.channel, nick=msg.nick)
elif len(msg.cmd) > 1: elif len(msg.cmds) > 1:
for station in msg.cmd[1:]: for station in msg.cmds[1:]:
if re.match("^[0-9]{4,5}$", station): if re.match("^[0-9]{4,5}$", station):
return print_station_status(msg, station) return print_station_status(msg, station)
elif station in DATAS.index: elif station in DATAS.index: