ruffed
This commit is contained in:
@@ -2,14 +2,14 @@ from bot.config import FEEDBACK_CHAT_ID
|
||||
from bot.announce import edit_announce
|
||||
from bot.api import telegram_api
|
||||
import logging
|
||||
from utils.store import get_all_pattern, get_average_pattern
|
||||
from state.scan import get_all_pattern, get_average_pattern
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
|
||||
start_message = {
|
||||
'en': "Welcome home! You can type any message here to be passed to chat",
|
||||
'ru': "Доброе утро! Можешь напечатать здесь любое сообщение для передачи в чат"
|
||||
"en": "Welcome home! You can type any message here to be passed to chat",
|
||||
"ru": "Доброе утро! Можешь напечатать здесь любое сообщение для передачи в чат",
|
||||
}
|
||||
|
||||
|
||||
@@ -21,25 +21,35 @@ async def handle_private(msg, state):
|
||||
if lang != "ru" and lang != "en":
|
||||
lang = "en"
|
||||
if text and text.startswith("/"):
|
||||
if text == '/start':
|
||||
if text == "/start":
|
||||
await telegram_api("sendMessage", chat_id=uid, text=start_message[lang])
|
||||
state['welcome'] = True
|
||||
elif state.get('welcome'):
|
||||
state["welcome"] = True
|
||||
elif state.get("welcome"):
|
||||
await edit_announce(msg)
|
||||
state['welcome'] = False
|
||||
state["welcome"] = False
|
||||
return
|
||||
elif text.startswith('/toxic'):
|
||||
elif text.startswith("/toxic"):
|
||||
cid = msg.get("chat", {}).get("id")
|
||||
toxic_pattern = f"toxic:{uid}:{cid}:*"
|
||||
toxic_score = await get_average_toxic(toxic_pattern)
|
||||
toxic_score = await get_average_pattern(toxic_pattern)
|
||||
text = f"Средняя токсичность сообщений: {toxic_score}%"
|
||||
mid = msg.get("message_id")
|
||||
await telegram_api("sendMessage", chat_id=uid, reply_to_message_id=mid, text=text)
|
||||
await telegram_api(
|
||||
"sendMessage", chat_id=uid, reply_to_message_id=mid, text=text
|
||||
)
|
||||
return
|
||||
elif text == '/removed':
|
||||
elif text == "/removed":
|
||||
removed_pattern = f"removed:{uid}:*"
|
||||
removed_messages = await get_all_pattern(removed_pattern)
|
||||
if removed_messages:
|
||||
await telegram_api("sendMessage", chat_id=uid, text="\n\n".join(removed_messages))
|
||||
await telegram_api(
|
||||
"sendMessage", chat_id=uid, text="\n\n".join(removed_messages)
|
||||
)
|
||||
return
|
||||
|
||||
await telegram_api("forwardMessage", from_chat_id=sender.get("id"), message_id=msg.get("message_id"), chat_id=FEEDBACK_CHAT_ID)
|
||||
await telegram_api(
|
||||
"forwardMessage",
|
||||
from_chat_id=sender.get("id"),
|
||||
message_id=msg.get("message_id"),
|
||||
chat_id=FEEDBACK_CHAT_ID,
|
||||
)
|
||||
|
Reference in New Issue
Block a user