Skip to content

Instantly share code, notes, and snippets.

View seratch's full-sized avatar

Kazuhiro Sera seratch

View GitHub Profile
@seratch
seratch / Dockerfile
Last active April 2, 2025 11:15
Slack OAuth App Example (Google Cloud Run + Datastore)
# https://hub.docker.com/_/python
FROM python:3.9.2-slim-buster
# Allow statements and log messages to immediately appear in the Knative logs
ENV PYTHONUNBUFFERED True
# Copy local code to the container image.
ENV APP_HOME /app
WORKDIR $APP_HOME
COPY . ./
@seratch
seratch / SlackApp.gs
Created February 18, 2021 15:51
Slack App in Google Apps Script
// *** Request Verification ***
// The currently recommended way is to verify request signature: https://api.slack.com/authentication/verifying-requests-from-slack
// Unfortunately, GAS web apps don"t have means to access request headers. Thus, this example uses the old way to verify requests.
// >>> Settings > Basic Information > App Credentials > Verification Token
const legacyVerificationToken = PropertiesService.getScriptProperties().getProperty("SLACK_VERIFICATION_TOKEN");
// *** OAuth Access Token ***
// Install your Slack app into its development workspace.
// >>> Settings > Install App > Bot User OAuth Access Token
const token = PropertiesService.getScriptProperties().getProperty("SLACK_BOT_TOKEN");
@seratch
seratch / go.mod
Last active August 14, 2023 16:16
Slack Socket Mode in Go
module socket-mode-app
go 1.15
require github.com/slack-go/slack v0.8.0
@seratch
seratch / SlackMod.java
Created December 23, 2020 05:20
Minecraft Forge 1.16 Mod that can call Slack APIs
package com.github.seratch.slack_mod;
import com.slack.api.Slack;
import com.slack.api.methods.response.chat.ChatPostMessageResponse;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.server.FMLServerStartingEvent;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@seratch
seratch / README.md
Last active November 16, 2020 07:09
Slack usergroup select menu
python3 -m venv .venv
source .venv/bin/activate
pip install -U pip
pip install -r requirements.txt

export SLACK_BOT_TOKEN=(your own value)
export SLACK_SIGNING_SECRET=(your own value)
python app.py
@seratch
seratch / app.py
Last active October 17, 2020 14:56
Deploying a Bolt for Python app using only AWS CLI
from slack_bolt.adapter.aws_lambda import SlackRequestHandler
SlackRequestHandler.clear_all_log_handlers()
import logging
logging.basicConfig(format="%(asctime)s %(message)s", level=logging.DEBUG)
from slack_bolt import App, Ack
from slack_sdk.web import WebClient
# export SLACK_BOT_TOKEN=xoxb-
@seratch
seratch / MyApp.kt
Last active October 5, 2020 02:57
Steps from Apps in Kotlin
import com.slack.api.bolt.App
import com.slack.api.bolt.jetty.SlackAppServer
import com.slack.api.bolt.middleware.builtin.WorkflowStep
import com.slack.api.model.block.Blocks.divider
import com.slack.api.model.block.Blocks.section
import com.slack.api.model.block.LayoutBlock
import com.slack.api.model.block.composition.BlockCompositions.plainText
import com.slack.api.model.kotlin_extension.block.withBlocks
import com.slack.api.model.view.Views.view
import com.slack.api.model.view.Views.viewTitle
@seratch
seratch / index.js
Last active September 18, 2020 06:38
Passing request headers to Bolt JS
const { LogLevel } = require("@slack/logger");
const { App } = require("@slack/bolt");
const { MyExpressReceiver } = require("./receiver")
const app = new App({
token: process.env.SLACK_BOT_TOKEN,
logLevel: process.env.SLACK_LOG_LEVEL || LogLevel.DEBUG,
receiver: new MyExpressReceiver({
signingSecret: process.env.SLACK_SIGNING_SECRET
}),
@seratch
seratch / Gemfile
Last active September 17, 2020 07:26
Slack app built with Sinatra
# frozen_string_literal: true
source "https://rubygems.org"
gem "sinatra"
gem "slack-ruby-client"
@seratch
seratch / Application.java
Created September 8, 2020 14:56
Bolt for Java + Spring Boot
package hello;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
@SpringBootApplication
@ServletComponentScan
public class Application {
public static void main(String[] args) {