Skip to content

Instantly share code, notes, and snippets.

@en129
Created January 3, 2017 05:01
Show Gist options
  • Save en129/8d2e973a3203c79fafc1dff75246393a to your computer and use it in GitHub Desktop.
Save en129/8d2e973a3203c79fafc1dff75246393a to your computer and use it in GitHub Desktop.
pushbulletからチャットテキスト受信
#! /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
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