So [matrix] seems to fit the bill: federated network, bridges to other services (like IRC), encryption, you can write your own client or run your own server...
Also hubzilla (nee red/matrix, unlrelated to matrix; descending from friendica which DID federate with Facebook and Twitter for a while, until FB & T closed off the federation API bridges)