<commit_before>var config = require('../configurations');
var ms = require('ms');

function PizzaTimer(mqttClient) {
    this.mqttClient = mqttClient;
}

PizzaTimer.prototype.setup = function(irc) {
    this.irc = irc;
    this.irc.onCommand('pizza', this.onCommand.bind(this));
};

PizzaTimer.prototype.onCommand = function(channel, nickname, command, message, isQuery) {

    if(isQuery) {
        return false;
    }

    var that = this;
    var minutes = parseInt(message, 10) || 15;
    var timeoutMs = ms(minutes + 'm');

    that.irc.answer(channel, nickname, "I won't forget it!");

    setTimeout(function() {
        that.mqttClient.publish(config.mqtt.topics.pizza, '' + minutes);
        that.irc.answer(channel, nickname, "Time is up!");
    }, timeoutMs);
};

module.exports = PizzaTimer;<commit_msg>Answer denied request for pizza timer by query<commit_after>var config = require('../configurations');
var ms = require('ms');

function PizzaTimer(mqttClient) {
    this.mqttClient = mqttClient;
}

PizzaTimer.prototype.setup = function(irc) {
    this.irc = irc;
    this.irc.onCommand('pizza', this.onCommand.bind(this));
};

PizzaTimer.prototype.onCommand = function(channel, nickname, command, message, isQuery) {

    if(isQuery) {
        return this.irc.answer(channel, nickname, 'You can\'t set a timer by query');
    }

    var that = this;
    var minutes = parseInt(message, 10) || 15;
    var timeoutMs = ms(minutes + 'm');

    that.irc.answer(channel, nickname, "I won't forget it!");

    setTimeout(function() {
        that.mqttClient.publish(config.mqtt.topics.pizza, '' + minutes);
        that.irc.answer(channel, nickname, "Time is up!");
    }, timeoutMs);
};

module.exports = PizzaTimer;
{'fraction_non_alphanumeric': 0.15055008685581933, 'fraction_numerical': 0.004632310364794441, 'mean_word_length': 3.6576819407008085, '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': '5254127', 'n_tokens_mistral': 586, 'n_tokens_neox': 545, 'n_words': 122}