【问题标题】:getChatMembersCount telebotgetChatMembersCount 远程机器人
【发布时间】:2018-08-03 08:13:45
【问题描述】:

我的代码:

import telebot
bot = telebot.TeleBot(constants.token)

@bot.message_handler(commands=['roll'])
def handle_command(message):
    roll = random.randint(1, 100)
    bot.send_message(message.chat.id, roll)
    bot.getChatMembersCount()


bot.polling(none_stop=True, interval=0)

错误:

AttributeError: 'TeleBot' 对象没有属性 'getChatMembersCount'

如何使用'getChatMembersCount'?

P。 S. 我用https://github.com/eternnoir/pyTelegramBotAPI

【问题讨论】:

    标签: python bots telegram-bot py-telegram-bot-api


    【解决方案1】:

    它被称为get_chat_members_count (direct link to implementation)。

    来自https://github.com/eternnoir/pyTelegramBotAPI/

    方法

    所有 API 方法都位于 TeleBot 类中。它们被重命名以遵循常见的 Python 命名约定。例如。 getMe 重命名为 get_me,sendMessage 重命名为 send_message。

    【讨论】:

      【解决方案2】:
      #Send a text from bot to channel by forward
      @bot.message_handler(func=lambda message: True)
          def main(message):
              if message.forward_from_chat:
                  apiuz=message.forward_from_chat
                  count = bot.get_chat_members_count(apiuz.id)
                  bot.send_message(chat_id, count)
      

      【讨论】:

      • 添加一些描述
      猜你喜欢
      • 1970-01-01
      • 2022-06-12
      • 2016-09-17
      • 1970-01-01
      • 2018-02-25
      • 2014-08-06
      • 1970-01-01
      • 2016-08-07
      • 1970-01-01
      相关资源
      最近更新 更多