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