first commit
This commit is contained in:
commit
b027361586
11 files changed
+1335
No files matched your search
+211
@@ -0,0 +1,211 @@
|
||||
from io import BytesIO
|
||||
from typing import Optional, Union
|
||||
|
||||
from aiogram import Bot, Dispatcher, F, Router
|
||||
from aiogram.client.default import DefaultBotProperties
|
||||
from aiogram.enums import ChatAction, ChatType
|
||||
from aiogram.exceptions import TelegramForbiddenError
|
||||
from aiogram.filters import Command
|
||||
from aiogram.types import (
|
||||
BufferedInputFile,
|
||||
CallbackQuery,
|
||||
ChosenInlineResult,
|
||||
InlineKeyboardButton,
|
||||
InlineKeyboardMarkup,
|
||||
InlineQuery,
|
||||
InlineQueryResultArticle,
|
||||
InputTextMessageContent,
|
||||
Message,
|
||||
User,
|
||||
)
|
||||
from aiogram.utils.deep_linking import create_start_link
|
||||
|
||||
from colors import *
|
||||
from config import *
|
||||
from supergenerator import *
|
||||
|
||||
router = Router()
|
||||
|
||||
|
||||
@router.message(Command("broadcast"))
|
||||
async def broadcast_handler(message: Message):
|
||||
if message.from_user.id != ADMIN_ID:
|
||||
return await message.reply("🚫 pashol naxxuy.")
|
||||
|
||||
text = message.text.removeprefix("/broadcast").strip()
|
||||
if not text:
|
||||
return await message.reply("🚫 напиши текст после команды ало.")
|
||||
|
||||
users = get_all_user_ids()
|
||||
|
||||
success = 0
|
||||
failed = 0
|
||||
|
||||
for user_id in users:
|
||||
try:
|
||||
if user_id > 0:
|
||||
await message.bot.send_message(user_id, text)
|
||||
success += 1
|
||||
except TelegramForbiddenError:
|
||||
failed += 1
|
||||
except Exception as e:
|
||||
print(f"{RED} -- broadcast err - {e}{RESET}")
|
||||
failed += 1
|
||||
|
||||
await message.reply(
|
||||
f"✅ *готово врат.*\n- успешно: {success}\n- не удалось: {failed}"
|
||||
)
|
||||
|
||||
|
||||
@router.message(Command("start"))
|
||||
async def start_handler(message: Message):
|
||||
if message.chat.type in [ChatType.GROUP, ChatType.SUPERGROUP]:
|
||||
await message.reply(
|
||||
"привет, запусти эту команду в ЛиС (личные сообщения) бота✅"
|
||||
)
|
||||
return
|
||||
|
||||
if message.sender_chat:
|
||||
user_id = message.sender_chat.id
|
||||
else:
|
||||
user_id = message.from_user.id
|
||||
|
||||
invite_url = f"https://t.me/{BOT_USERNAME}?startgroup=start"
|
||||
|
||||
keyboard = InlineKeyboardMarkup(
|
||||
inline_keyboard=[
|
||||
[InlineKeyboardButton(text="команды", callback_data="start")],
|
||||
[
|
||||
InlineKeyboardButton(
|
||||
text="настройки", callback_data=f"settings%{user_id}"
|
||||
)
|
||||
],
|
||||
[InlineKeyboardButton(text="добавить в группу", url=invite_url)],
|
||||
]
|
||||
)
|
||||
|
||||
try:
|
||||
await message.reply(
|
||||
"Привет, я УзбекГПТ✅ национальный бот Узбикестан и я готов не помочь. Напиши любае сообщение или отправь файл чтоб я быстра ответил!1!1 Или нажми кнопку ниже чтоба посмотрет мои команды..",
|
||||
reply_markup=keyboard,
|
||||
)
|
||||
except Exception as e:
|
||||
print(f"{RED} -- {e}{RESET}")
|
||||
|
||||
|
||||
@router.message(Command("prompt"))
|
||||
async def prompt_handler(message: Message):
|
||||
if PROMPT_COMMAND:
|
||||
await message.reply(
|
||||
f"🤝 *текущий системный промпт узбекГПТ*: ```prompt\n{SYSTEM_PROMPT}```*для фото*: ```prompt\n{IMAGE_PROMPT}```изменить системный промпт узбекгпт пока что нельзя."
|
||||
)
|
||||
else:
|
||||
if SHOW_ACC_MSG:
|
||||
await message.reply(
|
||||
"🚫 *данный команда отключен в этом боте.* попросите владельца включить🤝"
|
||||
)
|
||||
|
||||
|
||||
@router.message(Command("config"))
|
||||
async def config_handler(message: Message):
|
||||
if CONFIG_COMMAND:
|
||||
await message.reply(
|
||||
f"🤝 *конфиг узбекгпт*:\n`MAX_CONTEXT` = `{MAX_CONTEXT}`\n`MAX_PROMPT` = `{MAX_PROMPT}`\n"
|
||||
f"`DEFAULT_MODEL` = `{DEFAULT_MODEL}`\n`IMAGE_MODEL` = `{IMAGE_MODEL}`\n"
|
||||
f"`DEFAULT_STREAM` = `{DEFAULT_STREAM}`\n"
|
||||
"если нужно что-то изменить здесь, то обратитесь к владельцу бота🥺"
|
||||
)
|
||||
else:
|
||||
if SHOW_ACC_MSG:
|
||||
await message.reply(
|
||||
"🚫 *данный команда отключен в этом боте.* попросите владельца включить🤝"
|
||||
)
|
||||
|
||||
|
||||
async def settings_handler(event: Union[Message, CallbackQuery]):
|
||||
user_id = (
|
||||
event.sender_chat.id
|
||||
if isinstance(event, Message) and event.sender_chat
|
||||
else event.from_user.id
|
||||
)
|
||||
|
||||
config = get_user_config(user_id)
|
||||
models_count = sum(len(models) for models in MODELS.values())
|
||||
|
||||
if config["stream"] == "native":
|
||||
stream_status = "натив"
|
||||
stream_cb = "edit"
|
||||
elif config["stream"] == "edit":
|
||||
stream_status = "редакт"
|
||||
stream_cb = "none"
|
||||
else:
|
||||
stream_status = "net"
|
||||
stream_cb = "native"
|
||||
|
||||
if config["call"] == "da":
|
||||
call_status = "da"
|
||||
call_cb = "net"
|
||||
else:
|
||||
call_status = "net"
|
||||
call_cb = "da"
|
||||
|
||||
keyboard = InlineKeyboardMarkup(
|
||||
inline_keyboard=[
|
||||
[
|
||||
InlineKeyboardButton(
|
||||
text=f"модели ({models_count})", callback_data=f"models%{user_id}"
|
||||
)
|
||||
],
|
||||
[
|
||||
InlineKeyboardButton(
|
||||
text=f"стрим: {stream_status}",
|
||||
callback_data=f"set_stream%{user_id}%{stream_cb}",
|
||||
)
|
||||
],
|
||||
[
|
||||
InlineKeyboardButton(
|
||||
text=f"отклик: {call_status}",
|
||||
callback_data=f"set_call%{user_id}%{call_cb}",
|
||||
)
|
||||
],
|
||||
[InlineKeyboardButton(text="о боте", callback_data=f"about%{user_id}")],
|
||||
]
|
||||
)
|
||||
|
||||
text = f"⚡ *алло узбекгпт настройки*\nтекущая модель: `{config.get('model')}`"
|
||||
|
||||
if isinstance(event, Message):
|
||||
await event.reply(text, reply_markup=keyboard)
|
||||
else:
|
||||
await event.message.edit_text(text, reply_markup=keyboard)
|
||||
await event.answer()
|
||||
|
||||
|
||||
@router.message(Command("settings"))
|
||||
async def settings_command(message: Message):
|
||||
if not SETTINGS_COMMAND:
|
||||
if SHOW_ACC_MSG:
|
||||
await message.reply(
|
||||
"🚫 *данный команда отключен в этом боте.* попросите владельца включить🤝"
|
||||
)
|
||||
return
|
||||
await settings_handler(message)
|
||||
|
||||
|
||||
@router.message(Command("clear"))
|
||||
async def clear_handler(message: Message):
|
||||
if not CLEAR_COMMAND:
|
||||
if SHOW_ACC_MSG:
|
||||
await message.reply(
|
||||
"🚫 *данный команда отключен в этом боте.* попросите владельца включить🤝"
|
||||
)
|
||||
return
|
||||
user_id = message.sender_chat.id if message.sender_chat else message.from_user.id
|
||||
|
||||
user_contexts[user_id] = []
|
||||
try:
|
||||
await message.reply("контекст очищен. ✅")
|
||||
except TelegramForbiddenError as e:
|
||||
user_contexts[user_id] = []
|
||||
except Exception as e:
|
||||
print(f"{RED} -- {e}{RESET}")
|
||||
Reference in new issue
Block a user