НАСТРОЙКА ГРУППОВОЙ

This commit is contained in:
huker667 committed 2026-09-16 01:06:13 +03:00
1 parent 8eaf622b9d
commit b73f17c762
7 files changed
+309 -6

No files matched your search

+49 -3
View File
@@ -39,7 +39,7 @@ from helpers import *
from vars import *
from commands import *
from dotenv import load_dotenv
from random import uniform, shuffle, choices
from random import uniform, shuffle, choices, randint
try:
from config import *
@@ -107,8 +107,48 @@ async def guest_middleware(handler, event, data):
current_time = time.time()
stream = config.get("stream")
user_text = message.text or message.caption or ""
if is_channel and get_group_config(message.chat.id)["post_reply"] == "net":
return
if message.chat.type in [ChatType.GROUP, ChatType.SUPERGROUP] and user_text and not user_text.startswith("/"):
if message.sender_chat:
author = message.sender_chat.title or message.sender_chat.username or "канал"
elif message.from_user:
author = message.from_user.first_name or "кто-то"
else:
author = "кто-то"
if message.chat.id not in group_last_messages:
group_last_messages[message.chat.id] = []
group_last_messages[message.chat.id] = (group_last_messages[message.chat.id] + [{"user": author, "text": user_text[:200]}])[-10:]
if not is_replied_bot(message, is_channel, user_text, config) and event.message:
if (
message.chat.type in [ChatType.GROUP, ChatType.SUPERGROUP]
and message.from_user
and not message.from_user.is_bot
and message.from_user.id != 777000
):
g_config = get_group_config(message.chat.id)
if g_config["lurk"] == "da" and randint(1, 100) <= g_config["lurk_chance"]:
if randint(1, 100) <= g_config["lurk_reply_chance"]:
history = group_last_messages.get(message.chat.id, [])[-10:]
if history:
chat_log = "\n".join(f"{m['user']}: {m['text']}" for m in history)
lurk_prompt = f"<переписка юзеров>\n{chat_log}\n</переписка>\n" \
"ты узбекгпт и ты иногда подглядел за перепиской в этой группе. " \
"напиши короткое сообщение от себя в этот чат."
try:
lurk_result = await generate(
bot=bot,
prompt=lurk_prompt,
chat_id=message.chat.id,
user_id=None
)
if lurk_result:
await message.reply(lurk_result)
except Exception as e:
print(f"{RED} -- lurk - {e}{RESET}")
return
if user_id:
@@ -378,6 +418,7 @@ async def guest_middleware(handler, event, data):
if len(last_command_time[user_id][2]) == 1:
if is_channel and event.message:
g_config = get_group_config(message.chat.id)
result = await generate(
bot=bot,
prompt=prompt,
@@ -385,6 +426,7 @@ async def guest_middleware(handler, event, data):
user_id=None,
message_id=message_id,
images=images,
system_prompt=g_config["post_prompt"] if g_config["post_prompt"] else None,
)
elif event.message:
result = await generate(
@@ -435,7 +477,11 @@ async def guest_middleware(handler, event, data):
document=file
)
if POLLS and not message.chat.id in POLLS_BL:
polls_on = True
if message.chat.type in [ChatType.GROUP, ChatType.SUPERGROUP] and get_group_config(message.chat.id)["polls"] == "net":
polls_on = False
if POLLS and polls_on and not message.chat.id in POLLS_BL:
try:
if ":" in result and ("poll" in result or "quiz" in result):
pw = ["[poll]", "poll", "quiz"]