Skip to content

Instantly share code, notes, and snippets.

View sweetyclem's full-sized avatar

Clementine sweetyclem

  • Kelowna
View GitHub Profile
function respond(payload, respond) {
console.log('selectedOption: ', payload.actions[0].value)
switch (payload.callback_id) {
case 'anti_racism_article_book':
respondToAntiRacismButton(payload.actions[0].value, respond)
break
case 'anti_sexism_article_book':
respondToAntiSexismButton(payload.actions[0].value, respond)
break
SLACK_BOT_TOKEN=YOUR_BOT_TOKEN
SLACK_VERIF_TOKEN=YOUR_VERIF_TOKEN
SLACK_SIGNING_SECRET=YOUR_SIGNING_SECRET
PORT=5000
const bodyParser = require('body-parser');
const subjects = require('./elements/subjects.json')
module.exports.listenForCommands = async function (app) {
app.use(bodyParser.urlencoded({ extended: true }))
app.use(bodyParser.json())
app.post('/commands', (req, res) => {
const { token, user_id, channel_id } = req.body
console.log(`Received a slash command from user ${user_id} in channel ${channel_id}`)
if (process.env.NODE_ENV !== "production") {
require("dotenv").config()
}
const express = require('express')
const port = process.env.PORT
const app = express()
const events = require('./events')
const interactions = require('./interactions')
const slashCommand = require('./slashCommand')
[
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Here is an <https://witanddelight.com/2020/05/how-white-people-can-be-better-allies-to-the-black-community/|article>: ow how white people can be better allies to the black community :rolled_up_newspaper: :fist:"
}
}
]
const { createMessageAdapter } = require('@slack/interactive-messages')
const slackSigningSecret = process.env.SLACK_SIGNING_SECRET
const slackInteractions = createMessageAdapter(slackSigningSecret)
const articleOrBookButton = require('./elements/articleOrBookButton.json')
module.exports.listenForInteractions = function (app) {
app.use('/interactions', slackInteractions.requestListener())
}
slackInteractions.action({ type: 'select' }, (payload, respond) => {
{
"fallback": "Upgrade your Slack client to use messages like these.",
"color": "#3AA3E3",
"attachment_type": "default",
"actions": [
{
"name": "article",
"text": "Article",
"type": "button",
"value": "article"
/node_modules
npm-debug.log
.DS_Store
/*.env
if (process.env.NODE_ENV !== "production")
{
require("dotenv").config()
}
const express = require('express')
const port = process.env.PORT
const app = express()
app.listen(port, function () {
const { createEventAdapter } = require('@slack/events-api')
const slackSigningSecret = process.env.SLACK_SIGNING_SECRET
const slackEvents = createEventAdapter(slackSigningSecret)
function listenForEvents(app) {
app.use('/events', slackEvents.requestListener())
}
slackEvents.on('app_mention', (event) => {
console.log(`Received an app_mention event from user ${event.user} in channel ${event.channel}`)