To expand:

Q: Well i want to when some one is querying me to do an automated whois,
A:
  1. On your menubar, select
    File
    Options (Alt -O)
  2. When the Options dialog opens up in treeview, click on
    IRC (which is underneath Connect and all of its options)
  3. You will see 2 columns of checkboxes. Make sure the 7th checkbox in the first column on the left is checked:
    [X] Whois on query


Q: This only works in channels not in query's.
A: You can use any of the following characters to designate what kind of window you want to capture the input for: *#?=!@

on *:INPUT:#: is for channels only
on *:INPUT:?: is for queries only
on *:INPUT:=: is for DCC Chat
on *:INPUT:!: is for fserve
on *:INPUT:@: is for custom windows
on *:INPUT:*: is for all windows

So, you either want to put the actual code of the on INPUT inside and alias you call from both on *:INPUT:#: and on *:INPUT:?: or perhaps use simply on *:INPUT:*: (all windows) and just use the code itself inside the event since you don't need it elsewhere.