我已经编写了代码,以便在任何给定通道的松弛工作区内发布到通道(假设它存在),但我不断在通道上获得channel_not_found错误

1.)我可以证实他们确实存在

2.) Channels 不是私有的,因为它们前面有#符号而不是锁 .

我已经检查了我的松弛应用程序仪表板并将其安装在工作区上(也通过工作区管理员验证) . 我已将OAuth访问令牌(以xoxp开头)和Bot用户OAuth访问令牌(以xoxb开头)存储为我的计算机上的环境变量 . 我已经尝试在应用程序中使用这两个并获得与以下权限/范围相同的结果:chat:write:bot,chat:write:user和bot . 我可以通过webhooks发送消息,但我知道我需要为应用可能发布的每个 Channels 创建一个webhook . 此应用程序需要具有多种功能,能够根据用户希望的更新方式指导消息用户 . 任何有助于找到无法找到 Channels 的帮助都将非常感激 . 在下面的代码片段中,post_channel()函数是我正在使用的测试函数,并且简单地更改了通道名称等 .

from slackclient import SlackClient
import os

webhook_url = "a webhook url"


def post_message_channel(text, token, channel, is_name):

    """
    Creates an api call to post to a message to specific channel (private or
    public)and returns the JSON object that is returned by the slack api call.

    :param text: The message to post the slack channel.
    :param token: The slack app token to identify the sender.
    :param title: The title of the message being sent.
    :param channel: The channel to post the message to.
    :param is_name: If true, then the channel param holds a name, else it holds a channel id
    :return: The JSON object that the slack api responds with.
    """
    if is_name:
        formatted_channel = "#" + channel
    else:
        formatted_channel = channel
    slack_client = SlackClient(token)
    output_json = slack_client.api_call(
        "chat.postMessage",
        channels = formatted_channel,
        text = text,
        as_user = 1
    )
    return output_json


def post_channel():
    message = "This is a test for posting to a channel"
    my_token = os.environ["SLACK_BOT_USER_TOKEN"]
    print(post_message_channel(message, my_token, 'file_tracker_test', True))