(wip) reworking of the Message class; backported from v4
This commit is contained in:
parent
0e26450d8f
commit
0a16321259
15 changed files with 185 additions and 178 deletions
|
|
@ -157,7 +157,7 @@ def treat_alias(msg, hooks_cache):
|
|||
and msg.cmds[0][0] == "!"
|
||||
and msg.cmds[0][1:] in DATAS.getNode("aliases").index
|
||||
and msg.cmds[0][1:] not in hooks_cache("cmd_hook")):
|
||||
msg.content = msg.content.replace(msg.cmds[0],
|
||||
msg.text = msg.text.replace(msg.cmds[0],
|
||||
DATAS.getNode("aliases").index[msg.cmds[0][1:]]["origin"], 1)
|
||||
|
||||
msg.parse_content()
|
||||
|
|
@ -166,7 +166,7 @@ def treat_alias(msg, hooks_cache):
|
|||
return True
|
||||
|
||||
else:
|
||||
msg.content = replace_variables(msg.content, msg)
|
||||
msg.text = replace_variables(msg.text, msg)
|
||||
msg.parse_content()
|
||||
return False
|
||||
return False
|
||||
|
|
@ -174,8 +174,8 @@ def treat_alias(msg, hooks_cache):
|
|||
@hook("ask_default")
|
||||
def parseask(msg):
|
||||
global ALIAS
|
||||
if re.match(".*(set|cr[ée]{2}|nouvel(le)?) alias.*", msg.content) is not None:
|
||||
result = re.match(".*alias !?([^ ]+) (pour|=|:) (.+)$", msg.content)
|
||||
if re.match(".*(set|cr[ée]{2}|nouvel(le)?) alias.*", msg.text) is not None:
|
||||
result = re.match(".*alias !?([^ ]+) (pour|=|:) (.+)$", msg.text)
|
||||
if result.group(1) in DATAS.getNode("aliases").index or result.group(3).find("alias") >= 0:
|
||||
return Response(msg.sender, "Cet alias est déjà défini.")
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ def cmd_age(msg):
|
|||
|
||||
@hook("ask_default")
|
||||
def parseask(msg):
|
||||
res = re.match(r"^(\S+)\s*('s|suis|est|is|was|were)?\s+(birthday|geburtstag|née? |nee? le|born on).*$", msg.content, re.I)
|
||||
res = re.match(r"^(\S+)\s*('s|suis|est|is|was|were)?\s+(birthday|geburtstag|née? |nee? le|born on).*$", msg.text, re.I)
|
||||
if res is not None:
|
||||
try:
|
||||
extDate = msg.extractDate()
|
||||
|
|
|
|||
|
|
@ -188,14 +188,14 @@ RGXP_ask = re.compile(r"^.*((create|new)\s+(a|an|a\s*new|an\s*other)?\s*(events?
|
|||
|
||||
@hook("ask_default")
|
||||
def parseask(msg):
|
||||
if RGXP_ask.match(msg.content) is not None:
|
||||
name = re.match("^.*!([^ \"'@!]+).*$", msg.content)
|
||||
if RGXP_ask.match(msg.text) is not None:
|
||||
name = re.match("^.*!([^ \"'@!]+).*$", msg.text)
|
||||
if name is None:
|
||||
raise IRCException("il faut que tu attribues une commande à l'événement.")
|
||||
if name.group(1) in DATAS.index:
|
||||
raise IRCException("un événement portant ce nom existe déjà.")
|
||||
|
||||
texts = re.match("^[^\"]*(avant|après|apres|before|after)?[^\"]*\"([^\"]+)\"[^\"]*((avant|après|apres|before|after)?.*\"([^\"]+)\".*)?$", msg.content, re.I)
|
||||
texts = re.match("^[^\"]*(avant|après|apres|before|after)?[^\"]*\"([^\"]+)\"[^\"]*((avant|après|apres|before|after)?.*\"([^\"]+)\".*)?$", msg.text, re.I)
|
||||
if texts is not None and texts.group(3) is not None:
|
||||
extDate = msg.extractDate()
|
||||
if extDate is None or extDate == "":
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ def parselisten(msg):
|
|||
global LAST_SUBS
|
||||
|
||||
try:
|
||||
urls = re.findall("www.reddit.com(/\w/\w+/?)", msg.content)
|
||||
urls = re.findall("www.reddit.com(/\w/\w+/?)", msg.text)
|
||||
for url in urls:
|
||||
if msg.channel not in LAST_SUBS:
|
||||
LAST_SUBS[msg.channel] = list()
|
||||
|
|
|
|||
|
|
@ -78,11 +78,11 @@ apikey_ask = re.compile(r"(clef|key|password|mot de passe?)\s+(?:est|is)?\s+(?P<
|
|||
|
||||
@hook("ask_default")
|
||||
def parseask(msg):
|
||||
if msg.content.find("Free") >= 0 and (
|
||||
msg.content.find("API") >= 0 or msg.content.find("api") >= 0) and (
|
||||
msg.content.find("SMS") >= 0 or msg.content.find("sms") >= 0):
|
||||
resuser = apiuser_ask.search(msg.content)
|
||||
reskey = apikey_ask.search(msg.content)
|
||||
if msg.text.find("Free") >= 0 and (
|
||||
msg.text.find("API") >= 0 or msg.text.find("api") >= 0) and (
|
||||
msg.text.find("SMS") >= 0 or msg.text.find("sms") >= 0):
|
||||
resuser = apiuser_ask.search(msg.text)
|
||||
reskey = apikey_ask.search(msg.text)
|
||||
if resuser is not None and reskey is not None:
|
||||
apiuser = resuser.group("user")
|
||||
apikey = reskey.group("key")
|
||||
|
|
|
|||
|
|
@ -212,7 +212,7 @@ gps_ask = re.compile(r"^\s*(?P<city>.*\w)\s*(?:(?:se|est)\s+(?:trouve|situ[ée]*
|
|||
|
||||
@hook("ask_default")
|
||||
def parseask(msg):
|
||||
res = gps_ask.match(msg.content)
|
||||
res = gps_ask.match(msg.text)
|
||||
if res is not None:
|
||||
city_name = res.group("city").lower()
|
||||
gps_lat = res.group("lat").replace(",", ".")
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ def cmd_ycc(msg):
|
|||
def parselisten(msg):
|
||||
global LAST_URLS
|
||||
try:
|
||||
urls = re.findall("([a-zA-Z0-9+.-]+:(?://)?[^ ]+)", msg.content)
|
||||
urls = re.findall("([a-zA-Z0-9+.-]+:(?://)?[^ ]+)", msg.text)
|
||||
for url in urls:
|
||||
o = urlparse(url)
|
||||
if o.scheme != "":
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue