【发布时间】:2021-01-31 20:06:58
【问题描述】:
我最近从 google api serve=ive 添加了一个代码,这导致我的整个脚本除了事件之外没有响应:
@bot.event
async def on_message(msg):
analyze_request = {'comment': { 'text': msg.content }, 'requestedAttributes': {'TOXICITY': {}}}
response = service.comments().analyze(body=analyze_request).execute()
spanScore = response['attributeScores']['TOXICITY']['spanScores']
value = spanScore[0]['score']['value']
print(value * 100)
toxicity = value * 100
if toxicity > 95:
await msg.author.kick(reason = "Toxic messages")
await msg.author.send('You were kicked because you sent toxic message(s)')
await msg.send(f"{msg.author}, has been kicked for being toxic !")
elif toxicity > 70 and toxicity < 94:
await msg.channel.send(f"{msg.author.mention}, please watch your language")
感谢未来的回答者
【问题讨论】:
标签: google-api discord discord.py google-api-python-client