Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Channel info #70

Merged
merged 3 commits into from
Oct 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 26 additions & 44 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -1,45 +1,27 @@
{
"version": "2.0.0",
"tasks": [{
"label": "build-debug",
"type": "shell",
"command": "go",
"group": "build",
"presentation": {
"echo": true,
"reveal": "never",
"focus": false,
"panel": "shared"
},
"args": [
"build",
"-i",
"-gcflags",
"'-N -l'"
],
"linux": {
"args": [
"-o",
"debug",
"${workspaceRoot}/cmd/flottbot/main.go"
]
},
"osx": {
"args": [
"-o",
"debug",
"${workspaceRoot}/cmd/flottbot/main.go"
]
},
"windows": {
"args": [
"-o",
"debug.exe",
"\"${workspaceRoot}\\cmd\\flottbot\\main.go\""
]
},
"problemMatcher": [
"$go"
]
}]
}
"version": "2.0.0",
"tasks": [
{
"label": "build-debug",
"type": "shell",
"command": "go",
"group": "build",
"presentation": {
"echo": true,
"reveal": "never",
"focus": false,
"panel": "shared"
},
"args": [
"build",
"-i",
"-gcflags",
"'-N -l'",
"-o",
"debug",
"${workspaceFolder}/cmd/flottbot/main.go"
],
"problemMatcher": ["$go"]
}
]
}
3 changes: 3 additions & 0 deletions remote/discord/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ func populateMessage(message models.Message, msgType models.MessageType, channel
// message.ChannelName = name
// }

message.Vars["_channel.id"] = channel
message.Vars["_channel.name"] = channel

// Populate message user sender
// These will be accessible on rules via ${_user.email}, etc
if user != nil { // nil user implies a message from an api/bot (i.e. not an actual user)
Expand Down
4 changes: 4 additions & 0 deletions remote/slack/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,10 @@ func populateMessage(message models.Message, msgType models.MessageType, channel
message.ChannelName = name
}

// make channel variables available
message.Vars["_channel.id"] = message.ChannelID
message.Vars["_channel.name"] = message.ChannelName // will be empty if it came via DM

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DM's have a channel ID in Slack, too. Are you sure this wont get populated? It would actually be useful to me if it did.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just _channel.name will be empty, _channel.id will be there

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I guess that makes sense. Although on the eDiscovery API they have names, too. (based on the participants)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, not familiar with that. There's a story for looking at Conversations API (#46) that might help. Though in a 1:1 conversation, name still seems to be omitted, it seems, according to: https://api.slack.com/methods/conversations.info

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think its fine to have an empty name for DMs. Just an interesting idea.


// Populate message with user information (i.e. who sent the message)
// These will be accessible on rules via ${_user.email}, ${_user.id}, etc.
if user != nil { // nil user implies a message from an api/bot (i.e. not an actual user)
Expand Down