Telegram 机器人 - 现在将机器人添加到组中?

Telegram bot нow add bot to group?

python 上的 Telegram 机器人使用 pyTelegramBotAPI 库。 想要在调用命令 /start@BotName 时将机器人添加到组中 它如何与 bot @TrueMafiaBot 一起工作 我该怎么做?

您可以使用以下 link 并将其发送给用户:

t.me/BotUsername?startgroup=botstart

BotUsername 替换为您的机器人用户名,当用户单击 link 时,他们的客户端将提示 select 应将机器人添加到的组。

我通过按钮将机器人添加到组的最终代码

@bot.message_handler(commands=['start', 'help'])
def start_message(message):
    keyboard = types.InlineKeyboardMarkup()  # Keyboard
    key_add_to_group = types.InlineKeyboardButton(text='Add to group', url='http://t.me/evil_cards_bot?startgroup=test')
    keyboard.add(key_add_to_group)  # Add button to keyboard
    response_text = 'Add bot to group.'
    bot.send_message(message.chat.id, text=response_text, reply_markup=keyboard)