but you probably meant how to detect trojan infected clients?! Just grab a trojan port list, maybe you find also also some common trojan login sequenzes, so you can verify its a trojan and not just an open port. for the basics you can take an proxy scanner script and modify it.
Hmm, just trying to make a antiproxy/antipjen bot for a mates, just wondered if its something to do with the host, what the client does when it joins the channel, like message these $decode things etc.