<commit_before># Description:
#   Example scripts for you to examine and try out.
#
# Notes:
#   They are commented out by default, because most of them are pretty silly and
#   wouldn't be useful and amusing enough for day to day huboting.
#   Uncomment the ones you want to try and experiment with.
#
#   These are from the scripting documentation: https://github.com/github/hubot/blob/master/docs/scripting.md

module.exports = (robot) ->

  # 現在のレコード数
  length = robot.brain.get('records.length') >> 0

  robot.hear /(\d+).*(add|\ふえた)/i, (res) ->
    # e.g. res.match[1] === '1234'
    amount = parseInt res.match[1]
    robot.brain.set "records.#{length}", "#{amount}\tadd"
    robot.brain.set "records.length", ++length
    res.send "すごーい！お金がふえたよ +#{amount}円"

  robot.hear /(\d+).*(sub|\へった)/i, (res) ->
    # e.g. res.match[1] === '1234'
    amount = parseInt res.match[1]
    robot.brain.set "records.#{length}", "#{amount}\tsub"
    robot.brain.set "records.length", ++length
    res.send "ざんねん！お金がへったよ -#{amount}円"

  robot.hear /back|\もどす/, (res) ->
    if length > 0
      robot.brain.set "records.length", --length
      res.send "もどしたよ！" + robot.brain.get "records.#{length}"
    else
      res.send "えっ？"

  robot.hear /history|\りれき/i, (res) ->
    records = [0..length - 1].map (i) -> robot.brain.get "records.#{i}"
    res.send "けんすう: #{length}件\n" + records.join('\n')

  robot.hear /how much|\いくら/i, (res) ->
    if length > 0
      records = [0..length - 1].map (i) -> robot.brain.get "records.#{i}"
      money = 0
      for record in records
        # e.g. record === '1234 add'
        matches = /(\d+)\s(add|sub)/i.exec record<commit_msg>cannot show history if record is empty<commit_after># Description:
#   Example scripts for you to examine and try out.
#
# Notes:
#   They are commented out by default, because most of them are pretty silly and
#   wouldn't be useful and amusing enough for day to day huboting.
#   Uncomment the ones you want to try and experiment with.
#
#   These are from the scripting documentation: https://github.com/github/hubot/blob/master/docs/scripting.md

module.exports = (robot) ->

  # 現在のレコード数
  length = robot.brain.get('records.length') >> 0

  robot.hear /(\d+).*(add|\ふえた)/i, (res) ->
    # e.g. res.match[1] === '1234'
    amount = parseInt res.match[1]
    robot.brain.set "records.#{length}", "#{amount}\tadd"
    robot.brain.set "records.length", ++length
    res.send "すごーい！お金がふえたよ +#{amount}円"

  robot.hear /(\d+).*(sub|\へった)/i, (res) ->
    # e.g. res.match[1] === '1234'
    amount = parseInt res.match[1]
    robot.brain.set "records.#{length}", "#{amount}\tsub"
    robot.brain.set "records.length", ++length
    res.send "ざんねん！お金がへったよ -#{amount}円"

  robot.hear /back|\もどす/, (res) ->
    if length > 0
      robot.brain.set "records.length", --length
      res.send "もどしたよ！" + robot.brain.get "records.#{length}"
    else
      res.send "えっ？"

  robot.hear /history|\りれき/i, (res) ->
    if length > 0
      records = [0..length - 1].map (i) -> robot.brain.get "records.#{i}"
      res.send "けんすう: #{length}件\n" + records.join('\n')
    else
      res.send "は？"

  robot.hear /how much|\いくら/i, (res) ->
    if length > 0
      records = [0..length - 1].map (i) -> robot.brain.get "records.#{i}"
      money = 0
      for record in records
        # e.g. record === '1234 add'
        matches = /(\d+)\s(add|sub)/i.exec record
{'fraction_non_alphanumeric': 0.18195179306290418, 'fraction_numerical': 0.01440329218106996, 'mean_word_length': 2.727272727272727, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 28, 'https://': 2, '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': '2721913', 'n_tokens_mistral': 1333, 'n_tokens_neox': 1302, 'n_words': 313}