<commit_before>local handle = {}

local handlers =
{
  chat = function( msg, console ) handleChat( msg, console ) end,
  ping = function( msg, console ) handlePing( msg ) end
}

function handle.message( msg, msgType, console )
  print( "Handling message: " ) -- Debug
  print( msg ) -- Debug
  print( "of type: " ) -- Debug
  print( msgType ) -- Debug
  if handlers[msgType] then
    local send = handlers[msgType]( msg, console ) -- get the return value from the handler to know what to send
    print( send ) -- Debug
    if send then
      return send
    end
  elseif msgType == "unknown" then -- if the message type is unknown then do nothing
  else
    print( "ERROR: message type " .. msgType .. " for message <" .. msg .. "> does not have a handler." )
  end
end

function handleChat( msg, console )
  local username = string.sub( msg, string.find( msg, "[%w_]+" ) )
  local sStart, sEnd = string.find( msg, "[%w_]+![%w_]+@[%w_]+%.tmi%.twitch%.tv PRIVMSG #[%w_]+ :" )
  local chatMsg = string.sub( msg, sEnd + 1 )
  console:print( username .. ": " .. chatMsg )<commit_msg>Remove debug prints from handler<commit_after>local handle = {}

local handlers =
{
  chat = function( msg, console ) handleChat( msg, console ) end,
  ping = function( msg, console ) handlePing( msg ) end
}

function handle.message( msg, msgType, console )
  if handlers[msgType] then
    local send = handlers[msgType]( msg, console ) -- get the return value from the handler to know what to send
    if send then
      return send
    end
  elseif msgType == "unknown" then -- if the message type is unknown then do nothing
  else
    print( "ERROR: message type " .. msgType .. " for message <" .. msg .. "> does not have a handler." )
  end
end

function handleChat( msg, console )
  local username = string.sub( msg, string.find( msg, "[%w_]+" ) )
  local sStart, sEnd = string.find( msg, "[%w_]+![%w_]+@[%w_]+%.tmi%.twitch%.tv PRIVMSG #[%w_]+ :" )
  local chatMsg = string.sub( msg, sEnd + 1 )
  console:print( username .. ": " .. chatMsg )
{'fraction_non_alphanumeric': 0.14306857424765665, 'fraction_numerical': 0.000986679822397632, 'mean_word_length': 3.1387755102040815, 'pattern_counts': {'":': 2, '<': 5, '<?xml version=': 0, '>': 5, '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': '2909257', 'n_tokens_mistral': 653, 'n_tokens_neox': 644, 'n_words': 235}