I need a script to do something that's too hard

.
(22:24:02) (.Niss) !pi
(22:24:03) (.NEWMAPSBOT) Id Name Score Side Ping Address Kbits/s Time RG
(22:24:03) (.NEWMAPSBOT) 1 ryg5hnvdh 221 GDI 194 81.68.145.X 117 000.08.27 x
In short when i do a !pi (Player Info) the bot will show a list of people who are ingame playing and some info, including IP.
I have a Banlist of IP's (list is over 100 people, and servers are almost always full with 40 players) and checking every single IP is too much work, specially with people leaving/joining every time.
Now i need a script to check the IP (6th word bot will say) and if it matches ban on sight list ban the second word bot say's (Players name).
I got to this:
}
on *:TEXT:#: {
if ( $6 == IP ) {
msg # !kb $2 BOS
}
}
It doesn't work am i doing something wrong

.
EDIT: Btw if this IS correct tell me so i will get someone else to try it since my IRC is scripted and very weird

.