<commit_before>import {ADD_CHAT} from '../actions/actionTypes';
import {changeUserAction} from '../actions/userActions';
import {moveAction, voteAction} from '../actions/gameActions';
import {direction2Server, vote2Server, newPlayer2Server} from './socket_io';
import store, {getGameState} from '../store';
import {botSup, botStats, botNotFound, botAdvise} from './chatBot';

export default (action, next) => {
  if (action.type === ADD_CHAT && action.payload.text[0] === '\\') {
    const verb = action
      .payload
      .text
      .match(/\\\S+/gi)[0]
      .slice(1);
    //FIXME: make parsing target less brittle
    const target = action
      .payload
      .text
      .split(' ')[1]

    // If there is a current turn, get choice values from store
    const choices = getGameState().turn 
      ? getGameState().turn.votes
        .map(vote => vote.name)
      : [];
      
    // POSSIBLE USER ACTIONS FROM COMMAND LINE
    if (verb === 'name') {
      store.dispatch(changeUserAction(target));
      newPlayer2Server(target);
      return botSup(target);
    }
    if (['up', 'down', 'left', 'right'].indexOf(verb) > -1) {
      direction2Server(verb);
      return next(action);
    }
    if (verb === 'stats') {
      return botStats();
    }
    if (verb === 'help') {
      return botAdvise();
    }
    return botNotFound(verb);
  }
  return next(action);
}<commit_msg>fix (middleware): remove fixme flag on parser<commit_after>import {ADD_CHAT} from '../actions/actionTypes';
import {changeUserAction} from '../actions/userActions';
import {moveAction, voteAction} from '../actions/gameActions';
import {direction2Server, vote2Server, newPlayer2Server} from './socket_io';
import store, {getGameState} from '../store';
import {botSup, botStats, botNotFound, botAdvise} from './chatBot';

export default (action, next) => {
  if (action.type === ADD_CHAT && action.payload.text[0] === '\\') {
    const verb = action
      .payload
      .text
      .match(/\\\S+/gi)[0]
      .slice(1);
    const target = action
      .payload
      .text
      .split(' ')[1]

    // If there is a current turn, get choice values from store
    const choices = getGameState().turn 
      ? getGameState().turn.votes
        .map(vote => vote.name)
      : [];
      
    // POSSIBLE USER ACTIONS FROM COMMAND LINE
    if (verb === 'name') {
      store.dispatch(changeUserAction(target));
      newPlayer2Server(target);
      return botSup(target);
    }
    if (['up', 'down', 'left', 'right'].indexOf(verb) > -1) {
      direction2Server(verb);
      return next(action);
    }
    if (verb === 'stats') {
      return botStats();
    }
    if (verb === 'help') {
      return botAdvise();
    }
    return botNotFound(verb);
  }
  return next(action);
}
{'fraction_non_alphanumeric': 0.16002896451846488, 'fraction_numerical': 0.00724112961622013, 'mean_word_length': 2.7489823609226596, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '6329119', 'n_tokens_mistral': 862, 'n_tokens_neox': 841, 'n_words': 224}