示例#1
0
文件: prowl.js 项目: Hitlust/zenbot
 pushMessage: function(title, message) {
   var p = new Prowl(config.key)
   p.push(message, title, function(err) {
     if (err) {
       console.log('error: Push message failed, ' + err)
       return
     }
   })
 }
示例#2
0
 checkEvent.findCheck(function(err, check) {
   var message = "[" + check.name + '] ';
   message += !check.isUp ? 'went down.' : ('went back up after ' + Math.floor(checkEvent.downtime / 1000) + 's of downtime.');
   
   prowl.push(message, 'Uptime notification', function( err, remaining ){
       if( err ) throw err;
       console.log( 'I have ' + remaining + ' calls to the api during current hour.' );
   });
   
 });
示例#3
0
	this.on("input",function(msg) {
		var titl = this.title||msg.topic||"Node-RED";
		var pri = msg.priority||this.priority;
		if (typeof(msg.payload) == 'object') {
			msg.payload = JSON.stringify(msg.payload);
		}
		try {
			prowl.push(msg.payload, titl, { priority: pri }, function( err, remaining ){
				if ( err ) node.error(err);
				node.log( remaining + ' calls to Prowl api during current hour.' );
			});
		}
		catch (err) {
			node.error(err);
		}
	});
示例#4
0
	var sendPushNotification = function(data){
		console.log("Sending notification to Prowl");

		var isJPG = function() { return filename.split('.').pop() === "jpg" ? true : false };	
		var priority = isJPG ? -2 : 2;		
	
		prowl.push('Movement has been detected and the file sent to S3!', 'PiCam Home', {
		    priority: priority,
		    url: data.Location
		}, function( err, remaining ){
		    if( err ) {
		    	console.log(err);
		    	fs.appendFile('/tmp/motion_msgs.log', '\n Prowl notification sent! \n', function (err) {
				console.log(err);
			});
		    	throw err;
		    }
		    console.log( 'I have ' + remaining + ' calls to the api during current hour. BOOM!' );
		});
		
		fs.appendFile('/tmp/motion_msgs.log', '\n Sending notification to Prowl \n', function (err) {
			console.log(err);
		});
	}