def extra_call(self, bot, update, groupdict=None):
"""
Call an extra function from slave channel.
Args:
bot: Telegram Bot instance
update: Message update
groupdict: Parameters offered by the message
"""
if int(groupdict['id']) >= len(self.slaves):
return self._reply_error(bot, update, "Invalid slave channel ID. (XC01)")
ch = self.slaves[sorted(self.slaves)[int(groupdict['id'])]]
fns = ch.get_extra_functions()
if groupdict['command'] not in fns:
return self._reply_error(bot, update, "Command not found in selected channel. (XC02)")
header = "%s %s: %s\n-------\n" % (ch.channel_emoji, ch.channel_name, fns[groupdict['command']].name)
msg = bot.send_message(update.message.chat.id, header + "Please wait...")
result = fns[groupdict['command']](" ".join(update.message.text.split(' ', 1)[1:]))
bot.editMessageText(text=header + result, chat_id=update.message.chat.id, message_id=msg.message_id)
评论列表
文章目录