You want "on *:INPUT:*:", not #,? -- if you debug your script you'll see it's not even triggering in queries.