AIOgram
- 1 ответ
- 0 вопросов
1
Вклад в тег
import asyncio
from aiogram import Bot, Dispatcher, F
from aiogram.filters.callback_data import CallbackData
from aiogram.fsm.storage.memory import MemoryStorage
from aiogram.filters import Command, BaseFilter
from aiogram.types import InlineKeyboardMarkup, InlineKeyboardButton, CallbackQuery, ReplyKeyboardMarkup, \
KeyboardButtonRequestChat
from aiogram.utils.keyboard import InlineKeyboardBuilder
from aiogram.types import (
KeyboardButton,
Message)
TOKEN = ""
bot = Bot(TOKEN)
dp = Dispatcher(storage=MemoryStorage())
@dp.message(F.text.contains("/start"))
async def text_handler(message: Message):
await message.answer("I'm here", reply_markup=ReplyKeyboardMarkup(keyboard=
[
[
KeyboardButton(text="test1", request_chat=KeyboardButtonRequestChat(
request_id=1,
user_is_bot=False,
chat_is_channel=True,
chat_is_forum=False
)),
KeyboardButton(text="test2", request_chat=KeyboardButtonRequestChat(
request_id=2,
user_is_bot=False,
chat_is_channel=False,
chat_is_forum=False
)),
]
]
))
@dp.message(F.chat)
async def handle_request_chat(msg: Message):
chat_info = msg.chat_shared.chat_id
await bot.send_message(msg.from_user.id, f"Вы выбрали канал с ID: {chat_info}")
async def main():
await dp.start_polling(bot)
if __name__ == "__main__":
asyncio.run(main())