https://t.me/triviabot?start=payload
бот получит входящее сообщение /start payload
@bot.command()
, либо @commands.command()
, при этом регистрируя ее с помощью bot.add_command(test)
. @commands.command()
есть, а регистрации - нетfrom aiogram.types import ReplyKeyboardRemove, \
ReplyKeyboardMarkup, KeyboardButton
@dp.message_handler(commands=['start'])
async def process_start_command(message: types.Message):
button_hi = KeyboardButton('/help')
greet_kb = ReplyKeyboardMarkup()
greet_kb.add(button_hi)
await message.reply("Привет!", reply_markup=kb.greet_kb)
register_*_handler
, в то время как для инлайн кнопки вызвали обычную функцию, которая должна являться декоратором. register_callback_query_handler()
user_name = bs.find('title').text.split('|')[0].strip()
x = "f'@{message.chat.username}'"
f
должна стоять перед строкой, а не быть в ней.await bot.send_message(message.chat.id, f'@{message.chat.username} пока последит за аллертами. Дежурный пропиши /vse как вернёшься')
def hotels_max(message, *args):
maximum_hotels = int(message.text)
for sorted_hotel in args[0][:maximum_hotels]:
hotel_name, hotel_price, hotel_id = sorted_hotel.split(',')
kb = types.InlineKeyboardMarkup()
kb.add(types.InlineKeyboardButton('Получить фото', callback_data=f'hotel_{hotel_id}'))
bot.send_message(message.from_user.id, f'{hotel_name}, {hotel_price}', reply_markup=kb)
@bot.callback_query_handler(func=lambda call: call.data.startswith('hotel_'))
def hotel_photo(call):
# Предположу, что фото можно будет получить по ID отеля, поэтому достаем его
hotel_id = call.data.split('_')[-1]
# ну и дальше уже получаем фото и отправляем
bot.set_my_commands(commands, [aiogram.types.bot_command_scope_chat.BotCommandScopeChat(chat_id=123)])
BotCommandScopeAllPrivateChats
for i in corr:
if i['number'] == d:
news = f"<b>{i['date']}</b>\n" \
f"{i['judge']}\n" \
f"{i['forma']}\n" \
f"{i['number']}\n" \
f"<b>{i['involved']}</b>\n" \
f"{i['description']}\n"
await bot.send_message(message.from_user.id, news)
await state.finish()
break
else:
# не совпадают
bot.restrict_chat_member(chat_id, user_id, can_send_messages=False)