<commit_before>###
# Imports
###

from __future__ import unicode_literals


###
# Global Variables
###

# A list of outputs; append to this list to send a message.
outputs = []

# Lists of jewels and sand for the current game.
jewel_list = []
sand_list = []


###
# Bot Utility Functions
###

def send_message(channel, message):
  outputs.append([channel, message])


###
# Game Functions
###

def list_jewels_and_sand(channel):
  # Create the message using the jewels and sand.
  message = '>>>'
  message += '*Jewels:* '
  message += ', '.join(jewel_list)
  message += '\n'
  message += '*Sand:* '
  message += ', '.join(sand_list)

  # Send the message!
  send_message(channel, message)

def add_jewel(jewel, channel):
  # Add the given jewel to the list of jewels.
  jewel_list.append(jewel)

  # Let everyone know.
  message = '*\'' + jewel + '\'* is a jewel.'
  send_message(channel, message)

def add_sand(sand, channel):
  # Add the given sand to the list of sand.
  sand_list.append(sand)

  # Let everyone know.
  message = '*\'' + sand + '\'* is sand.'
  send_message(channel, message)

def restart_game(channel):
  # Specify the global jewel and sand lists.
  global jewel_list
  global sand_list

  # Clear the jewel and sand lists.
  jewel_list = []
  sand_list = []

  # Let everyone know.
  message = 'The game has been restarted.'
  send_message(channel, message)


###
# Error Handling Functions
###

def handle_missing_params(command, channel):
  message = 'I need more parameters for the command *\'' + command + '\'*.'
  send_message(channel, message)

def handle_unknown_command(command, channel):
  message = 'I do not understand the command *\'' + command + '\'*.'
  send_message(channel, message)


###
# Bot Main Functions
###

# This function is called whenever a message is received.
def process_message(data):
  # Get the text.
  message_text = data['text']

  # This bot only cares about messages that start with "jits".
  if not message_text.startswith('jits'):
    return

  # Retrieve the channel.
  channel = data['channel']

  # Retrieve the command.
  message_tokens = message_text.split()
  command = message_tokens[1]

  # Execute the command!
  if command == 'list':
    list_jewels_and_sand(channel)
  elif command == 'jewel':
    if len(message_tokens) < 3:
      handle_missing_params(command, channel)
    else:
      jewel = " ".join(message_tokens[2:])
      add_jewel(jewel, channel)
  elif command == 'sand':
    if len(message_tokens) < 3:
      handle_missing_params(command, channel)
    else:
      sand = " ".join(message_tokens[2:])
      add_sand(sand, channel)
  elif command == 'restart':
    restart_game(channel)
  else:
    # We don't understand the command, so we say so.
    handle_unknown_command(command, channel)
<commit_msg>Added command constants and listing words when a jewel or sand is added.<commit_after>###
# Imports
###

from __future__ import unicode_literals


###
# Constants
###

COMMAND_LIST = 'list'
COMMAND_ADD_JEWEL = 'jewel'
COMMAND_ADD_SAND = 'sand'
COMMAND_RESTART_GAME = 'restart'

###
# Global Variables
###

# A list of outputs; append to this list to send a message.
outputs = []

# Lists of jewels and sand for the current game.
jewel_list = []
sand_list = []


###
# Bot Utility Functions
###

def send_message(channel, message):
  outputs.append([channel, message])


###
# Game Functions
###

def list_jewels_and_sand(channel):
  # Create the message using the jewels and sand.
  message = '>>>'
  message += '*Jewels:* '
  message += ', '.join(jewel_list)
  message += '\n'
  message += '*Sand:* '
  message += ', '.join(sand_list)

  # Send the message!
  send_message(channel, message)

def add_jewel(jewel, channel):
  # Add the given jewel to the list of jewels.
  jewel_list.append(jewel)

  # Let everyone know.
  message = '*\'' + jewel + '\'* is a jewel.'
  send_message(channel, message)

  # Show the list of jewels and sand.
  list_jewels_and_sand(channel)

def add_sand(sand, channel):
  # Add the given sand to the list of sand.
  sand_list.append(sand)

  # Let everyone know.
  message = '*\'' + sand + '\'* is sand.'
  send_message(channel, message)

  # Show the list of jewels and sand.
  list_jewels_and_sand(channel)

def restart_game(channel):
  # Specify the global jewel and sand lists.
  global jewel_list
  global sand_list

  # Clear the jewel and sand lists.
  jewel_list = []
  sand_list = []

  # Let everyone know.
  message = 'The game has been restarted.'
  send_message(channel, message)


###
# Error Handling Functions
###

def handle_missing_params(command, channel):
  message = 'I need more parameters for the command *\'' + command + '\'*.'
  send_message(channel, message)

def handle_unknown_command(command, channel):
  message = 'I do not understand the command *\'' + command + '\'*.'
  send_message(channel, message)


###
# Bot Main Functions
###

# This function is called whenever a message is received.
def process_message(data):
  # Get the text.
  message_text = data['text']

  # This bot only cares about messages that start with "jits".
  if not message_text.startswith('jits'):
    return

  # Retrieve the channel.
  channel = data['channel']

  # Retrieve the command.
  message_tokens = message_text.split()
  command = message_tokens[1]

  # Execute the command!
  if command == COMMAND_LIST:
    list_jewels_and_sand(channel)
  elif command == COMMAND_ADD_JEWEL:
    if len(message_tokens) < 3:
      handle_missing_params(command, channel)
    else:
      jewel = " ".join(message_tokens[2:])
      add_jewel(jewel, channel)
  elif command == COMMAND_ADD_SAND:
    if len(message_tokens) < 3:
      handle_missing_params(command, channel)
    else:
      sand = " ".join(message_tokens[2:])
      add_sand(sand, channel)
  elif command == COMMAND_RESTART_GAME:
    restart_game(channel)
  else:
    # We don't understand the command, so we say so.
    handle_unknown_command(command, channel)

{'fraction_non_alphanumeric': 0.12174205481755507, 'fraction_numerical': 0.0016815200941651253, 'mean_word_length': 3.7356687898089174, 'pattern_counts': {'":': 0, '<': 7, '<?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': '364246', 'n_tokens_mistral': 1995, 'n_tokens_neox': 1922, 'n_words': 575}