Created
January 3, 2017 05:01
-
-
Save en129/8d2e973a3203c79fafc1dff75246393a to your computer and use it in GitHub Desktop.
pushbulletからチャットテキスト受信
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
#! /bin/sh | |
getIden=$(echo $("$PROGDIR"../pushbullet-bash/pushbullet pushes recent) | grep -o -E '([A-Za-z0-9]{22})') | |
#iden表示 | |
#echo $getIden | |
if [ -z $getIden ]; then | |
#testコマンドオプション-z:文字列長が0ならば真 | |
echo "not pushes receved" | |
else | |
#受信したテキスト表示 | |
getBody=$(echo $("$PROGDIR"../pushbullet-bash/pushbullet pull $getIden) | tr '{' '\n' | tr ',' '\n' | grep \"body\" | cut -d'"' -f4) | |
echo $getBody | |
fi |
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 pushbullet_apikey = '--your pushbullet API key' | |
var WebSocket = require('ws'); | |
var ws = new WebSocket('wss://stream.pushbullet.com/websocket/'+pushbullet_apikey); | |
var exec = require('child_process').exec; | |
ws.on('message', function(data, flags) { | |
console.log('received: %s', data); | |
if( data.match("push") ) { | |
exec('./getLastPush.sh', function(err, stdout, stderr){ | |
if (stdout) { console.log(stdout); } | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment