<commit_before>#!/usr/bin/env bash
#
# Wechaty - Connect ChatBots
#
# https://github.com/Chatie/wechaty
#
set -e

export HOME=/bot
export PATH=$PATH:/wechaty/bin:/wechaty/node_modules/.bin

function wechaty::banner() {
  echo
  figlet " Wechaty "
  echo ____________________________________________________
  echo "            https://www.chatie.io"
}

function wechaty::errorBotNotFound() {
  local file=$1
  echo "Container ERROR: can not found bot file: $HOME/$file"

  echo "Container PWD: $(pwd)"
  echo "Container HOME: $HOME"
  echo "Container LS $HOME: $(ls -l $HOME)"

  figlet " Troubleshooting "
  cat <<'TROUBLESHOOTING'

    Troubleshooting:

    1. Did you bind the current directory into container?

      check your `docker run ...` command, if there's no `volumn` arg,
      then you need to add it so that we can bind the volume of /bot:

        `--volume="$(pwd)":/bot`

      this will let the container visit your current directory.

    2. Are you sure your .js/.ts files aren't .js.txt/.ts.txt?

      this could be a problem on new Windows installs (file
      extensions hidden by default).

    if you still have issue, please have a look at
      https://github.com/chatie/wechaty/issues/66
      and do a search in issues, that might be help.

TROUBLESHOOTING
}

function wechaty::printEnv () {
  num=$(env | grep -c WECHATY)
  echo "$num WECHATY Environment Variables:"
  env | grep WECHATY
}

function wechaty::errorCtrlC () {
  # http://www.tldp.org/LDP/abs/html/exitcodes.html
  # 130 Script terminated by Control-C  Ctl-C Control-C is fatal error signal 2, (130 = 128 + 2, see above)
  echo ' Script terminated by Control-C '
  figlet ' Ctrl + C '
}

function wechaty::pressEnterToContinue() {
  local -i timeoutSecond=${1:-30}
  local message=${2:-'Press ENTER to continue ... '}

  read -r -t "$timeoutSecond"  -p "$message" || true
  echo
}

function wechaty::diagnose() {
  local -i ret=$1  && shift
  local file=$1 && shift

: echo " exit code $ret "
  figlet ' BUG REPORT '<commit_msg>add /bot/node_modules/ to NODE_PATH (#1478)<commit_after>#!/usr/bin/env bash
#
# Wechaty - Connect ChatBots
#
# https://github.com/Chatie/wechaty
#
set -e

export HOME=/bot
export PATH=$PATH:/wechaty/bin:/wechaty/node_modules/.bin
export NODE_PATH=/wechaty/node_modules:/bot/node_modules

function wechaty::banner() {
  echo
  figlet " Wechaty "
  echo ____________________________________________________
  echo "            https://www.chatie.io"
}

function wechaty::errorBotNotFound() {
  local file=$1
  echo "Container ERROR: can not found bot file: $HOME/$file"

  echo "Container PWD: $(pwd)"
  echo "Container HOME: $HOME"
  echo "Container LS $HOME: $(ls -l $HOME)"

  figlet " Troubleshooting "
  cat <<'TROUBLESHOOTING'

    Troubleshooting:

    1. Did you bind the current directory into container?

      check your `docker run ...` command, if there's no `volumn` arg,
      then you need to add it so that we can bind the volume of /bot:

        `--volume="$(pwd)":/bot`

      this will let the container visit your current directory.

    2. Are you sure your .js/.ts files aren't .js.txt/.ts.txt?

      this could be a problem on new Windows installs (file
      extensions hidden by default).

    if you still have issue, please have a look at
      https://github.com/chatie/wechaty/issues/66
      and do a search in issues, that might be help.

TROUBLESHOOTING
}

function wechaty::printEnv () {
  num=$(env | grep -c WECHATY)
  echo "WECHATY Environment Variables: $num"
  env | grep WECHATY
}

function wechaty::errorCtrlC () {
  # http://www.tldp.org/LDP/abs/html/exitcodes.html
  # 130 Script terminated by Control-C  Ctl-C Control-C is fatal error signal 2, (130 = 128 + 2, see above)
  echo ' Script terminated by Control-C '
  figlet ' Ctrl + C '
}

function wechaty::pressEnterToContinue() {
  local -i timeoutSecond=${1:-30}
  local message=${2:-'Press ENTER to continue ... '}

  read -r -t "$timeoutSecond"  -p "$message" || true
  echo
}

function wechaty::diagnose() {
  local -i ret=$1  && shift
  local file=$1 && shift

: echo " exit code $ret "
  figlet ' BUG REPORT '
{'fraction_non_alphanumeric': 0.1218274111675127, 'fraction_numerical': 0.011602610587382161, 'mean_word_length': 3.17979797979798, 'pattern_counts': {'":': 2, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 6, 'lorem ipsum': 0, 'www.': 4, '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': '461108', 'n_tokens_mistral': 1455, 'n_tokens_neox': 1356, 'n_words': 442}