Skip to content

Instantly share code, notes, and snippets.

@Lulzx
Created September 20, 2023 08:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Lulzx/40468b486347d66b0ae080485aae25e7 to your computer and use it in GitHub Desktop.
Save Lulzx/40468b486347d66b0ae080485aae25e7 to your computer and use it in GitHub Desktop.
channel join request handler
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