send_reply accepts message lists now
This commit is contained in:
12
plugins.py
12
plugins.py
@@ -594,19 +594,11 @@ def data_parse_commands(msg_obj):
|
|||||||
|
|
||||||
if None != ret:
|
if None != ret:
|
||||||
if 'msg' in list(ret.keys()):
|
if 'msg' in list(ret.keys()):
|
||||||
if str == type(ret['msg']): # FIXME 2to3
|
|
||||||
ratelimit_touch(RATE_CHAT)
|
ratelimit_touch(RATE_CHAT)
|
||||||
if ratelimit_exceeded(RATE_CHAT):
|
if ratelimit_exceeded(RATE_CHAT):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
send_reply(ret['msg'], msg_obj)
|
send_reply(ret['msg'], msg_obj)
|
||||||
else:
|
|
||||||
for line in ret['msg']:
|
|
||||||
ratelimit_touch(RATE_CHAT)
|
|
||||||
if ratelimit_exceeded(RATE_CHAT):
|
|
||||||
return False
|
|
||||||
|
|
||||||
send_reply(line, msg_obj)
|
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@@ -616,10 +608,6 @@ def data_parse_commands(msg_obj):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
if 'msg' in list(ret.keys()):
|
if 'msg' in list(ret.keys()):
|
||||||
if list is type(ret['msg']):
|
|
||||||
for m in ret['msg']:
|
|
||||||
send_reply(m, msg_obj)
|
|
||||||
else:
|
|
||||||
send_reply(ret['msg'], msg_obj)
|
send_reply(ret['msg'], msg_obj)
|
||||||
|
|
||||||
funcs = {}
|
funcs = {}
|
||||||
|
|||||||
13
urlbot.py
13
urlbot.py
@@ -105,10 +105,8 @@ def extract_title(url):
|
|||||||
def send_reply(message, msg_obj):
|
def send_reply(message, msg_obj):
|
||||||
set_conf('request_counter', conf('request_counter') + 1)
|
set_conf('request_counter', conf('request_counter') + 1)
|
||||||
|
|
||||||
for m in message:
|
if str is not type(message):
|
||||||
if 0x20 > ord(m):
|
message = '\n'.join(message)
|
||||||
logger('warn', 'strange char 0x%02x in send_reply(message), skipping' % ord(m))
|
|
||||||
return False
|
|
||||||
|
|
||||||
if debug_enabled():
|
if debug_enabled():
|
||||||
print(message)
|
print(message)
|
||||||
@@ -145,9 +143,11 @@ def ratelimit_exceeded(ignored=None): # FIXME: separate counters
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
def extract_url(data, msg_obj):
|
def extract_url(data, msg_obj):
|
||||||
ret = None
|
|
||||||
result = re.findall("(https?://[^\s>]+)", data)
|
result = re.findall("(https?://[^\s>]+)", data)
|
||||||
if result:
|
if not result:
|
||||||
|
return
|
||||||
|
|
||||||
|
ret = None
|
||||||
for url in result:
|
for url in result:
|
||||||
ratelimit_touch()
|
ratelimit_touch()
|
||||||
if ratelimit_exceeded(msg_obj):
|
if ratelimit_exceeded(msg_obj):
|
||||||
@@ -207,6 +207,7 @@ def extract_url(data, msg_obj):
|
|||||||
logger('info', 'printing ' + message)
|
logger('info', 'printing ' + message)
|
||||||
send_reply(message, msg_obj)
|
send_reply(message, msg_obj)
|
||||||
ret = True
|
ret = True
|
||||||
|
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
def handle_msg(msg_obj):
|
def handle_msg(msg_obj):
|
||||||
|
|||||||
Reference in New Issue
Block a user