def run(self):
for plugin in plugins_list:
res = import_plugin('plugins.{plugin}'.format(plugin=plugin))
for patt in res.patterns:
matches = regex(patt, self.msg_text)
if matches:
if 'admin_plugin' in res.config:
if res.config['admin_plugin']:
if self.chat_id == admins[self.bot_type]:
add_log('Safe user' + str(self.chat_id),
'Admin Plugin'
)
self.plugin = plugin
self.matches = matches
self.trigger = patt
# Status
incr_database(table='status', name='allbot_usage')
incr_database(table='status',
name=str('bot_usage:' + self.bot_type)
)
incr_database(table='status',
name=str('plugin_usage:' + plugin)
)
if self.bot_type == 'telegram-inline':
incr_database(table='status',
name=str('inline_usage')
)
# Get user_lang
self.user_lang = get_user_lang(self)
if self.debug:
add_log('{cmd} - {plugin}: {text} '.format(
cmd = patt,
plugin = plugin,
text = self.msg_text
),
'[TRIGGER]'
)
if self.dev_mode:
res.run(self, matches.group(1), matches)
else:
try:
res.run(self, matches.group(1), matches)
except Exception as err:
add_log('Failed run_plugin: {}'.format(err),
'Error in bot!',
True, True
)
if self.send_falid_plugin:
sendFalid(self, title='BOT', reason='generic')
评论列表
文章目录