Open glennblock opened 8 years ago
I'd like to second this. I'm trying to write a prototype application using this library and am having to refer to other projects to get an idea of how this library is supposed to work. So far it's proving very difficult.
3rd this - How do you receive messages? I can't see any events for incoming messages?
The SlackSocketClient has an incoming messages event.
Check issue no 3 (closed) - Unless I've missed something the event is not firing:
Dim gSlackClient = New SlackSocketClient("xxxxxx")
AddHandler gSlackClient.OnHello, AddressOf OnSlackHello
AddHandler gSlackClient.OnMessageReceived, AddressOf OnSlackMessageRecieved
gSlackClient.Connect(AddressOf OnSlackConnected)
Private Sub OnSlackHello()
console.writeline("Hello") 'Fires
End Sub
Private Sub OnSlackMessageRecieved(ByVal obj As NewMessage)
Console.WriteLine(obj.text) 'Nothing
End Sub
Private Sub OnSlackConnected(ByVal LoginResponse As LoginResponse)
Console.WriteLine("connected") 'Fires
End Sub
your app needs to stay running after you call .Connect(). the SlackAPI doesn't do that on its own.
It's a winforms app so the connection is open.
Are you running it on a separate thread from the UI thread? Maybe the thread is closing.
Here is the C# I have running now in LINQPad if this helps.
var authToken = "ADD YOUR TOKEN HERE";
SlackSocketClient client = new SlackSocketClient(authToken);
SlackClient client2 = new SlackClient(authToken);
client2.TestAuth((art) => art.Dump());
client.Connect((connected) =>
{
//This is called once the client has emitted the RTM start command
"Started".Dump();
}, () =>
{
//This is called once the RTM client has connected to the end point
"Connected".Dump();
});
client.OnMessageReceived += (message) =>
{
message.Dump();
if (message.type == "message" && message.text == "test")
{
client.SendMessage((mr) => mr.Dump("Message Received"), message.channel, "Testing Socket");
var buttons = new Attachment();
buttons.text = "Lets pick a button";
buttons.color = "#FF0000";
client2.PostMessage((pmr) => pmr.Dump("Post Message Received"), message.channel, "Testing SlackClient", attachments: new[] { buttons});
}
};
The easiest way to see how it works is to have a play with linqpad or check out the integration tests.
I have implemented both the websocket sending of a message and web api posting a message in this as well.
@chinswain I just used your exact code in LINQPad with my Auth token and it works.
Here's a simple gist I had use for scriptcs.
https://gist.github.com/glennblock/8bab71fb01ddd26e09127aba2d41d02a On Sun, Jul 24, 2016 at 8:50 PM Andrew McClenaghan notifications@github.com wrote:
@chinswain https://github.com/chinswain I just used your exact code in LINQPad with my Auth token and it works.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Inumedia/SlackAPI/issues/52#issuecomment-234830579, or mute the thread https://github.com/notifications/unsubscribe-auth/AAInRDJ6cQhcy-mTXFVIQsXwBCkenn0Eks5qZDJ3gaJpZM4I6tyl .
Can we send Messages with Buttons and Attachments using this SlackAPI?
@Vanshita see the example from @andymac4182 earlier in this thread. It includes a button from my read. I haven't tried it out, though.
Hey @kenrachynski. Thanks for helping me. I tried the same code, but in Visual Studio 2015 with some changes and It is working now. One more thing, I wish to send a direct message with all buttons and attachments instead of posting to a channel, I cannot find a function like PostMessage with post to direct user instead of channel. Could you please help me?
@Vanshita from memory you can post to the username
instead of the #channel
and that will work.
@andymac4182 It is working when I am passing the user Id to the function, but not with username. Also, I am able to get the user list only from RTM and not websocket.
I agree that this library is missing some good examples and documentation how to use it. Especially for beginners its currently pretty hard to figure out how it works.
I therefore added a simple but complete example for sending a message to the wiki. Feedback is of course welcome! https://github.com/Inumedia/SlackAPI/wiki/Complete-example-for-sending-a-message
Hi I'm a beginner for this API and had a trouble with sending and receiving messages simultaneously with SlackSocketClient. I managed to find a solution and add it to the wiki: https://github.com/Inumedia/SlackAPI/wiki/RTM-API-example-for-just-parroting-messages-received But review is required, because I'm not confident of my solution and English writing skill honestly...
I'd like to see examples for interacting with dialogs. I noticed a Dialog model in the library. But I don't know how to use it.
Comprehensive docs would be nice, but minimally it would help if there were more examples, like showing how to actually post a message to a channel :-)