Beispiel #1
0
//Force reconnect if needed
function forceReconnect()
{
  console.log("Detected delay longer than 45s, reconnecting...");
  timeLastMessageReceived = -1;
  incoming.disconnect();
  sleep(3000);
  incoming.connect();
}
Beispiel #2
0
incoming.on('disconnected', function() {
    console.log("[IncomingStream 'disconnect']");
    if (retryCount > 3) {
        retryCount = retryCount - 1;
        incoming.connect();
    }
})
Beispiel #3
0
incoming.on('error', function() {
    var args = Array.prototype.slice.call(arguments);
    console.log("[IncomingStream 'error']", args);l
    if (retryCount > 3) {
        retryCount = retryCount - 1;
        incoming.connect();
    }
})
Beispiel #4
0
            cmd += txt[i];
            backslash = false;
        }
    }

    cmd = $.trim( cmd );
    if ( cmd !== '' ) {
        split_text.push( cmd );
    }

    return split_text;
};

// IncomingStream constructor

var incoming = new GroupMe.IncomingStream(ACCESS_TOKEN, USER_ID, null);

// Log IncomingStream status to terminal
incoming.on('status', function() {
    var args = Array.prototype.slice.call(arguments);
    var str = args.shift();
    console.log("[IncomingStream 'status']", str, args);
});


function socketWatch()
{
  var currentTime = new Date().getTime();
  if(timeLastMessageReceived != -1 && timeLastMessageReceived <= (currentTime - 45000))
    forceReconnect();
}
Beispiel #5
0
// var attach_array = []
// API.Messages.index(access_token, '12914593', {}, function(err, ret){
// 	if (!err) {
// 		var current_messages = ret.messages
// 		for (var i = current_messages.length - 1; i >= 0; i--) {
// 			if (current_messages[i].attachments.length > 0){
// 				console.log(current_messages[i].attachments[0].url)
// 			}
// 			// console.log(current_messages[i].attachments.length)
// 		};
// 	}
// })


// API.Bots.create(access_token,"ass", '12914593', {}, function(err, ret){
// 	console.log(ret)
// })


var IncomingStream = require('groupme').IncomingStream;

var iStream = new IncomingStream(access_token,'6569568',[12914593])
iStream.connect()
console.log(iStream)
iStream.on('message', function(err,res){
	console.log(res)
	console.log(err)
})


Beispiel #6
0
    var FROM_GROUP = process.argv[5];
    var TO_GROUP = process.argv[6];
    var DATABASE_URL = process.argv[7];



    /************************************************************************
     * Set up the message-based IncomingStream and the HTTP push
     ***********************************************************************/

    var group_id = null;

    var retryCount = 3;

    // Constructs the IncomingStream, identified by the access token and 
    var incoming = new GroupMe.IncomingStream(ACCESS_TOKEN, USER_ID, null);

    /*
    // This logs the status of the IncomingStream
    incoming.on('status', function() {
        var args = Array.prototype.slice.call(arguments);
        var str = args.shift();
        console.log("[IncomingStream 'status']", str, args);
    });
    */
    

    // This waits for the IncomingStream to complete its handshake and start listening.
    incoming.on('connected', function() {
        console.log("[IncomingStream 'connected']");
        console.log("[API.Bots.index return] Firing up bot!", BOT_ID);