【问题标题】:Telegram bot нow add bot to group? [closed]电报机器人 - 现在将机器人添加到组? [关闭]
【发布时间】:2020-03-22 19:39:05
【问题描述】:

使用 pyTelegramBotAPI 库的 Python 电报机器人。 想要在调用命令 /start@BotName 时将机器人添加到组中它如何与 bot @TrueMafiaBot 一起使用 我怎么能这样做?

【问题讨论】:

  • 阅读自述文件了吗?你试过什么?什么不起作用?您在教程中的哪些地方遇到了挫折?
  • 我没有这方面的教程。我阅读了自述文件,但找不到答案。我试图谷歌但没有找到任何合适的

标签: python python-3.x telegram telegram-bot py-telegram-bot-api


【解决方案1】:

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

t.me/BotUsername?startgroup=botstart

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

【讨论】:

  • 谢谢,这正是我需要的
  • 它现在改变了,@应该删除t.me/BotUsername?startgroup=botstart
【解决方案2】:

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

@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)

【讨论】:

    猜你喜欢
    • 2016-11-11
    • 2016-09-17
    • 2017-08-18
    • 2021-04-08
    • 2020-08-25
    • 2015-09-22
    • 1970-01-01
    • 2020-08-20
    • 2023-03-30
    相关资源
    最近更新 更多