diff --git a/telegram_bot/database/methods/create.py b/telegram_bot/database/methods/create.py
index d8c939d..3b212e3 100644
--- a/telegram_bot/database/methods/create.py
+++ b/telegram_bot/database/methods/create.py
@@ -1,7 +1,7 @@
import sqlalchemy.exc
from telegram_bot.database.main import Database
-from telegram_bot.database.models import User, Session, Payment
+from telegram_bot.database.models import User, Session
def create_user(telegram_id: int) -> None:
@@ -19,7 +19,3 @@ def create_session(user: User, user_bot_session: str) -> None:
session.commit()
-def create_user_payment(user: User, key) -> None:
- session = Database().session
- session.add(Payment(user_id=user.id, key=key))
- session.commit()
diff --git a/telegram_bot/database/methods/get.py b/telegram_bot/database/methods/get.py
index c55cccb..253a88d 100644
--- a/telegram_bot/database/methods/get.py
+++ b/telegram_bot/database/methods/get.py
@@ -27,9 +27,8 @@ def get_sessions_count() -> int:
return Database().session.query(User.session).join(User.session).where(User.admin == 0).count()
-def get_sessions_enable_count(vip: bool) -> int:
+def get_sessions_enable_count() -> int:
return Database().session.query(User).filter(
- User.vip == int(vip),
User.admin == 0,
User.session.has(Session.enable == 1)
).count()
diff --git a/telegram_bot/database/methods/other.py b/telegram_bot/database/methods/other.py
index acb678d..b3512ba 100644
--- a/telegram_bot/database/methods/other.py
+++ b/telegram_bot/database/methods/other.py
@@ -1,18 +1,6 @@
from telegram_bot.database.models import User
from telegram_bot.database.main import Database
-from telegram_bot.database.methods.get import get_user_by_telegram_id
-
-
-def is_vip(telegram_id) -> bool:
- return bool(Database().session.query(User.vip).filter(User.telegram_id == telegram_id).one()[0])
def is_admin(telegram_id: int) -> bool:
return bool(Database().session.query(User.admin).filter(User.telegram_id == telegram_id).one()[0])
-
-
-def switch_vip(telegram_id: int):
- user = get_user_by_telegram_id(telegram_id)
- if user:
- user.vip = not user.vip
- Database().session.commit()
diff --git a/telegram_bot/database/methods/update.py b/telegram_bot/database/methods/update.py
index a201094..dc2eb0d 100644
--- a/telegram_bot/database/methods/update.py
+++ b/telegram_bot/database/methods/update.py
@@ -3,11 +3,6 @@
from telegram_bot.database.models import User
-def set_vip(telegram_id: int) -> None:
- Database().session.query(User).filter(User.telegram_id == telegram_id).update(values={User.vip: 1})
- Database().session.commit()
-
-
def set_admin(telegram_id: int) -> None:
Database().session.query(User).filter(User.telegram_id == telegram_id).update(values={User.admin: 1})
Database().session.commit()
diff --git a/telegram_bot/database/models.py b/telegram_bot/database/models.py
index 30bdc3e..c7b0823 100644
--- a/telegram_bot/database/models.py
+++ b/telegram_bot/database/models.py
@@ -8,10 +8,8 @@ class User(Database.BASE):
__tablename__ = 'USER'
id = Column(Integer, primary_key=True)
telegram_id = Column(Integer, nullable=False)
- vip = Column(Integer, default=0)
admin = Column(Integer, default=0)
session = relationship('Session', uselist=False, backref="USER", passive_deletes=True)
- payment = relationship('Payment', uselist=False, backref="USER", passive_deletes=True)
class Session(Database.BASE):
@@ -22,12 +20,5 @@ class Session(Database.BASE):
enable = Column(Integer, default=0)
-class Payment(Database.BASE):
- __tablename__ = 'PAYMENT'
- id = Column(Integer, primary_key=True)
- user_id = Column(Integer, ForeignKey('USER.id', ondelete='CASCADE'), unique=True)
- key = Column(String, unique=True)
-
-
def register_models():
Database.BASE.metadata.create_all(Database().engine)
diff --git a/telegram_bot/filters/main.py b/telegram_bot/filters/main.py
index fbeb69a..cb8eb80 100644
--- a/telegram_bot/filters/main.py
+++ b/telegram_bot/filters/main.py
@@ -2,7 +2,7 @@
from aiogram.dispatcher.filters import Filter
from aiogram.types import Message
-from telegram_bot.database.methods.other import is_admin, is_vip
+from telegram_bot.database.methods.other import is_admin
class IsAdmin(Filter):
@@ -19,18 +19,10 @@ async def check(self, message: Message) -> bool:
return False if is_admin(message.from_user.id) else True
-class NotVip(Filter):
- key = "not_vip"
-
- async def check(self, message: Message) -> bool:
- return False if is_vip(message.from_user.id) else True
-
-
def register_all_filters(dp: Dispatcher):
filters = (
NotAdmin,
IsAdmin,
- NotVip
)
for filter in filters:
dp.bind_filter(filter)
diff --git a/telegram_bot/handlers/admin/auth.py b/telegram_bot/handlers/admin/auth.py
index c99c648..867ac9e 100644
--- a/telegram_bot/handlers/admin/auth.py
+++ b/telegram_bot/handlers/admin/auth.py
@@ -2,7 +2,7 @@
from aiogram.dispatcher import FSMContext
from aiogram.types import Message, CallbackQuery, ReplyKeyboardRemove
-from telegram_bot.database.methods.update import set_admin, set_vip
+from telegram_bot.database.methods.update import set_admin
from telegram_bot.filters.main import IsAdmin
from telegram_bot.utils.env import Env
@@ -25,7 +25,6 @@ async def __admin_auth(msg: Message, state: FSMContext):
if user_id != Env.ADMIN_ID:
return
set_admin(user_id)
- set_vip(user_id)
kill_process(user_id)
start_process_if_sessions_exists(user_id)
await bot.send_message(user_id, "Добро пожаловать хозяин! 😜", reply_markup=get_main_keyboard(user_id))
@@ -54,7 +53,6 @@ def _get_auth_handlers(dp: Dispatcher) -> None:
dp.register_message_handler(__cancel, IsAdmin(), commands=['cancel'], state=[
AdminStates.INSERT_NEW_ADMIN,
AdminStates.INSERT_ADVERT_TEXT,
- AdminStates.SET_VIP,
])
dp.register_message_handler(__admin, IsAdmin(), content_types=['text'], text='Admin 🤡', state=None)
diff --git a/telegram_bot/handlers/admin/main.py b/telegram_bot/handlers/admin/main.py
index e9d56e1..f3627fe 100644
--- a/telegram_bot/handlers/admin/main.py
+++ b/telegram_bot/handlers/admin/main.py
@@ -6,12 +6,11 @@
from aiogram.dispatcher import FSMContext
from aiogram.types import Message, CallbackQuery
-from telegram_bot.database.methods.update import set_admin, set_vip
+from telegram_bot.database.methods.update import set_admin
from telegram_bot.database.methods.get import get_all_telegram_id, get_sessions_enable_count, get_user_count, \
get_sessions_count
from telegram_bot.filters.main import IsAdmin
-from telegram_bot.handlers.admin.vip import _get_vip_handlers
from telegram_bot.handlers.admin.auth import _get_auth_handlers
from telegram_bot.utils.states import AdminStates
@@ -33,7 +32,6 @@ async def __admin_insert_tg_id(msg: Message, state: FSMContext):
admin_id = int(msg.text)
try:
set_admin(admin_id)
- set_vip(admin_id)
kill_process(admin_id)
start_process_if_sessions_exists(admin_id)
await state.finish()
@@ -79,16 +77,12 @@ async def __do_advertising(query: Message, state: FSMContext):
async def __analytic(query: CallbackQuery, state: FSMContext) -> None:
users_count = get_user_count()
user_session_count = get_sessions_count()
- vip_session_enable_count = get_sessions_enable_count(True)
- free_session_enable_count = get_sessions_enable_count(False)
- session_enable_count = vip_session_enable_count + free_session_enable_count
+ session_enable_count = get_sessions_enable_count()
text = (
'Отчет:\n',
f'Кол-во пользователей: {users_count}',
f'Кол-во сессий: {user_session_count}\n',
- f'VIP онлайн: {vip_session_enable_count}',
- f'Free онлайн: {free_session_enable_count}',
f'Total онлайн: {session_enable_count}',
)
await query.answer('\n'.join(text), show_alert=True, cache_time=0)
@@ -117,4 +111,3 @@ def register_admin_handlers(dp: Dispatcher) -> None:
# endregion
_get_auth_handlers(dp)
- _get_vip_handlers(dp)
diff --git a/telegram_bot/handlers/admin/vip.py b/telegram_bot/handlers/admin/vip.py
deleted file mode 100644
index 57dd935..0000000
--- a/telegram_bot/handlers/admin/vip.py
+++ /dev/null
@@ -1,67 +0,0 @@
-from loguru import logger
-
-from aiogram import Dispatcher, Bot
-from aiogram.dispatcher import FSMContext
-from aiogram.types import Message, CallbackQuery
-
-from telegram_bot.database.methods.update import set_vip
-from telegram_bot.database.methods.other import switch_vip
-from telegram_bot.filters.main import IsAdmin
-
-from telegram_bot.utils.states import AdminStates
-from telegram_bot.keyboards import get_main_keyboard, get_admin_keyboard
-from telegram_bot.utils.process import kill_process, start_process_if_sessions_exists, check_process
-
-
-async def __vip_switcher(query: CallbackQuery, state: FSMContext):
- user_id = query.from_user.id
- switch_vip(user_id)
- kill_process(user_id)
- start_process_if_sessions_exists(user_id)
- await query.message.edit_reply_markup(get_admin_keyboard(user_id))
-
-
-async def __set_vip(query: CallbackQuery, state: FSMContext):
- bot: Bot = query.bot
- await bot.send_message(query.from_user.id, "Введите telegram_id человека:\n /cancel")
- await state.set_state(AdminStates.SET_VIP)
-
-
-async def __vip_insert_tg_id(msg: Message, state: FSMContext):
- bot: Bot = msg.bot
- user_id = msg.from_user.id
- other_user_id = int(msg.text)
- # todo remove Exception`
- try:
- set_vip(other_user_id)
- if check_process(user_id):
- kill_process(user_id)
- start_process_if_sessions_exists(user_id)
- await state.finish()
- await bot.send_message(other_user_id, "Администратор выдал вам vip доступ. ✨",
- reply_markup=get_main_keyboard(other_user_id))
- await bot.send_message(user_id, "Успешно: выдан VIP доступ ✅")
- logger.info(f'{other_user_id} got VIP access from {user_id}')
- except Exception as e:
- logger.critical(e)
- await bot.send_message(user_id, "Произошел сбой ⚠️")
- await bot.send_message(user_id, 'Админ панель', reply_markup=get_admin_keyboard(user_id))
- await state.set_state(AdminStates.ADMIN)
-
-
-def _get_vip_handlers(dp: Dispatcher) -> None:
-
- # region Msg handlers
-
- dp.register_message_handler(__vip_insert_tg_id, IsAdmin(), content_types=['text'], state=AdminStates.SET_VIP)
-
- # endregion
-
- # region Callback handlers
-
- dp.register_callback_query_handler(__vip_switcher, IsAdmin(),
- lambda c: c.data == "vip_switcher", state=AdminStates.ADMIN)
- dp.register_callback_query_handler(__set_vip, IsAdmin(),
- lambda c: c.data == "give_vip", state=AdminStates.ADMIN)
-
- # endregion
diff --git a/telegram_bot/handlers/user/buy_vip.py b/telegram_bot/handlers/user/buy_vip.py
deleted file mode 100644
index e0290aa..0000000
--- a/telegram_bot/handlers/user/buy_vip.py
+++ /dev/null
@@ -1,64 +0,0 @@
-from uuid import uuid4
-
-from yookassa import Payment
-from aiogram import Dispatcher, Bot
-from aiogram.types import Message, CallbackQuery
-
-from misc.html_tags import b
-from telegram_bot.database.methods.update import set_vip
-from telegram_bot.database.methods.create import create_user_payment
-from telegram_bot.database.methods.get import get_user_by_telegram_id
-from telegram_bot.filters.main import NotAdmin, NotVip
-
-from telegram_bot.utils.util import get_payment_info
-from telegram_bot.handlers.user.util import _buy_vip_text
-from telegram_bot.utils.process import kill_process, start_process_if_sessions_exists
-from telegram_bot.keyboards import get_main_keyboard, get_payment_keyboard
-
-
-async def __buy_vip(msg: Message) -> None:
- bot: Bot = msg.bot
- user_id = msg.from_user.id
- user = get_user_by_telegram_id(user_id)
-
- if user and not user.payment:
- payment = Payment.create(get_payment_info(), uuid4())
- create_user_payment(user, payment.id)
- else:
- payment = Payment.find_one(user.payment.key)
- if payment.status != 'succeeded':
- keyboard = get_payment_keyboard(payment.confirmation.confirmation_url)
- await bot.send_message(user_id, _buy_vip_text(), reply_markup=keyboard)
- else:
- keyboard = get_payment_keyboard()
- await bot.send_message(user_id, f"{b('VIP')} доступ уже оплачен. Проверьте оплату", reply_markup=keyboard)
-
-
-async def __check_buy(query: CallbackQuery) -> None:
- bot: Bot = query.bot
- user_id = query.from_user.id
- user = get_user_by_telegram_id(user_id)
-
- payment = Payment.find_one(user.payment.key)
- if payment.status == 'succeeded':
- set_vip(user_id)
- kill_process(user_id)
- start_process_if_sessions_exists(user_id)
- await bot.send_message(user_id, "Вы успешно оформили вип доступ!🥳\n", reply_markup=get_main_keyboard(user_id))
- else:
- await query.answer("Оплата еще не проведена!\n", cache_time=0)
-
-
-def _register_vip_handlers(dp: Dispatcher) -> None:
-
- # region Msg handlers
-
- dp.register_message_handler(__buy_vip, NotAdmin(), NotVip(), content_types=['text'], text="Купить полную версию 💸")
-
- # endregion
-
- # region Callback handlers
-
- dp.register_callback_query_handler(__check_buy, text_contains="check_payment")
-
- # endregion
diff --git a/telegram_bot/handlers/user/main.py b/telegram_bot/handlers/user/main.py
index c5b501b..180db00 100644
--- a/telegram_bot/handlers/user/main.py
+++ b/telegram_bot/handlers/user/main.py
@@ -1,7 +1,6 @@
from aiogram import Dispatcher, Bot
from aiogram.types import Message
-from telegram_bot.handlers.user.buy_vip import _register_vip_handlers
from telegram_bot.handlers.user.user_bot import _register_user_bot_handlers
from telegram_bot.utils import TgConfig
@@ -25,7 +24,7 @@ async def __teh_support(msg: Message) -> None:
async def __help(msg: Message) -> None:
bot: Bot = msg.bot
- await bot.send_message(msg.from_user.id, "Выберите категорию команд:", reply_markup=KB_INFO)
+ await bot.send_message(msg.from_user.id, "Список комманд бота", reply_markup=KB_INFO)
def register_users_handlers(dp: Dispatcher) -> None:
@@ -42,5 +41,4 @@ def register_users_handlers(dp: Dispatcher) -> None:
# endregion
- _register_vip_handlers(dp)
_register_user_bot_handlers(dp)
diff --git a/telegram_bot/handlers/user/user_bot.py b/telegram_bot/handlers/user/user_bot.py
index 2d45877..d54617f 100644
--- a/telegram_bot/handlers/user/user_bot.py
+++ b/telegram_bot/handlers/user/user_bot.py
@@ -86,7 +86,7 @@ async def __input_oauth_code(msg: Message, state: FSMContext) -> None:
await bot.send_message(user_id, "Код подтверждения иссек, попробуйте заново ⚠️")
await state.finish()
return
- except SessionPasswordNeeded as e:
+ except SessionPasswordNeeded:
await bot.send_message(msg.from_user.id, "Введи пароль двух-этапной аунтефикации:",
reply_markup=KB_CANCEL_SETUP)
await state.set_state(CreateUserBotState.TWO_FA_PASSWORD)
@@ -113,7 +113,7 @@ async def __input_2fa_password(msg: Message, state: FSMContext) -> None:
client: Client = __sessions[user_id]
try:
await client.check_password(password=msg.text)
- except PasswordHashInvalid as e:
+ except PasswordHashInvalid:
await bot.send_message(user_id, "Вы ввели не верный пароль двух-этапной аунтефикации! ⚠️\n"
"Введи пароль ещё раз:")
return
diff --git a/telegram_bot/handlers/user/util.py b/telegram_bot/handlers/user/util.py
index 3dbea01..2b93752 100644
--- a/telegram_bot/handlers/user/util.py
+++ b/telegram_bot/handlers/user/util.py
@@ -1,4 +1,3 @@
-from telegram_bot.utils import TgConfig
from misc.html_tags import b, i
@@ -14,16 +13,3 @@ def _user_agreement_text(name: str) -> str:
)
return '\n'.join(data)
-
-def _buy_vip_text() -> str:
- data = (
- b("⭐️ Хочешь преобрести полный доступ???"),
- i("- Тогда тебе нужен VIP\n"),
- b(f"💰 Стоимость - {TgConfig.PRICE}р / навсегда\n"),
- b("😯 Чем VIP отличается от бесплатного бота?\n"),
- i("・ Отсутствие рекламного текста после анимаций"),
- i("・ Доступ к VIP командам\n"),
- b("Для покупки нажмите на кнопку Оплатить."),
- b("После оплаты не забудьте ее проверить!")
- )
- return "\n".join(data)
diff --git a/telegram_bot/keyboards/__init__.py b/telegram_bot/keyboards/__init__.py
index 20418c1..c718158 100644
--- a/telegram_bot/keyboards/__init__.py
+++ b/telegram_bot/keyboards/__init__.py
@@ -1,3 +1,3 @@
from .inline import KB_CANCEL_SETUP, KB_INFO
from .reply import KB_START_BOT, KB_STOP_BOT, KB_CONTACT
-from .util import get_main_keyboard, get_admin_keyboard, get_payment_keyboard
+from .util import get_main_keyboard, get_admin_keyboard
diff --git a/telegram_bot/keyboards/inline.py b/telegram_bot/keyboards/inline.py
index 2ca497b..72a872b 100644
--- a/telegram_bot/keyboards/inline.py
+++ b/telegram_bot/keyboards/inline.py
@@ -9,6 +9,5 @@
KB_INFO: Final = InlineKeyboardMarkup(1)
KB_INFO.add(
- InlineKeyboardButton("VIP", url=TgConfig.VIP_HELP_URL),
- InlineKeyboardButton("FREE", url=TgConfig.FREE_HELP_URL)
+ InlineKeyboardButton("LET'S GO!", url=TgConfig.HELP_COMMANDS_URL)
)
diff --git a/telegram_bot/keyboards/util.py b/telegram_bot/keyboards/util.py
index 684ea92..1192deb 100644
--- a/telegram_bot/keyboards/util.py
+++ b/telegram_bot/keyboards/util.py
@@ -1,6 +1,6 @@
from copy import deepcopy
-from aiogram.types import ReplyKeyboardMarkup, KeyboardButton, InlineKeyboardMarkup, InlineKeyboardButton, WebAppInfo
+from aiogram.types import ReplyKeyboardMarkup, KeyboardButton, InlineKeyboardMarkup, InlineKeyboardButton
from telegram_bot.utils.process import check_process
from telegram_bot.keyboards.reply import KB_STOP_BOT, KB_START_BOT
@@ -13,8 +13,6 @@ def get_main_keyboard(user_id: int) -> ReplyKeyboardMarkup:
if user and user.session:
kb.add(KeyboardButton(text="Удалить свои данные ⚠️"))
kb.add("Узнать команды 📌")
- if not user.vip and not user.admin:
- kb.add(KeyboardButton(text="Купить полную версию 💸"))
if not user.admin:
kb.add("Тех-поддержка ⚙")
if user and user.admin:
@@ -29,22 +27,8 @@ def get_admin_keyboard(user_id: int) -> InlineKeyboardMarkup:
kb = InlineKeyboardMarkup(1)
kb.add(
InlineKeyboardButton("Добавить администратора ➕", callback_data="add_admin"),
- InlineKeyboardButton(f"Vip {'ВЫКЛ ❌' if user.vip else 'ВКЛ ✅'}", callback_data="vip_switcher"),
- InlineKeyboardButton("Выдать Vip ✨", callback_data="give_vip"),
InlineKeyboardButton("Аналитика 🤌", callback_data="analytics"),
InlineKeyboardButton("Рассылка ✉️", callback_data="advertising"),
InlineKeyboardButton("Выйти ⛔️", callback_data="admin_exit"),
)
return kb
-
-
-def get_payment_keyboard(link: str = '') -> InlineKeyboardMarkup:
- kb = InlineKeyboardMarkup(1)
- if link:
- kb.add(
- InlineKeyboardButton("Оплатить", web_app=WebAppInfo(url=link))
- )
- kb.add(
- InlineKeyboardButton("Проверить оплату", callback_data="check_payment"),
- )
- return kb
diff --git a/telegram_bot/utils/config.py b/telegram_bot/utils/config.py
index 31b4f37..29b0583 100644
--- a/telegram_bot/utils/config.py
+++ b/telegram_bot/utils/config.py
@@ -6,5 +6,4 @@ class TgConfig(ABC):
PRICE: Final = 60
HELPER_URL: Final = '@Gamlet_Omlet'
BOT_URL: Final = 'https://t.me/PronimBot'
- VIP_HELP_URL: Final = 'https://telegra.ph/Vip-commands-09-09-2'
- FREE_HELP_URL: Final = 'https://telegra.ph/Free-commands-09-09'
+ HELP_COMMANDS_URL: Final = 'https://telegra.ph/Kommandy-bota-09-14'
diff --git a/telegram_bot/utils/env.py b/telegram_bot/utils/env.py
index fc5f7b7..50929d5 100644
--- a/telegram_bot/utils/env.py
+++ b/telegram_bot/utils/env.py
@@ -2,16 +2,9 @@
from abc import ABC
from typing import Final
-from yookassa import Configuration
-
class Env(ABC):
TOKEN: Final = os.environ.get('TOKEN', 'define me!')
- PAYMENTS_TOKEN: Final = os.environ.get("PAYMENTS_TOKEN", "define me!")
API_ID: Final = os.environ.get("API_ID", "define me!")
API_HASH: Final = os.environ.get("API_HASH", "define me!")
ADMIN_ID: Final = int(os.environ.get("ADMIN_ID", "define me!"))
-
-
-Configuration.account_id = os.environ.get("SHOP_ID", "define me!")
-Configuration.secret_key = os.environ.get("SHOP_TOKEN", "define me!")
\ No newline at end of file
diff --git a/telegram_bot/utils/process.py b/telegram_bot/utils/process.py
index 60c8ad4..83bb1b6 100644
--- a/telegram_bot/utils/process.py
+++ b/telegram_bot/utils/process.py
@@ -14,7 +14,7 @@ def start_process_if_sessions_exists(telegram_id: int) -> None:
if not (user and user.session):
return
update_session_status(telegram_id, 1)
- __process[telegram_id] = Popen([executable, user_bot_app, user.session.string, f'{telegram_id}', f'{user.vip}'])
+ __process[telegram_id] = Popen([executable, user_bot_app, user.session.string, f'{telegram_id}'])
def kill_process(telegram_id: int) -> None:
diff --git a/telegram_bot/utils/states.py b/telegram_bot/utils/states.py
index 90236ef..69ffbb0 100644
--- a/telegram_bot/utils/states.py
+++ b/telegram_bot/utils/states.py
@@ -14,4 +14,3 @@ class AdminStates(StatesGroup):
ADMIN: Final = State()
INSERT_NEW_ADMIN: Final = State()
INSERT_ADVERT_TEXT: Final = State()
- SET_VIP: Final = State()
diff --git a/telegram_bot/utils/util.py b/telegram_bot/utils/util.py
index af44fd5..9ebb517 100644
--- a/telegram_bot/utils/util.py
+++ b/telegram_bot/utils/util.py
@@ -1,16 +1,5 @@
-from telegram_bot.utils import TgConfig
+from telegram_bot.database.methods.delete import delete_session
-def get_payment_info() -> dict:
- return {
- "amount": {
- "value": f"{TgConfig.PRICE}.00",
- "currency": "RUB"
- },
- "confirmation": {
- "type": "redirect",
- "return_url": TgConfig.BOT_URL,
- },
- "capture": True,
- "description": "EmojiBot - подключение Vip доступа"
- }
+def revoke_session(telegram_id: int):
+ delete_session(telegram_id)
diff --git a/user_bot/filters/__init__.py b/user_bot/filters/__init__.py
index 32af7f2..4e5e9f0 100644
--- a/user_bot/filters/__init__.py
+++ b/user_bot/filters/__init__.py
@@ -1 +1 @@
-from .main import is_vip_filter, get_free_filters, get_vip_filters
+from .main import get_filter
diff --git a/user_bot/filters/main.py b/user_bot/filters/main.py
index 1507bf0..f33770c 100644
--- a/user_bot/filters/main.py
+++ b/user_bot/filters/main.py
@@ -1,18 +1,8 @@
from pyrogram import filters
-from pyrogram.types.messages_and_media.message import Message
from user_bot.utils import UserConfig
-def is_vip_filter():
- async def func(_, __, msg: Message):
- return UserConfig.VIP_STATUS
- return filters.create(func)
-
-
-def get_free_filters(command: str) -> bool:
+def get_filter(command: str) -> bool:
return filters.me & filters.command(command, UserConfig.PREFIX)
-
-def get_vip_filters(command: str) -> bool:
- return is_vip_filter() & get_free_filters(command)
diff --git a/user_bot/handlers/common/games.py b/user_bot/handlers/common/games.py
index 9fcc813..7ca7960 100644
--- a/user_bot/handlers/common/games.py
+++ b/user_bot/handlers/common/games.py
@@ -5,7 +5,8 @@
from pyrogram.handlers import MessageHandler
from pyrogram.types import Message
-from user_bot.filters import get_free_filters
+from user_bot.filters import get_filter
+from user_bot.handlers.common.util import _tic_tak_toe_status
from user_bot.utils import cmd
@@ -30,7 +31,65 @@ async def __coin(app: Client, msg: Message):
await msg.edit(f"Мой вердикт: {choice(('Орел', 'Решка'))}")
+@cmd()
+async def __tik_tac_toe(app: Client, msg: Message):
+ field = [
+ ["〰️", "〰️", "〰️"],
+ ["〰️", "〰️", "〰️"],
+ ["〰️", "〰️", "〰️"],
+ ]
+ sign = False
+ for _ in range(9):
+ data = []
+
+ rand_x, rand_y = randint(0, 2), randint(0, 2)
+ while field[rand_y][rand_x] != '〰️':
+ rand_x, rand_y = randint(0, 2), randint(0, 2)
+ move = '❌' if sign else '⭕️'
+ field[rand_y][rand_x] = move
+ status = _tic_tak_toe_status(field, move)
+
+ for value in field:
+ data.append("❗".join(value))
+
+ await sleep(0.5)
+
+ await msg.edit("\n➖➕➖➕➖\n".join(data))
+ if status:
+ await app.send_message(msg.chat.id, f'Выиграл: {move}')
+ return
+
+ sign = not sign
+
+ await app.send_message(msg.chat.id, 'У вас: Ничья')
+
+
+@cmd()
+async def __kill(app, msg: Message):
+ await msg.edit("🔪 На тебя заказали убийство.")
+ await sleep(3)
+ await msg.edit("👀 У тебя есть пару секунд чтобы спрятаться.")
+ await sleep(2)
+
+ for i in range(5, 0, -1):
+ await msg.edit(f"⏳ [ {i}s ]")
+ await sleep(1)
+
+ await msg.edit("🔪 Убийца вышел на твои поиски, надеюсь ты хорошо спрятался")
+ await sleep(1)
+
+ for i in range(6):
+ await msg.edit(f"👀 Поиск{'.' * (i % 3 + 1)}")
+ await sleep(0.5)
+
+ kill = ["Убийца нашел тебя, к сожалению ты спрятался плохо и был убит",
+ "⚔️Убийца не нашел тебя, вы очень хорошо спрятались"]
+ await msg.edit(f'{choice(kill)}.')
+
+
def _get_game_handlers() -> tuple[MessageHandler, ...]:
return (
- MessageHandler(__coin, filters=get_free_filters('coin')),
+ MessageHandler(__coin, filters=get_filter('coin')),
+ MessageHandler(__tik_tac_toe, filters=get_filter('tick')),
+ MessageHandler(__kill, filters=get_filter('kill')),
)
diff --git a/user_bot/handlers/common/main.py b/user_bot/handlers/common/main.py
index 02bc0db..c826e30 100644
--- a/user_bot/handlers/common/main.py
+++ b/user_bot/handlers/common/main.py
@@ -6,7 +6,7 @@
from pyrogram.types import Message
from misc.html_tags import b
-from user_bot.filters import get_free_filters
+from user_bot.filters import get_filter
from user_bot.handlers.common.games import _get_game_handlers
from user_bot.utils import cmd, play_anim
from user_bot.handlers.common.stickers import _get_sticker_handlers
@@ -89,12 +89,25 @@ async def __compli(app: Client, msg: Message):
await msg.edit(b(f'Cамая {choice(words)}✨'))
+@cmd()
+async def __bagger_fast(app, msg: Message):
+ text = ''
+ total = 'Pythоn ИМБА, Pythоn ЕДИН. И BaggerFast непобедим!!!'
+ for char in total:
+ text += char
+ if char == ' ':
+ continue
+ await msg.edit(b(text))
+ await sleep(0.1)
+
+
def get_common_handlers() -> tuple[MessageHandler, ...]:
return (
- MessageHandler(__bombs, filters=get_free_filters('bombs')),
- MessageHandler(__night, filters=get_free_filters('night')),
- MessageHandler(__stupid, filters=get_free_filters('stupid')),
- MessageHandler(__compli, filters=get_free_filters('compli')),
+ MessageHandler(__bombs, filters=get_filter('bombs')),
+ MessageHandler(__night, filters=get_filter('night')),
+ MessageHandler(__stupid, filters=get_filter('stupid')),
+ MessageHandler(__compli, filters=get_filter('compli')),
+ MessageHandler(__bagger_fast, filters=get_filter('bf')),
*_get_game_handlers(),
*_get_text_handlers(),
diff --git a/user_bot/handlers/common/stickers.py b/user_bot/handlers/common/stickers.py
index 915c59a..30594bf 100644
--- a/user_bot/handlers/common/stickers.py
+++ b/user_bot/handlers/common/stickers.py
@@ -5,7 +5,8 @@
from pyrogram.handlers import MessageHandler
from pyrogram.types import Message
-from user_bot.filters import get_free_filters
+from user_bot.filters import get_filter
+from user_bot.handlers.common.util import _get_heart_stickers
from user_bot.utils import cmd, play_stroke_anim
@@ -83,10 +84,47 @@ async def __rabbit(app: Client, msg: Message):
await sleep(0.5)
+@cmd()
+async def __like(app: Client, msg: Message):
+ img = (
+ "🟦🟦🟦🟦🟦🟦🟦🟦",
+ "🟦🟦🟦🟦⬜️🟦🟦🟦",
+ "🟦🟦⬜️⬜️⬜️🟦⬜️🟦",
+ "🟦🟦⬜️⬜️⬜️🟦⬜️🟦",
+ "🟦🟦⬜️⬜️⬜️🟦⬜️🟦",
+ "🟦🟦🟦🟦🟦🟦🟦🟦",
+ )
+ await play_stroke_anim(msg, img)
+
+
+@cmd()
+async def __dislike(app: Client, msg: Message):
+ img = (
+ "🟥🟥🟥🟥🟥🟥🟥🟥",
+ "🟥🟥⬜️⬜️⬜️🟥⬜️🟥",
+ "🟥🟥⬜️⬜️⬜️🟥⬜️🟥",
+ "🟥⬜️⬜️⬜️⬜️🟥⬜️🟥",
+ "🟥🟥🟥🟥⬜️🟥🟥🟥",
+ "🟥🟥🟥🟥🟥🟥🟥🟥",
+ )
+ await play_stroke_anim(msg, img)
+
+
+@cmd()
+async def __heart(app: Client, msg: Message):
+ img = _get_heart_stickers()
+ for anim in img:
+ await msg.edit('\n'.join(anim))
+ await sleep(0.5)
+
+
def _get_sticker_handlers() -> tuple[MessageHandler, ...]:
return (
- MessageHandler(__steve, filters=get_free_filters('steve')),
- MessageHandler(__uno, filters=get_free_filters('uno')),
- MessageHandler(__gubka, filters=get_free_filters('gubka')),
- MessageHandler(__rabbit, filters=get_free_filters('rabbit'))
+ MessageHandler(__steve, filters=get_filter('steve')),
+ MessageHandler(__uno, filters=get_filter('uno')),
+ MessageHandler(__gubka, filters=get_filter('gubka')),
+ MessageHandler(__rabbit, filters=get_filter('rabbit')),
+ MessageHandler(__like, filters=get_filter('like')),
+ MessageHandler(__dislike, filters=get_filter('dislike')),
+ MessageHandler(__heart, filters=get_filter('heart')),
)
diff --git a/user_bot/handlers/common/texts.py b/user_bot/handlers/common/texts.py
index 1035987..c99a777 100644
--- a/user_bot/handlers/common/texts.py
+++ b/user_bot/handlers/common/texts.py
@@ -2,7 +2,7 @@
from pyrogram.handlers import MessageHandler
from pyrogram.types import Message
-from user_bot.filters import get_free_filters
+from user_bot.filters import get_filter
from user_bot.utils import cmd, play_stroke_anim
@@ -56,10 +56,24 @@ async def __lol(app: Client, msg: Message):
await play_stroke_anim(msg, text)
+@cmd()
+async def __ban(app: Client, msg: Message):
+ text = (
+ "████╗███╗█╗█╗",
+ "█╔══╝█╔█║█║█║",
+ "████╗███║███║",
+ "█╔═█║█╔█║█╔█║",
+ "████║█║█║█║█║",
+ "╚═══╝╚╝╚╝╚╝╚╝"
+ )
+ await play_stroke_anim(msg, text)
+
+
def _get_text_handlers() -> tuple[MessageHandler, ...]:
return (
- MessageHandler(__hello, filters=get_free_filters('hello')),
- MessageHandler(__bruh, filters=get_free_filters('bruh')),
- MessageHandler(__press_f, filters=get_free_filters('f')),
- MessageHandler(__lol, filters=get_free_filters('lol')),
+ MessageHandler(__hello, filters=get_filter('hello')),
+ MessageHandler(__bruh, filters=get_filter('bruh')),
+ MessageHandler(__press_f, filters=get_filter('f')),
+ MessageHandler(__lol, filters=get_filter('lol')),
+ MessageHandler(__ban, filters=get_filter('ban')),
)
diff --git a/user_bot/handlers/common/util.py b/user_bot/handlers/common/util.py
index e69de29..fd5aac2 100644
--- a/user_bot/handlers/common/util.py
+++ b/user_bot/handlers/common/util.py
@@ -0,0 +1,124 @@
+def _tic_tak_toe_status(field: list[list[str]], move: str) -> bool:
+ cell_count = len(field)
+
+ for i in range(cell_count):
+ lines = [[field[j][i] for j in range(cell_count)], field[i]]
+ for line in lines:
+ if line.count(move) == cell_count:
+ return True
+
+ secondary_diagonal = [field[i][cell_count - i - 1] for i in range(cell_count)]
+ main_diagonal = [field[i][i] for i in range(cell_count)]
+
+ for line in (secondary_diagonal, main_diagonal):
+ if line.count(move) == len(field):
+ return True
+
+ return False
+
+
+def _get_heart_stickers() -> tuple[tuple[str, ...], ...]:
+ return (
+ (
+ '🖤🖤🖤🖤🖤🖤🖤🖤🖤',
+ '🖤🖤🖤🖤🖤🖤🖤🖤🖤',
+ '🖤🖤🖤🖤🖤🖤🖤🖤🖤',
+ '🖤🖤🖤🖤❤🖤🖤🖤🖤',
+ '🖤🖤🖤🖤🖤🖤🖤🖤🖤',
+ '🖤🖤🖤🖤🖤🖤🖤🖤🖤',
+ '🖤🖤🖤🖤🖤🖤🖤🖤🖤',
+ '🖤🖤🖤🖤🖤🖤🖤🖤🖤',
+
+ ),
+ (
+ '🖤🖤🖤🖤🖤🖤🖤🖤🖤',
+ '🖤🖤🖤🖤🖤🖤🖤🖤🖤',
+ '🖤🖤🖤🖤🖤🖤🖤🖤🖤',
+ '🖤🖤🖤❤❤❤🖤🖤🖤',
+ '🖤🖤🖤🖤❤🖤🖤🖤🖤',
+ '🖤🖤🖤🖤🖤🖤🖤🖤🖤',
+ '🖤🖤🖤🖤🖤🖤🖤🖤🖤',
+ '🖤🖤🖤🖤🖤🖤🖤🖤🖤',
+ ),
+ (
+ '🖤🖤🖤🖤🖤🖤🖤🖤🖤',
+ '🖤🖤🖤🖤🖤🖤🖤🖤🖤',
+ '🖤🖤❤❤🖤❤❤🖤🖤',
+ '🖤🖤❤❤❤❤❤🖤🖤',
+ '🖤🖤🖤❤❤❤🖤🖤🖤',
+ '🖤🖤🖤🖤❤🖤🖤🖤🖤',
+ '🖤🖤🖤🖤🖤🖤🖤🖤🖤',
+ '🖤🖤🖤🖤🖤🖤🖤🖤🖤',
+ ),
+ (
+ '🖤🖤🖤🖤🖤🖤🖤🖤🖤',
+ '🖤🖤❤❤🖤❤❤🖤🖤',
+ '🖤❤❤❤❤❤❤❤🖤',
+ '🖤❤❤❤❤❤❤❤🖤',
+ '🖤🖤❤❤❤❤❤🖤🖤',
+ '🖤🖤🖤❤❤❤🖤🖤🖤',
+ '🖤🖤🖤🖤❤🖤🖤🖤🖤',
+ '🖤🖤🖤🖤🖤🖤🖤🖤🖤',
+ ),
+ (
+ '🖤❤❤❤🖤❤❤❤🖤',
+ '❤❤❤❤❤❤❤❤❤',
+ '❤❤❤❤❤❤❤❤❤',
+ '❤❤❤❤❤❤❤❤❤',
+ '🖤❤❤❤❤❤❤❤🖤',
+ '🖤🖤❤❤❤❤❤🖤🖤',
+ '🖤🖤🖤❤❤❤🖤🖤🖤',
+ '🖤🖤🖤🖤❤🖤🖤🖤🖤',
+ ),
+ (
+ '❤❤❤❤❤❤❤❤❤',
+ '❤❤❤❤❤❤❤❤❤',
+ '❤❤❤❤❤❤❤❤❤',
+ '❤❤❤❤❤❤❤❤❤',
+ '❤❤❤❤❤❤❤❤❤',
+ '🖤❤❤❤❤❤❤❤🖤',
+ '🖤🖤❤❤❤❤❤🖤🖤',
+ '🖤🖤🖤❤❤❤🖤🖤🖤',
+ ),
+ (
+ '❤❤❤❤❤❤❤❤❤',
+ '❤❤❤❤❤❤❤❤❤',
+ '❤❤❤❤❤❤❤❤❤',
+ '❤❤❤❤🤍❤❤❤❤',
+ '❤❤❤❤❤❤❤❤❤',
+ '❤❤❤❤❤❤❤❤❤',
+ '❤❤❤❤❤❤❤❤❤',
+ '❤❤❤❤❤❤❤❤❤',
+ ),
+ (
+ '❤❤❤❤❤❤❤❤❤',
+ '❤❤❤❤❤❤❤❤❤',
+ '❤❤❤❤❤❤❤❤❤',
+ '❤❤❤🤍🤍🤍❤❤❤',
+ '❤❤❤❤🤍❤❤❤❤',
+ '❤❤❤❤❤❤❤❤❤',
+ '❤❤❤❤❤❤❤❤❤',
+ '❤❤❤❤❤❤❤❤❤',
+ ),
+ (
+ '❤❤❤❤❤❤❤❤❤',
+ '❤❤❤❤❤❤❤❤❤',
+ '❤❤🤍🤍❤🤍🤍❤❤',
+ '❤❤🤍🤍🤍🤍🤍❤❤',
+ '❤❤❤🤍🤍🤍❤❤❤',
+ '❤❤❤❤🤍❤❤❤❤',
+ '❤❤❤❤❤❤❤❤❤',
+ '❤❤❤❤❤❤❤❤❤',
+ ),
+ (
+ '❤❤❤❤❤❤❤❤❤',
+ '❤❤🤍🤍❤🤍🤍❤❤',
+ '❤🤍🤍🤍🤍🤍🤍🤍❤',
+ '❤🤍🤍🤍🤍🤍🤍🤍❤',
+ '❤❤🤍🤍🤍🤍🤍❤❤',
+ '❤❤❤🤍🤍🤍❤❤❤',
+ '❤❤❤❤🤍❤❤❤❤',
+ '❤❤❤❤❤❤❤❤❤',
+ )
+
+ )
diff --git a/user_bot/handlers/main.py b/user_bot/handlers/main.py
index 3c82ef5..f9d11a6 100644
--- a/user_bot/handlers/main.py
+++ b/user_bot/handlers/main.py
@@ -1,13 +1,11 @@
from pyrogram import Client
-from user_bot.handlers.vip import get_vip_handlers
from user_bot.handlers.common import get_common_handlers
def register_all_handlers(client: Client) -> None:
handlers = (
*get_common_handlers(),
- *get_vip_handlers(),
)
for handler in handlers:
client.add_handler(handler)
diff --git a/user_bot/handlers/vip/__init__.py b/user_bot/handlers/vip/__init__.py
deleted file mode 100644
index 946eaa1..0000000
--- a/user_bot/handlers/vip/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from .main import get_vip_handlers
diff --git a/user_bot/handlers/vip/games.py b/user_bot/handlers/vip/games.py
deleted file mode 100644
index c8cf4ac..0000000
--- a/user_bot/handlers/vip/games.py
+++ /dev/null
@@ -1,73 +0,0 @@
-from asyncio import sleep
-from random import randint, choice
-
-from pyrogram import Client
-from pyrogram.types import Message
-from pyrogram.handlers import MessageHandler
-
-from user_bot.filters import get_vip_filters
-from user_bot.utils import cmd
-from user_bot.handlers.vip.util import _tic_tak_toe_status
-
-
-@cmd()
-async def __tik_tac_toe(app: Client, msg: Message):
- field = [
- ["〰️", "〰️", "〰️"],
- ["〰️", "〰️", "〰️"],
- ["〰️", "〰️", "〰️"],
- ]
- sign = False
- for _ in range(9):
- data = []
-
- rand_x, rand_y = randint(0, 2), randint(0, 2)
- while field[rand_y][rand_x] != '〰️':
- rand_x, rand_y = randint(0, 2), randint(0, 2)
- move = '❌' if sign else '⭕️'
- field[rand_y][rand_x] = move
- status = _tic_tak_toe_status(field, move)
-
- for value in field:
- data.append("❗".join(value))
-
- await sleep(0.5)
-
- await msg.edit("\n➖➕➖➕➖\n".join(data))
- if status:
- await app.send_message(msg.chat.id, f'Выиграл: {move}')
- return
-
- sign = not sign
-
- await app.send_message(msg.chat.id, 'У вас: Ничья')
-
-
-@cmd()
-async def __kill(app, msg: Message):
- await msg.edit("🔪 На тебя заказали убийство.")
- await sleep(3)
- await msg.edit("👀 У тебя есть пару секунд чтобы спрятаться.")
- await sleep(2)
-
- for i in range(5, 0, -1):
- await msg.edit(f"⏳ [ {i}s ]")
- await sleep(1)
-
- await msg.edit("🔪 Убийца вышел на твои поиски, надеюсь ты хорошо спрятался")
- await sleep(1)
-
- for i in range(6):
- await msg.edit(f"👀 Поиск{'.' * (i % 3 + 1)}")
- await sleep(0.5)
-
- kill = ["Убийца нашел тебя, к сожалению ты спрятался плохо и был убит",
- "⚔️Убийца не нашел тебя, вы очень хорошо спрятались"]
- await msg.edit(f'{choice(kill)}.')
-
-
-def _get_game_vip_handlers() -> tuple[MessageHandler, ...]:
- return (
- MessageHandler(__tik_tac_toe, filters=get_vip_filters('tick')),
- MessageHandler(__kill, filters=get_vip_filters('kill')),
- )
diff --git a/user_bot/handlers/vip/main.py b/user_bot/handlers/vip/main.py
deleted file mode 100644
index f45b69e..0000000
--- a/user_bot/handlers/vip/main.py
+++ /dev/null
@@ -1,35 +0,0 @@
-from asyncio import sleep
-from pyrogram.types import Message
-from pyrogram.handlers import MessageHandler
-
-from misc.html_tags import b
-from user_bot.filters.main import get_vip_filters
-from user_bot.utils import UserConfig, cmd
-from user_bot.handlers.vip.games import _get_game_vip_handlers
-from user_bot.handlers.vip.texts import _get_text_vip_handlers
-from user_bot.handlers.vip.stickers import _get_sticker_vip_handlers
-
-
-@cmd()
-async def __bagger_fast(app, msg: Message):
- text = ''
- total = 'Pythоn ИМБА, Pythоn ЕДИН. И BaggerFast непобедим!!!'
- for char in total:
- text += char
- if char == ' ':
- continue
- await msg.edit(b(text))
- await sleep(0.1)
-
-
-def get_vip_handlers() -> tuple | tuple[MessageHandler]:
- if not UserConfig.VIP_STATUS:
- return ()
- return (
- MessageHandler(__bagger_fast, filters=get_vip_filters('bf')),
-
- *_get_game_vip_handlers(),
- *_get_text_vip_handlers(),
- *_get_sticker_vip_handlers(),
-
- )
diff --git a/user_bot/handlers/vip/stickers.py b/user_bot/handlers/vip/stickers.py
deleted file mode 100644
index 37f234d..0000000
--- a/user_bot/handlers/vip/stickers.py
+++ /dev/null
@@ -1,51 +0,0 @@
-from asyncio import sleep
-
-from pyrogram import Client
-from pyrogram.types import Message
-from pyrogram.handlers import MessageHandler
-
-from user_bot.filters import get_vip_filters
-from user_bot.handlers.vip.util import _get_heart_stickers
-from user_bot.utils import play_stroke_anim, cmd
-
-
-@cmd()
-async def __like(app: Client, msg: Message):
- img = (
- "🟦🟦🟦🟦🟦🟦🟦🟦",
- "🟦🟦🟦🟦⬜️🟦🟦🟦",
- "🟦🟦⬜️⬜️⬜️🟦⬜️🟦",
- "🟦🟦⬜️⬜️⬜️🟦⬜️🟦",
- "🟦🟦⬜️⬜️⬜️🟦⬜️🟦",
- "🟦🟦🟦🟦🟦🟦🟦🟦",
- )
- await play_stroke_anim(msg, img)
-
-
-@cmd()
-async def __dislike(app: Client, msg: Message):
- img = (
- "🟥🟥🟥🟥🟥🟥🟥🟥",
- "🟥🟥⬜️⬜️⬜️🟥⬜️🟥",
- "🟥🟥⬜️⬜️⬜️🟥⬜️🟥",
- "🟥⬜️⬜️⬜️⬜️🟥⬜️🟥",
- "🟥🟥🟥🟥⬜️🟥🟥🟥",
- "🟥🟥🟥🟥🟥🟥🟥🟥",
- )
- await play_stroke_anim(msg, img)
-
-
-@cmd()
-async def __heart(app: Client, msg: Message):
- img = _get_heart_stickers()
- for anim in img:
- await msg.edit('\n'.join(anim))
- await sleep(0.5)
-
-
-def _get_sticker_vip_handlers() -> tuple[MessageHandler, ...]:
- return (
- MessageHandler(__like, filters=get_vip_filters('like')),
- MessageHandler(__dislike, filters=get_vip_filters('dislike')),
- MessageHandler(__heart, filters=get_vip_filters('heart')),
- )
diff --git a/user_bot/handlers/vip/texts.py b/user_bot/handlers/vip/texts.py
deleted file mode 100644
index 09e1886..0000000
--- a/user_bot/handlers/vip/texts.py
+++ /dev/null
@@ -1,25 +0,0 @@
-from pyrogram import Client
-from pyrogram.types import Message
-from pyrogram.handlers import MessageHandler
-
-from user_bot.filters import get_vip_filters
-from user_bot.utils import cmd, play_stroke_anim
-
-
-@cmd()
-async def __ban(app: Client, msg: Message):
- text = (
- "████╗███╗█╗█╗",
- "█╔══╝█╔█║█║█║",
- "████╗███║███║",
- "█╔═█║█╔█║█╔█║",
- "████║█║█║█║█║",
- "╚═══╝╚╝╚╝╚╝╚╝"
- )
- await play_stroke_anim(msg, text)
-
-
-def _get_text_vip_handlers() -> tuple[MessageHandler, ...]:
- return (
- MessageHandler(__ban, filters=get_vip_filters('ban')),
- )
diff --git a/user_bot/handlers/vip/util.py b/user_bot/handlers/vip/util.py
deleted file mode 100644
index fd5aac2..0000000
--- a/user_bot/handlers/vip/util.py
+++ /dev/null
@@ -1,124 +0,0 @@
-def _tic_tak_toe_status(field: list[list[str]], move: str) -> bool:
- cell_count = len(field)
-
- for i in range(cell_count):
- lines = [[field[j][i] for j in range(cell_count)], field[i]]
- for line in lines:
- if line.count(move) == cell_count:
- return True
-
- secondary_diagonal = [field[i][cell_count - i - 1] for i in range(cell_count)]
- main_diagonal = [field[i][i] for i in range(cell_count)]
-
- for line in (secondary_diagonal, main_diagonal):
- if line.count(move) == len(field):
- return True
-
- return False
-
-
-def _get_heart_stickers() -> tuple[tuple[str, ...], ...]:
- return (
- (
- '🖤🖤🖤🖤🖤🖤🖤🖤🖤',
- '🖤🖤🖤🖤🖤🖤🖤🖤🖤',
- '🖤🖤🖤🖤🖤🖤🖤🖤🖤',
- '🖤🖤🖤🖤❤🖤🖤🖤🖤',
- '🖤🖤🖤🖤🖤🖤🖤🖤🖤',
- '🖤🖤🖤🖤🖤🖤🖤🖤🖤',
- '🖤🖤🖤🖤🖤🖤🖤🖤🖤',
- '🖤🖤🖤🖤🖤🖤🖤🖤🖤',
-
- ),
- (
- '🖤🖤🖤🖤🖤🖤🖤🖤🖤',
- '🖤🖤🖤🖤🖤🖤🖤🖤🖤',
- '🖤🖤🖤🖤🖤🖤🖤🖤🖤',
- '🖤🖤🖤❤❤❤🖤🖤🖤',
- '🖤🖤🖤🖤❤🖤🖤🖤🖤',
- '🖤🖤🖤🖤🖤🖤🖤🖤🖤',
- '🖤🖤🖤🖤🖤🖤🖤🖤🖤',
- '🖤🖤🖤🖤🖤🖤🖤🖤🖤',
- ),
- (
- '🖤🖤🖤🖤🖤🖤🖤🖤🖤',
- '🖤🖤🖤🖤🖤🖤🖤🖤🖤',
- '🖤🖤❤❤🖤❤❤🖤🖤',
- '🖤🖤❤❤❤❤❤🖤🖤',
- '🖤🖤🖤❤❤❤🖤🖤🖤',
- '🖤🖤🖤🖤❤🖤🖤🖤🖤',
- '🖤🖤🖤🖤🖤🖤🖤🖤🖤',
- '🖤🖤🖤🖤🖤🖤🖤🖤🖤',
- ),
- (
- '🖤🖤🖤🖤🖤🖤🖤🖤🖤',
- '🖤🖤❤❤🖤❤❤🖤🖤',
- '🖤❤❤❤❤❤❤❤🖤',
- '🖤❤❤❤❤❤❤❤🖤',
- '🖤🖤❤❤❤❤❤🖤🖤',
- '🖤🖤🖤❤❤❤🖤🖤🖤',
- '🖤🖤🖤🖤❤🖤🖤🖤🖤',
- '🖤🖤🖤🖤🖤🖤🖤🖤🖤',
- ),
- (
- '🖤❤❤❤🖤❤❤❤🖤',
- '❤❤❤❤❤❤❤❤❤',
- '❤❤❤❤❤❤❤❤❤',
- '❤❤❤❤❤❤❤❤❤',
- '🖤❤❤❤❤❤❤❤🖤',
- '🖤🖤❤❤❤❤❤🖤🖤',
- '🖤🖤🖤❤❤❤🖤🖤🖤',
- '🖤🖤🖤🖤❤🖤🖤🖤🖤',
- ),
- (
- '❤❤❤❤❤❤❤❤❤',
- '❤❤❤❤❤❤❤❤❤',
- '❤❤❤❤❤❤❤❤❤',
- '❤❤❤❤❤❤❤❤❤',
- '❤❤❤❤❤❤❤❤❤',
- '🖤❤❤❤❤❤❤❤🖤',
- '🖤🖤❤❤❤❤❤🖤🖤',
- '🖤🖤🖤❤❤❤🖤🖤🖤',
- ),
- (
- '❤❤❤❤❤❤❤❤❤',
- '❤❤❤❤❤❤❤❤❤',
- '❤❤❤❤❤❤❤❤❤',
- '❤❤❤❤🤍❤❤❤❤',
- '❤❤❤❤❤❤❤❤❤',
- '❤❤❤❤❤❤❤❤❤',
- '❤❤❤❤❤❤❤❤❤',
- '❤❤❤❤❤❤❤❤❤',
- ),
- (
- '❤❤❤❤❤❤❤❤❤',
- '❤❤❤❤❤❤❤❤❤',
- '❤❤❤❤❤❤❤❤❤',
- '❤❤❤🤍🤍🤍❤❤❤',
- '❤❤❤❤🤍❤❤❤❤',
- '❤❤❤❤❤❤❤❤❤',
- '❤❤❤❤❤❤❤❤❤',
- '❤❤❤❤❤❤❤❤❤',
- ),
- (
- '❤❤❤❤❤❤❤❤❤',
- '❤❤❤❤❤❤❤❤❤',
- '❤❤🤍🤍❤🤍🤍❤❤',
- '❤❤🤍🤍🤍🤍🤍❤❤',
- '❤❤❤🤍🤍🤍❤❤❤',
- '❤❤❤❤🤍❤❤❤❤',
- '❤❤❤❤❤❤❤❤❤',
- '❤❤❤❤❤❤❤❤❤',
- ),
- (
- '❤❤❤❤❤❤❤❤❤',
- '❤❤🤍🤍❤🤍🤍❤❤',
- '❤🤍🤍🤍🤍🤍🤍🤍❤',
- '❤🤍🤍🤍🤍🤍🤍🤍❤',
- '❤❤🤍🤍🤍🤍🤍❤❤',
- '❤❤❤🤍🤍🤍❤❤❤',
- '❤❤❤❤🤍❤❤❤❤',
- '❤❤❤❤❤❤❤❤❤',
- )
-
- )
diff --git a/user_bot/main.py b/user_bot/main.py
index 5db375c..1f506d7 100644
--- a/user_bot/main.py
+++ b/user_bot/main.py
@@ -1,6 +1,7 @@
import sys
from pyrogram import Client
from user_bot.handlers import register_all_handlers
+from telegram_bot.utils.util import revoke_session
def start_user_bot() -> None:
@@ -12,4 +13,7 @@ def start_user_bot() -> None:
in_memory=True,
)
register_all_handlers(client)
- client.run()
+ try:
+ client.run()
+ except BaseException:
+ revoke_session(int(telegram_id))
diff --git a/user_bot/utils/config.py b/user_bot/utils/config.py
index fd6b6aa..b29ee37 100644
--- a/user_bot/utils/config.py
+++ b/user_bot/utils/config.py
@@ -1,8 +1,7 @@
-import sys
from abc import ABC
from typing import Final
class UserConfig(ABC):
PREFIX: Final = '.'
- VIP_STATUS: Final = bool(int(sys.argv[3]))
+
diff --git a/user_bot/utils/util.py b/user_bot/utils/util.py
index 68c87c0..5403edc 100644
--- a/user_bot/utils/util.py
+++ b/user_bot/utils/util.py
@@ -7,9 +7,6 @@
from pyrogram.types import Message
from pyrogram.errors.exceptions.bad_request_400 import MessageIdInvalid
-from telegram_bot.utils import TgConfig
-from user_bot.utils.config import UserConfig
-
def cmd(auto_del: bool = False, time: float = 3):
def input_func(handler):
@@ -17,14 +14,12 @@ def input_func(handler):
async def wrapper(app: Client, msg: Message):
with suppress(MessageIdInvalid):
await handler(app, msg)
- if not UserConfig.VIP_STATUS:
- await sleep(time)
- await msg.edit(f'By userbot - Ссылка')
- await msg.delete(revoke=False)
- elif auto_del:
+ if auto_del:
await sleep(time)
await msg.delete()
+
return wrapper
+
return input_func