Created
September 20, 2023 08:30
-
-
Save Lulzx/40468b486347d66b0ae080485aae25e7 to your computer and use it in GitHub Desktop.
channel join request handler
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import asyncio | |
from aiogram import Bot, Dispatcher, types | |
bot = Bot(token='TOKEN') | |
dp = Dispatcher(bot) | |
@dp.chat_join_request_handler() | |
async def handle_chat_join_request(chat_join_request: types.chat_join_request.ChatJoinRequest): | |
user_id = chat_join_request.from_user.id | |
channel_id = chat_join_request.chat.id | |
await bot.approve_chat_join_request(channel_id, user_id) | |
await bot.send_message(user_id, 'Welcome to the channel!') | |
if __name__ == '__main__': | |
print('Starting bot...') | |
asyncio.run(dp.start_polling()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment