我正在尝试检索我工作区中的所有空闲频道。我有超过 1000 个频道和对话限制。列表是 1000,它说我必须使用光标才能进入下一页。 如果有人可以帮助我,我对此很陌生,我将非常感激。 提前致谢。强文本
import json
from slack_sdk.web.async_client import AsyncWebClient
from slack_sdk import WebClient
from flask import Flask, request,make_response, jsonify
# WebClient insantiates a client that can call API methods
# When using Bolt, you can use either `app.client` or the `client` passed to listeners.
client = WebClient("xoxb-")
# You probably want to use a database to store any conversations information ;)
conversations_store = {}
def fetch_conversations():
try:
# Call the conversations.list method using the WebClient
result = client.conversations_list()
save_conversations(result["channels"])
print(result["response_metadata"]["next_cursor"])
if result["response_metadata"]["next_cursor"] is not None:
except SlackApiError as e:
logger.error("Error fetching conversations: {}".format(e))
# Put conversations into the JavaScript object
def save_conversations(conversations):
conversation_id = ""
for conversation in conversations:
# Key conversation info on its unique ID
conversation_id = conversation["id"]
print(conversation["name"])
# Store the entire conversation object
# (you may not need all of the info)
conversations_store[conversation_id] = conversation
fetch_conversations()