Giter Site home page Giter Site logo

Add more examples about slackapi HOT 18 OPEN

inumedia avatar inumedia commented on September 7, 2024 3
Add more examples

from slackapi.

Comments (18)

kenrachynski avatar kenrachynski commented on September 7, 2024 3

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.

from slackapi.

ErikKalkoken avatar ErikKalkoken commented on September 7, 2024 3

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

from slackapi.

chinswain avatar chinswain commented on September 7, 2024

3rd this - How do you receive messages? I can't see any events for incoming messages?

from slackapi.

Zaicon avatar Zaicon commented on September 7, 2024

The SlackSocketClient has an incoming messages event.

from slackapi.

chinswain avatar chinswain commented on September 7, 2024

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

from slackapi.

kenrachynski avatar kenrachynski commented on September 7, 2024

your app needs to stay running after you call .Connect(). the SlackAPI doesn't do that on its own.

from slackapi.

chinswain avatar chinswain commented on September 7, 2024

It's a winforms app so the connection is open.

from slackapi.

Fausto-Payano-Axomic avatar Fausto-Payano-Axomic commented on September 7, 2024

Are you running it on a separate thread from the UI thread? Maybe the thread is closing.

from slackapi.

andymac4182 avatar andymac4182 commented on September 7, 2024

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.

from slackapi.

andymac4182 avatar andymac4182 commented on September 7, 2024

@chinswain I just used your exact code in LINQPad with my Auth token and it works.

from slackapi.

glennblock avatar glennblock commented on September 7, 2024

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 [email protected]
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
#52 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAInRDJ6cQhcy-mTXFVIQsXwBCkenn0Eks5qZDJ3gaJpZM4I6tyl
.

from slackapi.

vanshita-tilwani avatar vanshita-tilwani commented on September 7, 2024

Can we send Messages with Buttons and Attachments using this SlackAPI?

from slackapi.

kenrachynski avatar kenrachynski commented on September 7, 2024

@vanshita see the example from @andymac4182 earlier in this thread. It includes a button from my read. I haven't tried it out, though.

from slackapi.

vanshita-tilwani avatar vanshita-tilwani commented on September 7, 2024

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?

from slackapi.

andymac4182 avatar andymac4182 commented on September 7, 2024

@vanshita from memory you can post to the username instead of the #channel and that will work.

from slackapi.

vanshita-tilwani avatar vanshita-tilwani commented on September 7, 2024

@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.

from slackapi.

Detsudetsu avatar Detsudetsu commented on September 7, 2024

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...

from slackapi.

lorddev avatar lorddev commented on September 7, 2024

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.

from slackapi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.