Skip to content

Commit

Permalink
update some
Browse files Browse the repository at this point in the history
  • Loading branch information
uryyyyyyy committed Jan 27, 2016
1 parent c527dd7 commit 1d737eb
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 128 deletions.
24 changes: 15 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
nodeJsSamples
=============

## setup
# slackBot

install nodeJS in your local
(AWS lambda use v0.10.36)
this repo has some slack bot(running on AWS-Lambda and NodeJS)

`npm install`
the functions are

## run
- botChat
- simplest sample of "slack outgoing web-hook" with "AWS Lambda & API Gateway"
- bots communicate each other.

## test
- dustAlert
- sample of "slack incoming web-hook" with "scheduled AWS Lambda"
- when dust day has come, alert it.

## deploy
- weatherReport
- sample of "slack incoming web-hook" with "scheduled AWS Lambda"
- when today will be rainy, alert it.

- temperatureReport
- sample of "slack incoming web-hook" with "scheduled AWS Lambda"
- when today will be cold/hot(±5 than yesterday), alert it.
17 changes: 11 additions & 6 deletions dustAlert/src/week.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ var postJson = function(obj, succCB, failCB) {
var options = {
hostname: 'hooks.slack.com',
port: 443,
path: '/services/XXX/XXX/XXX', //set your webhook url.
path: '/services/XXX',
method: 'POST',
headers: {
'Content-Type': 'application/json'
Expand Down Expand Up @@ -39,17 +39,17 @@ var calcText = function(date){
console.log(date);
var weekNum = date.getDay();
if(weekNum === 1){//Mon
return "明日 ハ 「可燃ゴミ」 ノ 日デス"
return "今日 ハ 「可燃ゴミ」 ノ 日デス"
}else if(weekNum === 3){//Wed
return "明日 ハ 「資源ゴミ」 ノ 日デス"
return "今日 ハ 「資源ゴミ」 ノ 日デス"
}else if(weekNum === 4){//Thu
return "明日 ハ 「可燃ゴミ」 ノ 日デス"
return "今日 ハ 「可燃ゴミ」 ノ 日デス"
}
if(weekNum === 2){//Tue
date.setDate( date.getDate() + 1 );
var dateNum = date.getDate();
if(1 <= dateNum && dateNum <= 7) {//Tue
return "明日 ハ 月ニ 一度 ノ 「不燃ゴミ」 ノ 日デス\n▒▒▓█▇▅▂∩( ✧Д✧)∩ファイアー▂▅▇█▓▒▒"
return "今日 ハ 月ニ 一度 ノ 「不燃ゴミ」 ノ 日デス\n▒▒▓█▇▅▂∩( ✧Д✧)∩ファイアー▂▅▇█▓▒▒"
}
}
return null;
Expand All @@ -73,7 +73,12 @@ exports.handler = function(event, context) {

var text = calcText(date);
if(text){
postJson({'text': text}, onSuccess, onFailure);
postJson({
'text': text,
"icon_emoji": ":slackbot:",
"username": "slackbot",
"channel": "#bot"
}, onSuccess, onFailure);
}else{
context.done(null, 'a very merry unbirthday to you');
}
Expand Down
31 changes: 0 additions & 31 deletions package.json

This file was deleted.

81 changes: 0 additions & 81 deletions weather.js

This file was deleted.

2 changes: 1 addition & 1 deletion weatherReport/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ var sendToSlack = function(text) {
text: text,
"username": "slackbot",
"icon_emoji": ":slackbot:",
"channel": "#sandbox"
"channel": "#bot"
},
headers: {'Content-Type': 'application/json'}
});
Expand Down

0 comments on commit 1d737eb

Please sign in to comment.