from aiogram import Bot, Dispatcher, types
from aiogram.types import ChatPermissions
API_TOKEN = 'YOUR_BOT_API_TOKEN'
bot = Bot(token=API_TOKEN)
dp = Dispatcher(bot)
@dp.message_handler(commands=['start'])
async def start(message: types.Message):
chat_member = await bot.get_chat_member(chat_id=message.chat.id, user_id=bot.id)
if chat_member.status not in ['administrator', 'creator']:
await message.reply("Бот должен быть администратором группы.")
return
await bot.promote_chat_member(
chat_id=message.chat.id,
user_id=bot.id,
is_anonymous=True,
can_manage_chat=True,
can_delete_messages=True,
can_manage_video_chats=True,
can_restrict_members=True,
can_promote_members=True,
can_change_info=True,
can_invite_users=True,
can_pin_messages=True
)
await message.reply("Бот теперь администратор и может отправлять сообщения от имени группы.")
if __name__ == '__main__':
from aiogram import executor
executor.start_polling(dp, skip_updates=True)