<commit_before>/**
 *
 *      ioBroker pushover Adapter
 *
 *      (c) 2014 bluefox
 *
 *      MIT License
 *
 */

var po_notif = require('pushover-notifications');

var adapter = require(__dirname + '/../../lib/adapter.js')({

    name: 'pushover',

    objectChange: function (id, obj) {

    },

    stateChange: function (id, state) {
        
    },

    unload: function (callback) {
        try {
            adapter.log.info('terminating');
            callback();
        } catch (e) {
            callback();
        }
    },

    ready: function () {
        main();
    },
    
    // New message arrived. obj is array with current messages
    message: function (obj) {
        if (obj && obj.command == "send") processMessage(obj.message);
        processMessages();
        return true;
    }

});

var stopTimer = null;
var pushover;

// Terminate adapter after 30 seconds idle
function stop() {
    if (stopTimer) {
        clearTimeout(stopTimer);
    }

    // Stop only if subscribe mode
    if (adapter.common && adapter.common.mode == 'subscribe') {
        stopTimer = setTimeout(function () {
            stopTimer = null;
            adapter.stop();
        }, 30000);
    }
}

function processMessage(message) {
    if (stopTimer) {
        clearTimeout(stopTimer);
    }

    sendNotification(message);

    stop();
}<commit_msg>(bluefox) change adapter to emitEvent architecture<commit_after>/**
 *
 *      ioBroker pushover Adapter
 *
 *      (c) 2014 bluefox
 *
 *      MIT License
 *
 */

var po_notif = require('pushover-notifications');

var adapter = require(__dirname + '/../../lib/adapter.js')('pushover');

adapter.on('message', function (obj) {
    if (obj && obj.command == "send") processMessage(obj.message);
    processMessages();
});

adapter.on('ready', function () {
    main();
});

var stopTimer = null;
var pushover;

// Terminate adapter after 30 seconds idle
function stop() {
    if (stopTimer) {
        clearTimeout(stopTimer);
    }

    // Stop only if subscribe mode
    if (adapter.common && adapter.common.mode == 'subscribe') {
        stopTimer = setTimeout(function () {
            stopTimer = null;
            adapter.stop();
        }, 30000);
    }
}

function processMessage(message) {
    if (stopTimer) {
        clearTimeout(stopTimer);
    }

    sendNotification(message);

    stop();
}
{'fraction_non_alphanumeric': 0.14158541754980924, 'fraction_numerical': 0.009325985587113183, 'mean_word_length': 2.2506887052341598, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1241961', 'n_tokens_mistral': 714, 'n_tokens_neox': 681, 'n_words': 167}