You can use /scon -at1 which means: Send the command to all server windows which are connected.
alias myAlias {
scon -at1 if ($me ison #chan1) && (BOT ison #chan1) { do this }
}
However I recommend to use "Network name" and just check that in the that condition then use an alias and call its name in here instead of writing the code...
alias myAlias {
scon -at1 $iif($network == MyNetwork,CallSomeAlias)
}
Btw, like the what '5618' just told you can make a loop through the $scon() and make that network active then execute your command.