removed-fix2
This commit is contained in:
parent
ca5f22ec0f
commit
08024e81fc
|
@ -32,30 +32,22 @@ async def messages_routing(msg, state):
|
||||||
elif bool(text):
|
elif bool(text):
|
||||||
mid = msg.get("message_id")
|
mid = msg.get("message_id")
|
||||||
if text == '/toxic@welcomecenter_bot':
|
if text == '/toxic@welcomecenter_bot':
|
||||||
text = ''
|
latest_toxic_message_id = await redis.get(f"toxic:{cid}")
|
||||||
toxic_score = 0
|
pattern = f"toxic:{cid}:{uid}:*"
|
||||||
if not reply_msg:
|
scores = []
|
||||||
logger.debug(f'scoring average for {uid}')
|
async for key in redis.scan_iter(pattern):
|
||||||
scoring_msg_id = mid
|
scr = int(await redis.get(key))
|
||||||
pattern = f"toxic:{cid}:{uid}:*"
|
scores.append(scr)
|
||||||
scores = []
|
toxic_score = math.floor(sum(scores)/len(scores)) if scores else 0
|
||||||
async for key in redis.scan_iter(pattern):
|
scoring_msg_id = reply_msg.get("message_id") or int(latest_toxic_message_id)
|
||||||
scr = int(await redis.get(key))
|
one_score = await redis.get(f"toxic:{cid}:{uid}:{scoring_msg_id}")
|
||||||
scores.append(scr)
|
emoji = '😳' if toxic_score > 90 else '😟' if toxic_score > 80 else '😏' if toxic_score > 60 else '🙂' if toxic_score > 20 else '😇'
|
||||||
toxic_score = math.floor(sum(scores)/len(scores)) if scores else 0
|
text = f"{int(one_score)}% токсичности\nСредняя токсичность сообщений: {toxic_score}% {emoji}"
|
||||||
emoji = '😳' if toxic_score > 90 else '😟' if toxic_score > 80 else '😏' if toxic_score > 60 else '🙂' if toxic_score > 20 else '😇'
|
await telegram_api(
|
||||||
text = f"Доброе утро! Средняя токсичность твоих сообщений: {toxic_score}% {emoji}"
|
"deleteMessage",
|
||||||
else:
|
chat_id=cid,
|
||||||
latest_toxic_message_id = await redis.get(f"toxic:{cid}")
|
message_id=mid
|
||||||
scoring_msg_id = reply_msg.get("message_id") or int(latest_toxic_message_id)
|
)
|
||||||
toxic_score = await redis.get(f"toxic:{cid}:{uid}:{scoring_msg_id}")
|
|
||||||
x = int(toxic_score) if toxic_score else 0
|
|
||||||
text = f"{x}% токсичности"
|
|
||||||
await telegram_api(
|
|
||||||
"deleteMessage",
|
|
||||||
chat_id=cid,
|
|
||||||
message_id=mid
|
|
||||||
)
|
|
||||||
if text:
|
if text:
|
||||||
await telegram_api(
|
await telegram_api(
|
||||||
"sendMessage",
|
"sendMessage",
|
||||||
|
|
Loading…
Reference in New Issue
Block a user