Aiogram python InlineKeyboard

kmbjn2e3  于 2023-04-08  发布在  Python
关注(0)|答案(1)|浏览(65)

我有一些代码:

master = InlineKeyboardMarkup()
master.add(InlineKeyboardButton(text='7(800)555-35-35', url='tel:+78005553535'),
           InlineKeyboardButton(text='8(800)555-35-35', url='tel:+88005553535'))

但是当我尝试召唤这个键盘时,我有一个错误:aiogram.utils.exceptions.BadRequest: Wrong http url

dba5bblo

dba5bblo1#

你需要编写如下代码:

main.py

from aiogram
import Bot, Dispatcher, executor, types
import keyboards as kb

bot = Bot(token = 'BOT_TOKEN')
dp = Dispatcher(bot)

@dp.message_handler(commands = ['inline'])
async def show_items(message: types.Message):
   await message.answer('It is buttons', reply_markup = kb.start_keyboard)

if __name__ == '__main__':
   executor.start_polling(dp, skip_updates = True)

键盘.py

from aiogram.types
import ReplyKeyboardMarkup, KeyboardButton, InlineKeyboardMarkup, InlineKeyboardButton

inline_keyboard = InlineKeyboardButton(text='7(800)555-35-35', url = 'tel:+78005553535'),
InlineKeyboardButton(text='8(800)555-35-35', url = 'tel:+88005553535')

start_keyboard = ReplyKeyboardMarkup(resize_keyboard = True).add(inline_keyboard)

相关问题