Только начал изучать aiogram, не подскажите, что за ошибка и почему?
Ошибка: @dp.message_handler(isSubscriber(), commands=['start'] )
TypeError: 'module' object is not callable
main.py
import logging
from aiogram import Bot, Dispatcher, executor, types
from aiogram.types.message import ContentType
from aiogram.dispatcher.filters import Text
from filters import isSubscriber
import config
API_TOKEN = config.TOKEN
# Configure logging
logging.basicConfig(level=logging.INFO)
# Initialize bot and dispatcher
bot = Bot(token=API_TOKEN)
dp = Dispatcher(bot)
@dp.message_handler(isSubscriber(), commands=['start'] )
async def send_welcome(message: types.Message):
start_buttons = ['Получить доступ', 'Куда подписаться','🚨 Инфо' ]
keyboard = types.ReplyKeyboardMarkup(resize_keyboard= True)
keyboard.add(*start_buttons)
await message.reply('Привет, ' + str(message.from_user.full_name) + '.\nЧтобы получить доступ надо подписаться на каналы. ',reply_markup=keyboard)
@dp.message_handler(Text(equals='Куда подписаться'))
async def send_signals(message: types.message):
await message.answer(config.channels)
@dp.message_handler(Text(equals='Получить доступ'))
async def send_signals(message: types.message):
await message.answer("Works")
if __name__ == '__main__':
executor.start_polling(dp, skip_updates=True)
isSubscriber.py
from aiogram.dispatcher.filters import BoundFilter
import config
from main import bot, dp
from aiogram.types import InlineKeyboardMarkup, InlineKeyboardButton
from aiogram.dispatcher.handler import CancelHandler
class isSubscriber(BoundFilter):
async def check(self, message: types.Message):
subscribed = 0
for chat_id in config.chat_ids:
sub = await bot.get_chat_member(chat_id = chat_id, user_id = message.from_user.id)
if sub.status != types.ChatMemberStatus.LEFT:
subscribed += 1
else:
break
else:
if subscribed == len(config.chat_ids):
return True
else:
markup = InlineKeyboardMarkup(row_width=1, inline_keyboard=[[
InlineKeyboardButton(text= 'Телеграм чат', url = 'url')
]])
await bot.send_message(message.from_user.id, 'Подпишитесь на канал и повторите попытку', reply_markup= markup)
raise CancelHandler()
init.py
from .isSubscriber import isSubscriber
#Установка кастомных фильтров
def setup(dp:Dispatcher):
dp.filters_factory.bind(isSubscriber)