rateme
This commit is contained in:
parent
6bffb8039b
commit
0604a4fd8f
|
@ -31,10 +31,19 @@ async def messages_routing(msg, state):
|
|||
|
||||
elif bool(text):
|
||||
mid = msg.get("message_id")
|
||||
latest_toxic_message_id = await redis.get(f"toxic:{cid}")
|
||||
if text == '/toxic@welcomecenter_bot' and latest_toxic_message_id:
|
||||
scoring_msg_id = reply_msg.get("message_id") or latest_toxic_message_id
|
||||
toxic_score = await redis.get(f"toxic:{cid}:{scoring_msg_id}")
|
||||
if text == '/toxic@welcomecenter_bot':
|
||||
if not reply_msg:
|
||||
scoring_msg_id = mid
|
||||
pattern = f"toxic:{cid}:{uid}:*"
|
||||
scores = []
|
||||
async for key in client.scan_iter(pattern):
|
||||
scr = await redis.get(key)
|
||||
scores.append(scr)
|
||||
toxic_score = sum(scores)/len(scores)
|
||||
else:
|
||||
latest_toxic_message_id = await redis.get(f"toxic:{cid}")
|
||||
scoring_msg_id = reply_msg.get("message_id") or latest_toxic_message_id
|
||||
toxic_score = await redis.get(f"toxic:{cid}:{uid}:{scoring_msg_id}")
|
||||
await telegram_api(
|
||||
"sendMessage",
|
||||
chat_id=cid,
|
||||
|
@ -50,7 +59,7 @@ async def messages_routing(msg, state):
|
|||
toxic_score = detector(text)
|
||||
toxic_perc = math.floor(toxic_score*100)
|
||||
await redis.set(f"toxic:{cid}", mid)
|
||||
await redis.set(f"toxic:{cid}:{mid}", toxic_perc, ex=60*60*24*3)
|
||||
await redis.set(f"toxic:{cid}:{uid}:{mid}", toxic_perc, ex=60*60*24*3)
|
||||
logger.info(f'\ntext: {text}\ntoxic: {toxic_perc}%')
|
||||
if toxic_score > 0.81:
|
||||
if toxic_score > 0.90:
|
||||
|
|
Loading…
Reference in New Issue
Block a user