Skip to content

Instantly share code, notes, and snippets.

@drewr
Last active February 3, 2025 18:44
Show Gist options
  • Save drewr/0378617a7f4bd1483e6c027d4a66ebf1 to your computer and use it in GitHub Desktop.
Save drewr/0378617a7f4bd1483e6c027d4a66ebf1 to your computer and use it in GitHub Desktop.
Quick slack interaction
  1. Create slack app in the UI (the command line ended up creating an unusable app)
  2. Add these oauth permissions
channels:history
channels:read
groups:history
groups:read
im:history
mpim:history
team:read
users:read
  1. Get admin to approve
  2. Copy the token
(ns drewrbot.core
(:require [clj-slack.users]))
(def username
(memoize
(fn [conn id]
(let [resp (clj-slack.users/info conn id)]
(if (:ok resp)
(select-keys (:user resp) [:real_name :name])
(throw (ex-info "user error" {:id id
:conn (select-keys conn [:api-url])
:response resp})))))))
(defproject drewrbot "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url "http://example.com/FIXME"
:license {:name "EPL-2.0 OR GPL-2.0-or-later WITH Classpath-exception-2.0"
:url "https://www.eclipse.org/legal/epl-2.0/"}
:dependencies [[org.clojure/clojure "1.11.1"]
[org.julienxx/clj-slack "0.8.3"
:exclusions [clj-http/clj-http
cheshire/cheshire]]
;; These aren't technically needed
[clj-http/clj-http "3.13.0"]
[cheshire/cheshire "5.13.0"]]
:repl-options {:init-ns drewrbot.core})
drewrbot.core> (def tok "xoxb-2404970246-8389136563845-xKuIv*************")
drewrbot.core> (def slack {:api-url "https://slack.com/api" :token tok})
drewrbot.core> (->> (clj-slack.conversations/replies slack "C07KQSBDZLZ" "1738171244.769229") :messages(map :user) (map (partial username slack)) (into #{}))
#{{:real_name "****", :name "****"}
{:real_name "Drew Raines", :name "drewr"}
{:real_name "****", :name "****"}
{:real_name "****", :name "****"}...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment