from aiogram.types import ReplyKeyboardMarkup, InlineKeyboardMarkup, KeyboardButton, InlineKeyboardButton
menu_keyboard = ReplyKeyboardMarkup(resize_keyboard=True)
menu_keyboard.add(KeyboardButton("Купить подписку"))
sub_verification_menu = InlineKeyboardMarkup(row_width=1)
sub_verification_menu.insert(InlineKeyboardButton(text="Подписаться", url="Ссылка на мой тгк"))
sub_verification_menu.insert(InlineKeyboardButton(text="Подписался!", callback_data="sub_check"))
from aiogram import Bot, dispatcher, executor, types
from keyboards import keyboard_menu, sub_verification_menu
from config import TOKEN, YKASSA_TOKEN
bot = Bot(TOKEN)
dp = dispatcher(bot)
def sub_verification(chat_member):
if chat_member["status"] != "left":
return True
else:
return False
@dp.message_hendler(commands="start")
async def start(message: types.Message):
if sub_verification(await bot.get_chat_member(chat_id="@Return_metro_shop", user_id=message.from_user.id)):
await message.answer("Выберите действие из меню", reply_markup=keyboard_menu)
else:
await message.answer("Для получения доступа, подпишись на канал!", reply_markup=sub_verification_menu)
@dp.callback_query_handler(text="sub_check")
async def sub_check(message: types.Message):
await bot.delete_message(message.from_user.id, message.message.message_id)
if sub_verification(await bot.get_chat_member(chat_id="@Return_metro_shop", user_id=message.from_user.id)):
await bot.send_message(message.from_user.id,("Выберите действие из меню"), reply_markup=keyboard_menu)
else:
await bot.send_message(message.from_user.id,"Для получения доступа, подпишись на канал!", reply_markup=sub_verification_menu)
if __name__ == "__main__":
executor.start_polling(dp, skip_updates=True)
Traceback (most recent call last):
File "c:\Users\dinis\Desktop\payments test\bot.py", line 3, in <module>
from keyboards import keyboard_menu, sub_verification_menu
ImportError: cannot import name 'keyboard_menu' from 'keyboards' (c:\Users\dinis\Desktop\payments test\keyboards.py)
Traceback (most recent call last):
File "c:\Users\dinis\Desktop\payments test\bot.py", line 7, in
dp = dispatcher(bot)
^^^^^^^^^^^^^^^
TypeError: 'module' object is not callable