Prepare hooks to be used for other things than Message
This commit is contained in:
parent
877041bb12
commit
8c52f75b6a
16 changed files with 171 additions and 136 deletions
|
|
@ -34,7 +34,7 @@ def help_full():
|
|||
return "!conjugaison <tens> <verb>: give the conjugaison for <verb> in <tens>."
|
||||
|
||||
|
||||
@hook("cmd_hook", "conjugaison", help="!conjugaison <tens> <verb>: give the conjugaison for <verb> in <tens>.")
|
||||
@hook("cmd_hook", "conjugaison")
|
||||
def cmd_conjug(msg):
|
||||
if len(msg.cmds) < 3:
|
||||
raise IRCException("donne moi un temps et un verbe, et je te donnerai sa conjugaison!")
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ import traceback
|
|||
nemubotversion = 3.4
|
||||
|
||||
from event import ModuleEvent
|
||||
from hooks import Hook, hook
|
||||
from hooks import hook
|
||||
from tools.date import extractDate
|
||||
from tools.countdown import countdown_format, countdown
|
||||
|
||||
|
|
@ -60,8 +60,9 @@ def cmd_we(msg):
|
|||
"Youhou, on est en week-end depuis %s."),
|
||||
channel=msg.channel)
|
||||
|
||||
@hook("cmd_hook", "start", help="!start /something/: launch a timer")
|
||||
@hook("cmd_hook", "start")
|
||||
def start_countdown(msg):
|
||||
"""!start /something/: launch a timer"""
|
||||
if len(msg.cmds) < 2:
|
||||
raise IRCException("indique le nom d'un événement à chronométrer")
|
||||
if msg.cmds[1] in DATAS.index:
|
||||
|
|
@ -154,8 +155,9 @@ def end_countdown(msg):
|
|||
else:
|
||||
return Response(msg.sender, "%s n'est pas un compteur connu."% (msg.cmds[1]), channel=msg.channel, nick=msg.nick)
|
||||
|
||||
@hook("cmd_hook", "eventslist", help="!eventslist: gets list of timer")
|
||||
@hook("cmd_hook", "eventslist")
|
||||
def liste(msg):
|
||||
"""!eventslist: gets list of timer"""
|
||||
if len(msg.cmds) > 1:
|
||||
res = list()
|
||||
for user in msg.cmds[1:]:
|
||||
|
|
|
|||
|
|
@ -15,8 +15,8 @@ def load(context):
|
|||
"http://developer.mapquest.com/")
|
||||
return None
|
||||
|
||||
from hooks import Hook
|
||||
add_hook("cmd_hook", Hook(cmd_geocode, "geocode"))
|
||||
from hooks.messagehook import MessageHook
|
||||
add_hook("cmd_hook", MessageHook(cmd_geocode, "geocode"))
|
||||
|
||||
|
||||
def help_tiny ():
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import socket
|
|||
import subprocess
|
||||
import urllib
|
||||
|
||||
from hooks import Hook, hook
|
||||
from hooks import hook
|
||||
from tools import web
|
||||
|
||||
nemubotversion = 3.4
|
||||
|
|
@ -21,7 +21,8 @@ def load(context):
|
|||
"<whoisxmlapi username=\"XX\" password=\"XXX\" />\nRegister at "
|
||||
"http://www.whoisxmlapi.com/newaccount.php")
|
||||
else:
|
||||
add_hook("cmd_hook", Hook(cmd_whois, "netwhois"))
|
||||
from hooks.messagehook import MessageHook
|
||||
add_hook("cmd_hook", MessageHook(cmd_whois, "netwhois"))
|
||||
|
||||
def help_full():
|
||||
return "!traceurl /url/: Follow redirections from /url/."
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ def help_full():
|
|||
|
||||
LAST_SUBS = dict()
|
||||
|
||||
@hook("cmd_hook", "subreddit", help="!subreddit /subreddit/: Display information on the subreddit.")
|
||||
@hook("cmd_hook", "subreddit")
|
||||
def cmd_subreddit(msg):
|
||||
global LAST_SUBS
|
||||
if len(msg.cmds) <= 1:
|
||||
|
|
|
|||
|
|
@ -12,9 +12,9 @@ from hooks import hook
|
|||
nemubotversion = 3.4
|
||||
|
||||
def help_full():
|
||||
return "If you would like to sleep soon, use !sleepytime to know the best time to wake up; use !sleepytime hh:mm if you want to wake up at hh:mm"
|
||||
return "If you would like to sleep soon, use !sleepytime to know the best time to wake up; use !sleepytime hh:mm if you want to wake up at hh:mm"
|
||||
|
||||
@hook("cmd_hook", "sleepytime", help="If you would like to sleep soon, use !sleepytime to know the best time to wake up; use !sleepytime hh:mm if you want to wake up at hh:mm")
|
||||
@hook("cmd_hook", "sleepytime")
|
||||
def cmd_sleep(msg):
|
||||
if len (msg.cmds) > 1 and re.match("[0-9]{1,2}[h':.,-]([0-9]{1,2})?[m'\":.,-]?",
|
||||
msg.cmds[1]) is not None:
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ nemubotversion = 3.4
|
|||
def help_full():
|
||||
return "!syno <word>: give a list of synonyms for <word>."
|
||||
|
||||
@hook("cmd_hook", "synonymes", help="!syno <word>: give a list of synonyms for <word>.")
|
||||
@hook("cmd_hook", "synonymes")
|
||||
def cmd_syno(msg):
|
||||
return go("synonymes", msg)
|
||||
|
||||
|
|
|
|||
|
|
@ -28,8 +28,8 @@ def load(context):
|
|||
else:
|
||||
URL = URL % CONF.getNode("wrapi")["key"]
|
||||
|
||||
from hooks import Hook
|
||||
add_hook("cmd_hook", Hook(cmd_translate, "translate"))
|
||||
from hooks.messagehook import MessageHook
|
||||
add_hook("cmd_hook", MessageHook(cmd_translate, "translate"))
|
||||
|
||||
|
||||
def help_full():
|
||||
|
|
|
|||
|
|
@ -25,10 +25,10 @@ def load(context):
|
|||
"http://developer.forecast.io/")
|
||||
return None
|
||||
|
||||
from hooks import Hook
|
||||
add_hook("cmd_hook", Hook(cmd_weather, "météo"))
|
||||
add_hook("cmd_hook", Hook(cmd_alert, "alert"))
|
||||
add_hook("cmd_hook", Hook(cmd_coordinates, "coordinates"))
|
||||
from hooks.messagehook import MessageHook
|
||||
add_hook("cmd_hook", MessageHook(cmd_weather, "météo"))
|
||||
add_hook("cmd_hook", MessageHook(cmd_alert, "alert"))
|
||||
add_hook("cmd_hook", MessageHook(cmd_coordinates, "coordinates"))
|
||||
|
||||
|
||||
def help_full ():
|
||||
|
|
|
|||
|
|
@ -10,13 +10,11 @@ from urllib.request import urlopen
|
|||
|
||||
nemubotversion = 3.4
|
||||
|
||||
from hooks import hook
|
||||
|
||||
API_URL="http://worldcup.sfg.io/%s"
|
||||
|
||||
def load(context):
|
||||
from hooks import Hook
|
||||
add_hook("cmd_hook", Hook(cmd_watch, "watch_worldcup"))
|
||||
add_hook("cmd_hook", Hook(cmd_worldcup, "worldcup"))
|
||||
|
||||
from event import ModuleEvent
|
||||
add_event(ModuleEvent(func=lambda url: urlopen(url, timeout=10).read().decode(), func_data=API_URL % "matches/current?by_date=DESC", call=current_match_new_action, intervalle=30))
|
||||
|
||||
|
|
@ -37,6 +35,7 @@ def start_watch(msg):
|
|||
save()
|
||||
raise IRCException("This channel is now watching world cup events!")
|
||||
|
||||
@hook("cmd_hook", "watch_worldcup")
|
||||
def cmd_watch(msg):
|
||||
global DATAS
|
||||
|
||||
|
|
@ -178,6 +177,7 @@ def get_matches(url):
|
|||
if is_valid(match):
|
||||
yield match
|
||||
|
||||
@hook("cmd_hook", "worldcup")
|
||||
def cmd_worldcup(msg):
|
||||
res = Response(msg.sender, channel=msg.channel, nomore="No more match to display", count=" (%d more matches)")
|
||||
nb = len(msg.cmds)
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ def gen_response(res, msg, srv):
|
|||
else:
|
||||
raise IRCException("mauvaise URL : %s" % srv)
|
||||
|
||||
@hook("cmd_hook", "ycc", help="!ycc [<url>]: with an argument, reduce the given <url> thanks to ycc.fr; without argument, reduce the last URL said on the current channel.")
|
||||
@hook("cmd_hook", "ycc")
|
||||
def cmd_ycc(msg):
|
||||
if len(msg.cmds) == 1:
|
||||
global LAST_URLS
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue