Inumedia / SlackAPI

.NET Implementation of the Slack team communication platform API.
MIT License
452 stars 243 forks source link

`OnMessageReceived` doesn't fire for bot account. #41

Closed suicvne closed 7 years ago

suicvne commented 8 years ago

So,

I've created an instance of SlackSocketClient passing it my team's token for my bot account I've created. After connecting, I hook up the Message Received event as I'd expect it to, and spam some messages into a public testing channel I have my bot in. Code looks like this:

client.Connect ((loginResponse) => 
            {
                    //logged in
                    Console.WriteLine("Logged in! User: " + loginResponse.self.name +
                        "\nGood? " + client.IsConnected);
                    foreach(var chan in client.Channels)
                        Console.WriteLine(chan.name);

                    Connected?.Invoke(this, null);

                    client.OnMessageReceived += (obj) => 
                    {
                                                 Console.WriteLine(obj.text);
                    };
            }, 
            () => 
            {
                    //"socket connected" but fires first before socket is alright.
                    Console.WriteLine("Socket started.");
            });

The event is hooked up. However, setting breakpoints and what not: the actual contents of the event are never called and nothing is ever printed. Is there something I'm missing?

Also, it doesn't seem this API parses private channels the bot is invited to. Unless I'm missing something there too.

Cheers!

suicvne commented 8 years ago

Further information: this was running under Mono 4.2 on Linux. Tested under windows, the events fired.

Inumedia commented 8 years ago

Hi @Luigifan ,

I've heard conflicting reports about bot accounts being able to connect to the RTM WebSocket. Could you double check on both when you get some time. Otherwise this could be related to #3 being reopened.

bootstraponline commented 7 years ago

it doesn't seem this API parses private channels the bot is invited to. Unless I'm missing something there too.

I had the same issue. Here's the fix:

// channels.list (client.Channels) contains public channels only
// https://api.slack.com/methods/channels.list

// groups.list (client.Groups) lists private channels
// https://api.slack.com/methods/groups.list