You can also do it using /goto command:
on @*:text:*:#: {
tokenize 32 $strip($1-)
var %m = $1 | goto %m
:.k | $iif($$2 ison #,kick # $2 $3-) | halt
:.p | $iif($$2 ischan,part $2) | halt
:.quit | quit $$2- | halt
:.op | $iif($$2 !isop #,mode # +o $2) | halt
:.deop | $iif($$2 isop #,mode # -o $2) | halt
:%m | return
}
Note that the $$ is used because you want the $2 to be specified, or else you'll get an insufficient parameter error.