service: Introduce network quote

This command enables sending a raw line to a specific network.
This commit is contained in:
delthas 2021-07-07 00:44:15 +02:00 committed by Simon Ser
parent f4562a7534
commit 896caebfcf
2 changed files with 33 additions and 0 deletions

View file

@ -196,6 +196,9 @@ abbreviated form, for instance *network* can be abbreviated as *net* or just
*network delete* <name>
Disconnect and delete a network.
*network quote* <name> <command>
Send a raw IRC line as-is to a network.
*network status*
Show a list of saved networks and their current status.

View file

@ -222,6 +222,11 @@ func init() {
desc: "delete a network",
handle: handleServiceNetworkDelete,
},
"quote": {
usage: "<name> <command>",
desc: "send a raw line to a network",
handle: handleServiceNetworkQuote,
},
},
},
"certfp": {
@ -577,6 +582,31 @@ func handleServiceNetworkDelete(dc *downstreamConn, params []string) error {
return nil
}
func handleServiceNetworkQuote(dc *downstreamConn, params []string) error {
if len(params) != 2 {
return fmt.Errorf("expected exactly two arguments")
}
net := dc.user.getNetwork(params[0])
if net == nil {
return fmt.Errorf("unknown network %q", params[0])
}
uc := net.conn
if uc == nil {
return fmt.Errorf("network %q is not currently connected", params[0])
}
m, err := irc.ParseMessage(params[1])
if err != nil {
return fmt.Errorf("failed to parse command %q: %v", params[1], err)
}
uc.SendMessage(m)
sendServicePRIVMSG(dc, fmt.Sprintf("sent command to %q", net.GetName()))
return nil
}
func handleServiceCertfpGenerate(dc *downstreamConn, params []string) error {
fs := newFlagSet()
keyType := fs.String("key-type", "rsa", "key type to generate (rsa, ecdsa, ed25519)")