本文整理汇总了Python中bot.Bot.on_text_message方法的典型用法代码示例。如果您正苦于以下问题:Python Bot.on_text_message方法的具体用法?Python Bot.on_text_message怎么用?Python Bot.on_text_message使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bot.Bot
的用法示例。
在下文中一共展示了Bot.on_text_message方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: on_text_message
# 需要导入模块: from bot import Bot [as 别名]
# 或者: from bot.Bot import on_text_message [as 别名]
def on_text_message(self, from_user, to_users, to_channels, tree_ids, message):
# Only answer to direct messages, not channel messages.
cmd = shlex.split(message.encode('ascii', 'ignore'))
if self.state.user in to_users:
for p in self.__prefixes.keys():
if cmd[0].startswith(p):
cmd[0] = cmd[0][len(p):]
func = getattr(self, self.__prefixes[p])
func(from_user, *cmd)
return
if self.state.channel in to_channels:
for p in self.__channel_prefixes.keys():
if cmd[0].startswith(p):
cmd[0] = cmd[0][len(p):]
func = getattr(self, self.__channel_prefixes[p])
func(from_user, *cmd)
return
Bot.on_text_message(self, from_user, to_users, to_channels, tree_ids,
message)