routing-fix
This commit is contained in:
@@ -2,6 +2,7 @@ from bot.config import FEEDBACK_CHAT_ID
|
||||
from bot.announce import edit_announce
|
||||
from bot.api import telegram_api
|
||||
import logging
|
||||
from store import get_all_removed
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
@@ -11,15 +12,20 @@ start_message = {
|
||||
'ru': "Доброе утро! Можешь напечатать здесь любое сообщение для передачи в чат"
|
||||
}
|
||||
|
||||
|
||||
async def handle_private(msg, state):
|
||||
text = msg.get("text")
|
||||
sender = msg.get("from", {})
|
||||
uid = sender.get("id")
|
||||
lang = sender.get("language_code", "ru")
|
||||
if lang != "ru" and lang != "en":
|
||||
lang = "en"
|
||||
if text.startswith("/"):
|
||||
if text == '/start':
|
||||
await telegram_api("sendMessage", chat_id=sender.get("id"), text=start_message[lang])
|
||||
await telegram_api("sendMessage", chat_id=uid, text=start_message[lang])
|
||||
elif text == '/removed':
|
||||
removed_messages = await get_all_removed(uid)
|
||||
await telegram_api("sendMessage", chat_id=uid, text="\n".join(removed_messages.values()))
|
||||
else:
|
||||
await telegram_api("forwardMessage", from_chat_id=sender.get("id"), message_id=msg.get("id"), chat_id=FEEDBACK_CHAT_ID)
|
||||
else:
|
||||
|
@@ -1,6 +1,6 @@
|
||||
import logging
|
||||
import math
|
||||
|
||||
from store import redis
|
||||
from bot.api import telegram_api
|
||||
from bot.config import FEEDBACK_CHAT_ID
|
||||
from nlp.toxicity_detector import detector
|
||||
@@ -36,8 +36,9 @@ async def messages_routing(msg, state):
|
||||
logger.info(f'\ntext: {text}\ntoxic: {math.floor(toxic_score*100)}%')
|
||||
if toxic_score > 0.71:
|
||||
if toxic_score > 0.85:
|
||||
await redis.execute("SET", f"removed:{uid}:{cid}:{mid}", text)
|
||||
await telegram_api(
|
||||
"deletemessage",
|
||||
"deleteMessage",
|
||||
chat_id=cid,
|
||||
message_id=mid
|
||||
)
|
||||
|
Reference in New Issue
Block a user