<commit_before># Description:
#   くじ引きを行うbot
# Author:
#   raoka0000

module.exports = (robot) ->
  robot.respond /(lottery|lot|くじ|randam|ランダム|抽選|) (.+)/i, (msg) ->
    room = msg.envelope.room
    channel = robot.adapter.client.rtm.dataStore.getChannelGroupOrDMById(room)
    if channel.getType() is "dm"
      msg.send "DMではできないクエ"
      return
    option = msg.match[2]
    if option == ""
      loop #do-whileの代わり
        target = msg.random channel.members
        break if target != robot.adapter.self.id
      target_name = robot.adapter.client.rtm.dataStore.getUserById(target).real_name
      msg.send "当選者は#{target_name}だクエ"
    else if option == "-list"
      shuffle channel.members
      n = 0
      names = []
      for target in channel.members
        continue if target is robot.adapter.self.id
        name = robot.adapter.client.rtm.dataStore.getUserById(target).real_name
        names.push "#{++n}: #{name}"
      msg.send "#{names.join("\n")}"


#配列をシャッフル
shuffle = (array) ->
  i = array.length
  if i is 0 then return false
  while --i
    j = Math.floor Math.random() * (i + 1)
    tmpi = array[i]
    tmpj = array[j]
    array[i] = tmpj
    array[j] = tmpi
  return
<commit_msg>バグの修正<commit_after># Description:
#   くじ引きを行うbot
# Author:
#   raoka0000

module.exports = (robot) ->
  robot.respond /(lottery|lot|くじ|randam|ランダム|抽選)(.*)/i, (msg) ->
    option = msg.match[2].trim()
    room = msg.envelope.room
    channel = robot.adapter.client.rtm.dataStore.getChannelGroupOrDMById(room)
    if channel.getType() is "dm"
      msg.send "DMではできないクエ"
      return
    if option == ""
      loop #do-whileの代わり
        target = msg.random channel.members
        break if target != robot.adapter.self.id
      target_name = robot.adapter.client.rtm.dataStore.getUserById(target).real_name
      msg.send "当選者は#{target_name}だクエ"
    else if option == "-list"
      shuffle channel.members
      n = 0
      names = []
      for target in channel.members
        continue if target is robot.adapter.self.id
        name = robot.adapter.client.rtm.dataStore.getUserById(target).real_name
        names.push "#{++n}: #{name}"
      msg.send "#{names.join("\n")}"


#配列をシャッフル
shuffle = (array) ->
  i = array.length
  if i is 0 then return false
  while --i
    j = Math.floor Math.random() * (i + 1)
    tmpi = array[i]
    tmpj = array[j]
    array[i] = tmpj
    array[j] = tmpi
  return

{'fraction_non_alphanumeric': 0.13804573804573805, 'fraction_numerical': 0.006652806652806653, 'mean_word_length': 2.596412556053812, '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': '5863749', 'n_tokens_mistral': 893, 'n_tokens_neox': 883, 'n_words': 183}