<commit_before>import {RTM_MESSAGE_SUBTYPES} from '@slack/client';
import {isNil, isNull} from 'lodash';
import {slack, orders} from './resources';
import {prettyPrint, stripMention} from './utils';
import config from '../config';

// #obedbot-testing id - 'G1TT0TBAA'
//const channelId = 'G1TT0TBAA';
const channelId = config.slack.channelId;
const botUserId = config.slack.botId;
const atObedbot = new RegExp("<@" + botUserId + ">");
const reactions = ['jedlopodnos', 'corn', 'spaghetti', 'shopping_bags'];

/*
 * orders are of form {ts: 'string with timestamp, order: 'string with order'}
 */
let veglife = orders.veglife;
let jpn = orders.jedloPodNos;
let spaghetti = orders.spaghetti;
let nakup = orders.nakup;

// ts = timestamp
let lastCall = { ts: null, timeLeft: null };
const lastCallLength = config.lastCall.length;
const lastCallStep = config.lastCall.step;

const rtm = slack.rtm;
const web = slack.web;


/**
 * Checks the incoming order and assigns it to the correct restaurant
 *
 * @param {string} order - order message
 * @param {string} ts - timestamp of the order message
 * @returns {bool} - true if order matches, false if not identified
 */
export function processOrder(order, ts) {
  order = order.toLowerCase().trim();
  console.log('Processing order:', order);

  if (order.match(/^veg[1-4]\+?[ps]?/)) {
    console.log('Veglife', order);
    veglife.push({ts: ts, text: order});
  } else if (order.match(/^[1-8]\+[pk]/)) {
    console.log('Jedlo pod nos');
    jpn.push({ts: ts, text: order});
  } else if (order.match(/^[a-z]((300)|(400)|(450)|(600)|(800))([psc]{1,2})?\+?[pt]?/)) {
    console.log('Spaghetti');
    spaghetti.push({ts: ts, text: order});
  } else if (order.match(/^nakup/)) {
    console.log('Nakup', order.substring(6));
    nakup.push({ts: ts, text: order.substring(6)});
  } else {
    console.log('ziadna restika, plany poplach');
    return false;
  }

  return true;
}

/**
 * Updates the order with the given ts to newOrder
 *
 * @param {string} newOrder - new order message<commit_msg>Add missing option in jedlopodnos regexp<commit_after>import {RTM_MESSAGE_SUBTYPES} from '@slack/client';
import {isNil, isNull} from 'lodash';
import {slack, orders} from './resources';
import {prettyPrint, stripMention} from './utils';
import config from '../config';

// #obedbot-testing id - 'G1TT0TBAA'
//const channelId = 'G1TT0TBAA';
const channelId = config.slack.channelId;
const botUserId = config.slack.botId;
const atObedbot = new RegExp("<@" + botUserId + ">");
const reactions = ['jedlopodnos', 'corn', 'spaghetti', 'shopping_bags'];

/*
 * orders are of form {ts: 'string with timestamp, order: 'string with order'}
 */
let veglife = orders.veglife;
let jpn = orders.jedloPodNos;
let spaghetti = orders.spaghetti;
let nakup = orders.nakup;

// ts = timestamp
let lastCall = { ts: null, timeLeft: null };
const lastCallLength = config.lastCall.length;
const lastCallStep = config.lastCall.step;

const rtm = slack.rtm;
const web = slack.web;


/**
 * Checks the incoming order and assigns it to the correct restaurant
 *
 * @param {string} order - order message
 * @param {string} ts - timestamp of the order message
 * @returns {bool} - true if order matches, false if not identified
 */
export function processOrder(order, ts) {
  order = order.toLowerCase().trim();
  console.log('Processing order:', order);

  if (order.match(/^veg[1-4]\+?[ps]?/)) {
    console.log('Veglife', order);
    veglife.push({ts: ts, text: order});
  } else if (order.match(/^[1-8]\+[psk]/)) {
    console.log('Jedlo pod nos');
    jpn.push({ts: ts, text: order});
  } else if (order.match(/^[a-z]((300)|(400)|(450)|(600)|(800))([psc]{1,2})?\+?[pt]?/)) {
    console.log('Spaghetti');
    spaghetti.push({ts: ts, text: order});
  } else if (order.match(/^nakup/)) {
    console.log('Nakup', order.substring(6));
    nakup.push({ts: ts, text: order.substring(6)});
  } else {
    console.log('ziadna restika, plany poplach');
    return false;
  }

  return true;
}

/**
 * Updates the order with the given ts to newOrder
 *
 * @param {string} newOrder - new order message
{'fraction_non_alphanumeric': 0.17437895762299074, 'fraction_numerical': 0.013151485630784217, 'mean_word_length': 4.172544080604534, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '5849288', 'n_tokens_mistral': 1490, 'n_tokens_neox': 1436, 'n_words': 388}