Hey dude, slight alteration to you code.

Code:
alias queryfilter { 
  $iif($group(#queryfilter) == off,.enable,.disable) #queryfilter
  $iif($group(#queryfilter) == off,amsg stopping query filter, amsg starting query filter)
}

#queryfilter off
on ^*:open:?:*: {
  if ($nick isop #channel name) || ($nick isvoice #channelname) { msg $nick sup7 $nick }  
  else { 
    msg $nick Do not pm me didnt you read the topic?  
  }
}
#queryfilter end


Just simple type:

/queryfilter

If it's turned on, it turns it off. If it's turned off, it turns on. You wont need to keep typing /queryfilter on and /queryfilter off.

-Andy