You're missing a closing bracket at the end, and on TEXT will never trigger for your own messages. Try this:

Code:
on *:input:#:{
  if (*ty* iswm $1-) { set %ty 1 }
}
on *:text:*ty*:#:{ inc %ty }