Here's a quick stab at $comnet. I tested it briefly but again I'd suggest trying it out a bit more thoroughly before relying on it.

Code:
alias comnet {
  ; Usage: $comnet(nick, N) returns the connection ID of the Nth connection you share with nick
  ; Usage: $comnet(nick, N).network returns the network name of the Nth connection you share with nick
  var %networks
  scon -a $eval(%networks = %networks,0) $!iif($comchan( $1 , 0) ,$iif($prop == network,$network,$cid) ,$null )
  return $iif($int($2) == 0, $numtok(%networks, 32), $gettok(%networks, $v1, 32))
}


Important to note you should use the .network property if you just want the network name.


Spelling mistakes, grammatical errors, and stupid comments are intentional.