【问题标题】:Get user's groups in rocketchat using python api使用 python api 在 Rocketchat 中获取用户组
【发布时间】:2019-09-17 15:52:51
【问题描述】:

如何使用 python API 获取用户的房间(组)?我拥有 Rocketchat 的管理员权限。我试过了:

from rocketchat_API.rocketchat import RocketChat    

rocket = RocketChat(
    ROCKET_CHAT_ADMIN_USERNAME,
    ROCKET_CHAT_ADMIN_PASSWORD,
    server_url=ROCKET_CHAT_HOST)

rocket.users_info(USER_ID)

但它不包含组信息。我认为我应该根据Rest API 为这个方法提供另一个参数,但我不知道如何。

【问题讨论】:

  • 按组是指channel 吗?
  • @HashRocketSyntax 我的意思是房间。

标签: python rocket.chat


【解决方案1】:

您应该像这样提供额外的关键字参数:

rocket.users_info(user_id=USER_ID, fields='{"userRooms": 1}')

userRooms 是您需要根据 Rest API 指定的附加字段。

【讨论】:

    【解决方案2】:

    查看 REST API,您也会对这种替代方法 spotlight 感兴趣:

    GET /api/v1/spotlight

    搜索用户可见的用户或房间。

    https://rocket.chat/docs/developer-guides/rest-api/miscellaneous/spotlight/

    并查看 Python API 的源代码:

    def spotlight(self, query, **kwargs):
            """Searches for users or rooms that are visible to the user."""
            return self.__call_api_get('spotlight', query=query, kwargs=kwargs)
    

    https://github.com/jadolg/rocketchat_API/blob/master/rocketchat_API/rocketchat.py

    【讨论】:

      猜你喜欢
      • 2018-07-03
      • 2018-05-10
      • 2019-09-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-11-16
      • 2021-08-18
      • 1970-01-01
      相关资源
      最近更新 更多