本文整理匯總了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)