Several lua documentations can be found online. Documentation for most important custom functions of Toribash can be found in the data/script/sdk folder.
What you are looking for is the "add_hook" functions and the "console" hook. These let you register a function that is called everytime something is written to the console. E.g:
local function echoStuff(code, msg)
echo(code)
echo(msg)
end
add_hook("console", "", echoStuff)
This will call echoStuff everytime before a message is displayed in the console and simply print it's code (which can be used to identify the type of message (normal chat message, whisper, etc)) and the message itself. This will still print the original message, so it will appear twice. If you want to prevent that, simply add "return 1" before "end"
I could be wrong about the order of arguments, better test that yourself.
There are lots of different hooks. You can find a list in data/script/startup.lua. You wont need any appart from "console" for this project though.
Another function you will need is "run_cmd". It lets you execute (almost) any console command you can enter yourself. So run_cmd("ls foo.lua") will load the foo.lua script. I think that can be used to chat via the "/say" command, e.g.: run_cmd("say Hello World!"). I'm not 100% sure if this will work though. It could be that "/say" is one of the commands you can't execute with run_cmd.
I don't think you can find out how many TC a player has via lua.