本文整理汇总了Python中Core.Util.UtilBot.change_karma方法的典型用法代码示例。如果您正苦于以下问题:Python UtilBot.change_karma方法的具体用法?Python UtilBot.change_karma怎么用?Python UtilBot.change_karma使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Core.Util.UtilBot
的用法示例。
在下文中一共展示了UtilBot.change_karma方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _karma
# 需要导入模块: from Core.Util import UtilBot [as 别名]
# 或者: from Core.Util.UtilBot import change_karma [as 别名]
def _karma(bot, event, *args):
username = ' '.join(args)
username = username.replace('@', '')
add = username.count("+")
sub = username.count("-")
if add > 6:
add = 6
if sub > 6:
sub = 6
username = username.replace("+", "")
username = username.replace("-", "")
username = username.lower()
for u in sorted(event.conv.users, key=lambda x: x.full_name.split()[-1]):
if username not in u.full_name.lower():
continue
if u.id_ == event.user.id_:
bot.send_message(event.conv, "Your Karma changes with actions upon others, not actions upon oneself.")
return
new_karma = None
if add >= 2 and sub == 0:
new_karma = UtilBot.change_karma(u.id_[0], add - 1)
elif sub >= 2 and add == 0:
new_karma = UtilBot.change_karma(u.id_[0], (sub - 1) * -1)
if new_karma is not None:
bot.send_message(event.conv, "{}'s karma is now {}".format(u.full_name, new_karma))
return
yield from bot._client.settyping(event.conv_id, schemas.TypingStatus.STOPPED)