~emersion/public-inbox

soju: service: Introduce network quote v1 SUPERSEDED

delthas: 1
 service: Introduce network quote

 1 files changed, 30 insertions(+), 0 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~emersion/public-inbox/patches/23637/mbox | git am -3
Learn more about email & git
View this thread in the archives

[PATCH soju] service: Introduce network quote Export this patch

This command enables sending a raw line to a specific network.
---
 service.go | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

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:  "<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)")
-- 
2.30.0
LGTM! Can we also add the new command to the man page?