• Stars
    star
    329
  • Rank 128,030 (Top 3 %)
  • Language
    Ruby
  • License
    MIT License
  • Created almost 11 years ago
  • Updated almost 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Upload files to Slack chat from the command-line.

Slackcat

Upload files and snippets to Slack chat from the command-line.

Getting started

Log in to your slack.com account and get your API token from https://api.slack.com/.

gem install slackcat
export SLACK_TOKEN=<your api token>
echo 'hello world' | slackcat -c <channel>

Note: since gem dependencies build extension modules, you may need ruby headers installed. For example, using system ruby on debian derivatives, you need to install the ruby-dev package.

Environment variables

  • SLACK_TOKEN: your token from https://api.slack.com/.
  • SLACK_CHANNEL: default destination channel; will be used if no -c, -g or -u option given

Command-line options

            --token, -k <s>:   Slack API token
         --channels, -c <s>:   Channels to share
           --groups, -g <s>:   Groups to share
            --users, -u <s>:   Users (DMs) to share
         --filetype, -t <s>:   File type identifier
            --title, -T <s>:   Title of file
         --filename, -n <s>:   Filename of file
  --initial-comment, -i <s>:   Initial comment to add
                 --post, -p:   Post instead of upload
            --multipart, -m:   Multipart upload each file
         --download, -d <s>:   Download a linked file
          --save-as, -s <s>:   Save downloaded file as
                 --help, -h:   Show this message

Basic usage: text snippets

To upload text snippets, slackcat is used similarly to unix cat: read data from STDIN or list filenames as arguments. Multiple files will be concatenated.

Examples:

date | slackcat -c general
slackcat -u buddy foo.txt bar.txt

Uploads to slack are private by default. If you list channels, groups or usernames, content will be shared to them.

Multipart file uploads

If you wish to upload binary files, for example images, use the -m option, which will cause each file to be uploaded separately.

Example:

slackcat -c general -m kitten.jpg cat.gif

Slack does a good job of setting filetype correctly from mimetype, though you may override this with the -t option.

This mode does not read stdin.

Post messages as chat text

To post text as a normal chat, instead of as a text snippet, use the -p option.

Example:

date | slackcat -c general -p
slackcat -u buddy -p foo.txt bar.txt

Due to a limitation of the slack api you may also pass only one channel, group or username.

Example usage from vim

Upload contents of buffer:

:%! slackcat -c dev

Example usage from emacs

Upload contents of region:

M-| slackcat -c dev

To make a named function:

(setenv "SLACK_TOKEN" "<your api token>")

(defvar slackcat-bin  "slackcat" "Command to invoke slackcat.")
(defvar slackcat-args "-c dev"   "Default arguments to pass to slackcat.")

(defun slackcat (&optional b e)
  "Upload contents of region to slack chat."
  (interactive "r")
  (let ((args (read-from-minibuffer "slackcat args: " slackcat-args)))
    (shell-command-on-region b e (format "%s %s" slackcat-bin args))))

More Repositories

1

org-present

Ultra-minimalist presentation minor-mode for Emacs org-mode.
Emacs Lisp
360
star
2

slackbotsy

Ruby bot for Slack chat, inspired by botsy.
Ruby
76
star
3

let-me-in

Add my IP to an AWS security group so I can ssh to instances (and do other useful things)
Go
50
star
4

ecr-login

Lightweight login helper for AWS Container Registry
Go
39
star
5

dockerfiles

Collection of dockerfiles for hub.docker.com/u/rlister
Dockerfile
31
star
6

stax

Highly-opinionated AWS Cloudformation stack handling tools
Ruby
18
star
7

awful

Ruby gem providing simple AWS cmdline tasks and YAML persistence.
Ruby
14
star
8

asg-route53

Write AWS Route53 records containing members of an Autoscaling group.
Go
14
star
9

slackbotsy_example

Example deployment of slackbotsy using sinatra, with example scripts.
Ruby
9
star
10

argus

Docker image builder for AWS Elastic Container Registry
Ruby
8
star
11

auger

Test-driven ops
Ruby
7
star
12

ec2tags

Small golang program to return AWS EC2 instance tags as environment variables.
Go
6
star
13

emacs.d

My emacs configs.
Emacs Lisp
5
star
14

puppet-npm-simple

Puppet package provider for node.js npm modules.
Ruby
5
star
15

emacs-haste-client

Native emacs lisp client for hastebin.com.
Emacs Lisp
5
star
16

supervisord-aws

Dashboard for supervisord instances with AWS auto-scaling group discovery.
Ruby
4
star
17

coreos_ami

Ruby gem to discover CoreOS AMIs for AWS.
Ruby
3
star
18

chef-dokku-simple

Chef cookbook for installing dokku using the default bootstrap script.
Ruby
3
star
19

mark-forward-sexp

Emacs commands to mark region inside matched delimiters.
Emacs Lisp
3
star
20

smed

Simple editor for AWS SecretsManager
Go
3
star
21

host_range

Ruby gem for using hostname range patterns.
Ruby
2
star
22

puppet-hcmbcs

Puppet Package provider for HCMBCS.
Ruby
2
star
23

builder_beer

Build docker containers
Ruby
2
star
24

capistrano-influxdb

Record capistrano 3 deploy events using influxdb.
2
star
25

perl-HostRange

Perl module port of ruby gem host_range.
1
star
26

resque_cmdline

A simple, fast command-line tool for showing info about resque/sidekiq workers.
Ruby
1
star
27

iam-rotate

Check for AWS IAM keys that need to be rotated
Ruby
1
star
28

yppoppassd

Eudora password change server.
1
star
29

atomics_resource

Ruby and/or Rails interface for Atomics (MySQL over HTTP) queries.
Ruby
1
star
30

github-get

Simple golang http client to deliver individual files from a github repo to a production server
Go
1
star
31

opsgenie-send

Send alerts and heartbeats to Opsgenie
Ruby
1
star
32

selectFilter

Generic javascript function to filter select lists by regex.
JavaScript
1
star
33

rlister.github.com

HTML
1
star
34

pipeline

Copy file to multiple hosts using pipeline of netcats.
Ruby
1
star
35

augweb

Web interface for auger test-driven ops.
JavaScript
1
star
36

dwm

Personal dwm hacks, checkout hacks branch for my code.
C
1
star
37

congress_api

Simple wrapper for ProPublica Congress API
Ruby
1
star