Comments (4)
@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.
@leocassarani yes, that is what I thought!! But, how do I get the channel ID from the Channel
struct?
from slack.
@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.
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)
- Webhook Sending Functions Seem to Use the Regular JSON Encoder Which Escapes HTML Characters Unnecessarily HOT 1
- Get Block data from webhook payload
- request for a release cut HOT 2
- Release 0.21.4 breaks slash commands in socket mode
- Slash Command returns "bad_error_message" HOT 7
- file_input feature support in slack-go HOT 2
- Unable to render buttons using slack.Attachment HOT 2
- Receiving no payload on websocket based events HOT 2
- Custom http client Resty retry function does not work
- Not possible to set initial value of RichTextInputBlockElement due to wrong type HOT 1
- bug: Missing `team_id` param HOT 1
- Why doesn't the getFile method return []body HOT 1
- Unable to post messages when in deployment HOT 2
- files.upload is getting deprecated by Slack HOT 1
- Upload Files V2: Ability to upload multiple files in one message HOT 1
- UploadFileV2 uploads incorrectly when using text `Content` parameter
- conversations.history unmarshall bug HOT 1
- AddRemoteFile fails because of token in querystring HOT 4
- Slack Functions HOT 2
- Events API Reconciliation HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from slack.