Your first question, you want it for when you type a sentence or when a user types a sentence?
Your second question:
on *:TEXT:!names *:#channel:{
if ($numtok($2-,44)) {
var %idx = 0
while (%idx < $numtok($2-,44)) {
inc %idx
write file.txt $gettok($2-,%idx,44)
}
}
}
You'll have to edit the code:
#channel - replace with an actual channel name (eg, #blah)
file.txt - replace with a filename of your choice