是否可以在选择聊天后删除链接前的机器人用户名:“@Bot https://t.me/Bot?start=1”是选择聊天后的消息。如何删除链接之前的所有内容,使其变成这样:“https://t.me/Bot?start=1”?
功能(远程机器人库):
def switch(message):
markup = types.InlineKeyboardMarkup()
bot_name = bot.get_me().username
switch_button = types.InlineKeyboardButton(text='Try', switch_inline_query=ref_link.format(bot_name, message.chat.id))
markup.add(switch_button)
bot.send_message(message.chat.id, "Выбрать чат", reply_markup = markup)
我尝试将库更改为 aiogram,但没有成功。
使用常规 URL 解决:
ref_link = 'https://t.me/share/url?url=https://t.me/{}?start={}'\
@bot.message_handler(commands = ['invite'])
def inv(message):
markup = types.InlineKeyboardMarkup()
bot_name = bot.get_me().username
switch_button = types.InlineKeyboardButton(text='Пригласить друга', url=ref_link.format(bot_name, message.chat.id))
markup.add(switch_button)
bot.send_message(message.chat.id, "Выбрать чат", reply_markup = markup)