Skip to content

Instantly share code, notes, and snippets.

@katsumata-ryo
Created December 1, 2018 17:45
Show Gist options
  • Save katsumata-ryo/f6c5c4736a58a3510e737681ae6cb68f to your computer and use it in GitHub Desktop.
Save katsumata-ryo/f6c5c4736a58a3510e737681ae6cb68f to your computer and use it in GitHub Desktop.
jobcan touch by aws lambda for ruby via IFTTT
source "https://rubygems.org"
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
gem 'slack-ruby-client'
require 'slack-ruby-client'
TOKEN_ID = ENV['TOKEN_ID']
def lambda_handler(event:, context:)
Slack.configure do |config|
config.token = TOKEN_ID
end
client = Slack::Web::Client.new
begin
client.chat_command(
channel: '#times_katsumata',
command: '/jobcan_touch',
text: 'by AWS Lmabda for Ruby via IFTTT',
as_user: true
)
rescue => e
{statusCode: 422, body: JSON.generate({class: e.class, message: e.message})}
end
{statusCode: 200, body: JSON.generate({message: 'ok'})}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment