Skip to content

Instantly share code, notes, and snippets.

@hyuki
Created August 19, 2018 05:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hyuki/9c4c98e9ca92893a4477eb7536372086 to your computer and use it in GitHub Desktop.
Save hyuki/9c4c98e9ca92893a4477eb7536372086 to your computer and use it in GitHub Desktop.
Script to send "/clip yesterday" to your channel. (Slack-Evernote integration)
#! /usr/bin/env ruby
#
# clip-yesterday.rb - Script to send "/clip yesterday" to your channel.
#
# WARNING: This script uses Slack Legacy Tokens. Use at your own risk.
#
# Author: hyuki
# Based on:
# * https://github.com/wgkoro/lambda_slack_command
# * https://api.slack.com/custom-integrations/legacy-tokens
# * https://twitter.com/WG_koro/status/1029657575971741696
require 'uri'
require 'open-uri'
# $ grep CLIP_YESTERDAY ~/.bash_profile
# export CLIP_YESTERDAY_TOKEN=xoxp-0000000000-0000000000-000000000000-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
# export CLIP_YESTERDAY_CHANNEL_ID=C00000000
params = {
'token' => ENV['CLIP_YESTERDAY_TOKEN'],
'channel' => ENV['CLIP_YESTERDAY_CHANNEL_ID'],
'command' => '/clip',
'text' => 'yesterday',
}
open("https://slack.com/api/chat.command?#{URI.encode_www_form(params)}") do |f|
puts f.readlines
end
# vim: set filetype=ruby:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment