linter+fmt
This commit is contained in:
@@ -11,7 +11,6 @@ from nlp.toxicity_detector import detector
|
||||
logger = logging.getLogger("handlers.messages_routing")
|
||||
|
||||
|
||||
|
||||
async def messages_routing(msg, state):
|
||||
cid = msg["chat"]["id"]
|
||||
uid = msg["from"]["id"]
|
||||
@@ -53,13 +52,13 @@ async def messages_routing(msg, state):
|
||||
# count average between all of messages
|
||||
toxic_pattern = f"toxic:{cid}:{uid}:*"
|
||||
toxic_score = await get_average_pattern(toxic_pattern)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# current mesasage toxicity
|
||||
if reply_to_msg_id:
|
||||
one_score = await redis.get(f"toxic:{cid}:{uid}:{reply_to_msg_id}")
|
||||
reply_text = ''
|
||||
reply_text = ""
|
||||
if one_score:
|
||||
logger.debug(one_score)
|
||||
reply_text += f"{int(one_score)}% токсичности\n"
|
||||
@@ -75,7 +74,9 @@ async def messages_routing(msg, state):
|
||||
if toxic_score > 20
|
||||
else "😇"
|
||||
)
|
||||
reply_text += "Средняя токсичность сообщений: {toxic_score}% {emoji}"
|
||||
reply_text += (
|
||||
f"Средняя токсичность сообщений: {toxic_score}% {emoji}"
|
||||
)
|
||||
if reply_text:
|
||||
await telegram_api(
|
||||
"sendMessage",
|
||||
@@ -85,12 +86,12 @@ async def messages_routing(msg, state):
|
||||
)
|
||||
try:
|
||||
await telegram_api("deleteMessage", chat_id=cid, message_id=mid)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
elif text == "/removed@welcomecenter_bot":
|
||||
try:
|
||||
await telegram_api("deleteMessage", chat_id=cid, message_id=mid)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
else:
|
||||
toxic_score = detector(text)
|
||||
@@ -103,7 +104,7 @@ async def messages_routing(msg, state):
|
||||
await redis.set(f"removed:{uid}:{cid}:{mid}", text)
|
||||
try:
|
||||
await telegram_api("deleteMessage", chat_id=cid, message_id=mid)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
else:
|
||||
await telegram_api(
|
||||
|
Reference in New Issue
Block a user