Archived
1
0
Fork 0
This repository has been archived on 2024-04-26. You can view files and clone it, but cannot push or open issues or pull requests.
akari-bot/core/tos.py

34 lines
1.4 KiB
Python
Raw Normal View History

2021-10-18 15:50:46 +00:00
from core.elements import MessageSession
2022-01-08 07:17:21 +00:00
from database import BotDBUtil
2021-10-18 15:50:46 +00:00
async def warn_target(msg: MessageSession, reason=None):
current_warns = int(msg.target.senderInfo.query.warns) + 1
msg.target.senderInfo.edit('warns', current_warns)
warn_template = ['警告:',
'根据服务条款,你已违反我们的行为准则。']
if reason is not None:
warn_template.append('具体原因:' + reason)
2021-10-20 14:04:30 +00:00
if current_warns < 5:
warn_template.append(f'这是对你的第{current_warns}次警告。如超过5次警告我们将会把你的账户加入黑名单。')
if current_warns <= 2:
warn_template.append(f'如果你有任何异议请至https://github.com/Teahouse-Studios/bot/issues/new/choose发起issue。')
if current_warns == 5:
2021-10-18 15:50:46 +00:00
warn_template.append(f'这是对你的最后一次警告。')
2021-10-20 14:04:30 +00:00
if current_warns > 5:
msg.target.senderInfo.edit('isInBlockList', True)
2021-10-18 15:50:46 +00:00
return
await msg.sendMessage('\n'.join(warn_template))
2022-01-08 07:17:21 +00:00
2022-01-08 08:08:25 +00:00
2022-01-08 07:17:21 +00:00
async def pardon_user(user: str):
BotDBUtil.SenderInfo(user).edit('warns', 0)
2022-01-08 08:08:25 +00:00
2022-01-08 07:17:21 +00:00
async def warn_user(user: str, count=1):
current_warns = int(BotDBUtil.SenderInfo(user).query.warns) + count
BotDBUtil.SenderInfo(user).edit('warns', current_warns)
if current_warns > 5:
BotDBUtil.SenderInfo(user).edit('isInBlockList', True)
return current_warns