diff --git a/doc/soju.1.scd b/doc/soju.1.scd index bf5267c..6838bbc 100644 --- a/doc/soju.1.scd +++ b/doc/soju.1.scd @@ -196,6 +196,9 @@ abbreviated form, for instance *network* can be abbreviated as *net* or just *network delete* Disconnect and delete a network. +*network quote* + Send a raw IRC line as-is to a network. + *network status* Show a list of saved networks and their current status. diff --git a/service.go b/service.go index e11285f..b95f551 100644 --- a/service.go +++ b/service.go @@ -222,6 +222,11 @@ func init() { desc: "delete a network", handle: handleServiceNetworkDelete, }, + "quote": { + usage: " ", + 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)")