Created
December 1, 2018 17:45
jobcan touch by aws lambda for ruby via IFTTT
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source "https://rubygems.org" | |
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" } | |
gem 'slack-ruby-client' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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