mirror of
http://aero2k.de/t/repos/urlbot-native.git
synced 2017-09-06 15:25:38 +02:00
fix command/parser bug
This commit is contained in:
25
urlbot.py
25
urlbot.py
@@ -11,7 +11,7 @@ from common import (
|
|||||||
RATE_CHAT,
|
RATE_CHAT,
|
||||||
RATE_EVENT,
|
RATE_EVENT,
|
||||||
rate_limit,
|
rate_limit,
|
||||||
ptypes_PARSE, ptypes_COMMAND)
|
)
|
||||||
from config import runtimeconf_set
|
from config import runtimeconf_set
|
||||||
from idlebot import IdleBot, start
|
from idlebot import IdleBot, start
|
||||||
from plugins import (
|
from plugins import (
|
||||||
@@ -216,8 +216,15 @@ class UrlBot(IdleBot):
|
|||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.data_parse_commands(msg_obj)
|
reacted_on_command = self.data_parse_commands(msg_obj)
|
||||||
self.data_parse_other(msg_obj)
|
reacted_on_parse = self.data_parse_other(msg_obj)
|
||||||
|
|
||||||
|
if not any([reacted_on_command, reacted_on_parse]) \
|
||||||
|
and rate_limit(RATE_GLOBAL):
|
||||||
|
ret = else_command({'reply_user': msg_obj['from']._jid[2]})
|
||||||
|
if ret:
|
||||||
|
if 'msg' in ret:
|
||||||
|
self.send_reply(ret['msg'], msg_obj)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.logger.exception(e)
|
self.logger.exception(e)
|
||||||
|
|
||||||
@@ -265,12 +272,7 @@ class UrlBot(IdleBot):
|
|||||||
if ret:
|
if ret:
|
||||||
self._run_action(ret, plugin, msg_obj)
|
self._run_action(ret, plugin, msg_obj)
|
||||||
reacted = True
|
reacted = True
|
||||||
|
return reacted
|
||||||
if not reacted and rate_limit(RATE_GLOBAL):
|
|
||||||
ret = else_command({'reply_user': reply_user})
|
|
||||||
if ret:
|
|
||||||
if 'msg' in ret:
|
|
||||||
self.send_reply(ret['msg'], msg_obj)
|
|
||||||
|
|
||||||
def data_parse_other(self, msg_obj):
|
def data_parse_other(self, msg_obj):
|
||||||
"""
|
"""
|
||||||
@@ -280,7 +282,8 @@ class UrlBot(IdleBot):
|
|||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
data = msg_obj['body']
|
data = msg_obj['body']
|
||||||
reply_user = msg_obj['mucnick']
|
reply_user = msg_obj['mucnick'] or msg_obj['from']._jid[2]
|
||||||
|
reacted = False
|
||||||
|
|
||||||
for plugin in plugin_storage[ptypes_PARSE]:
|
for plugin in plugin_storage[ptypes_PARSE]:
|
||||||
if not plugin_enabled_get(plugin):
|
if not plugin_enabled_get(plugin):
|
||||||
@@ -290,6 +293,8 @@ class UrlBot(IdleBot):
|
|||||||
|
|
||||||
if ret:
|
if ret:
|
||||||
self._run_action(ret, plugin, msg_obj)
|
self._run_action(ret, plugin, msg_obj)
|
||||||
|
reacted = True
|
||||||
|
return reacted
|
||||||
|
|
||||||
def _run_action(self, action, plugin, msg_obj):
|
def _run_action(self, action, plugin, msg_obj):
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user