This file contains hidden or 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
// 更新情報取得 | |
database.ref('list').on('value', (snapshot) => { | |
this.list = getList(snapshot); | |
this.update(); | |
}) |
This file contains hidden or 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
database.ref('list').once('value').then((snapshot) => { | |
const list = getList(snapshot); | |
riot.mount('List', { list }); | |
riot.mount('Add'); | |
}) |
This file contains hidden or 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
const getList = (snapshot) => { | |
const obj = snapshot.val(); | |
if (!obj) return []; | |
return Object.keys(obj).map((key) => obj[key]); | |
} |
This file contains hidden or 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
// Initialize Firebase | |
const config = { | |
apiKey: "sakiika_ikaga00sakiika_ikaga", | |
authDomain: "sakiika-ikaga.firebaseapp.com", | |
databaseURL: "https://sakiika-ikaga.firebaseio.com", | |
storageBucket: "sakiika-ikaga.appspot.com", | |
messagingSenderId: "0123456789" | |
}; | |
firebase.initializeApp(config); |
This file contains hidden or 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
const testPromise = (num,sec) => { | |
const random = Math.round(Math.random() * 10); //ランダムで0〜9の数値を返す | |
return new Promise((resolve, reject) => { | |
setTimeout(() => { | |
console.log(num + ": random is " + random); | |
if (random === 3) reject("random is three"); | |
resolve("random is " + random) | |
},sec); | |
}) | |
} |
This file contains hidden or 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
const timeoutPromise = (sec, msg) => { | |
return new Promise((resolve, reject) => { | |
setTimeout(()=>{ | |
console.log(msg); | |
resolve(); | |
},sec) | |
}); | |
} | |
timeoutPromise(4000,"4秒経過") |
This file contains hidden or 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
const test = new Promise((resolve, reject) => { | |
setTimeout(()=>{ | |
console.log("4秒経過"); | |
resolve(3000); | |
},4000) | |
}); | |
test | |
.then((sec) => new Promise((resolve) => setTimeout(() => { console.log("7秒経過");resolve(2000); },sec))) //sec=3000 | |
.then((sec) => new Promise((resolve) => setTimeout(() => { console.log("9秒経過");resolve(1000); },sec))) //sec=2000 |
This file contains hidden or 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
module.exports = (robot) => { | |
robot.router.get('/', (req, res) => { | |
res.end("ページ"); | |
robot.send({room: '<チャンネルID>'}, "アクセスあり"); | |
}); | |
}; |
This file contains hidden or 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
module.exports = (robot) => { | |
robot.router.get('/', (req, res) => { | |
res.end("<出力内容>"); | |
}); | |
}; |
This file contains hidden or 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
module.exports = (robot) -> | |
robot.hear /.+/i, (msg) -> | |
@exec = require('child_process').exec | |
user_name= msg.match[0].split(" ")[0]; | |
Command = msg.match[0].replace(user_name,""); | |
@exec "#{Command}", (error, stdout, stderr) -> | |
msg.send error if error? | |
msg.send stdout if stdout? | |
msg.send stderr if stderr? |