Giter Club home page Giter Club logo

Comments (4)

leocassarani avatar leocassarani commented on August 24, 2024

@leolara If you've already established an RTM connection, I would suggest iterating over the Channels slice of the Info struct to find what you're looking for: https://godoc.org/github.com/nlopes/slack#Info

func FindChannelByName(rtm *slack.RTM, name string) *slack.Channel {
    for _, ch := range rtm.GetInfo().Channels {
        if ch.Name == name {
            return &ch
        }
    }
    return nil
}

The only gotcha there is that if a channel is renamed, the Info struct won't get updated. If you need to support that use case, you could keep your own copy of the Channels slice and update it manually every time you receive a ChannelRenameEvent over the RTM connection.

Hope this helps!

from slack.

leolara avatar leolara commented on August 24, 2024

@leocassarani yes, that is what I thought!! But, how do I get the channel ID from the Channel struct?

from slack.

leocassarani avatar leocassarani commented on August 24, 2024

@leolara Channel embeds groupConversation, which embeds conversation, so you're looking for channel.ID: https://github.com/nlopes/slack/blob/4a9ff5f6ed8bb0df51620f49ee90fc0858a2913e/conversation.go#L5

However, I think your confusion is understandable here. Because those embedded structs are private, they don't show up in GoDoc. I myself have struggled with that at one point or another.

@nlopes any thoughts on making those private structs public, or finding some other way to make the fields show up in GoDoc?

from slack.

leolara avatar leolara commented on August 24, 2024

@leocassarani

I do not think it is possible to do that, which is a bad thing for godoc.

Why groupConversation and conversation should be private? Perhaps the solution is to make them public.

from slack.

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.