service: Introduce network quote
This command enables sending a raw line to a specific network.
This commit is contained in:
parent
f4562a7534
commit
896caebfcf
@ -196,6 +196,9 @@ abbreviated form, for instance *network* can be abbreviated as *net* or just
|
|||||||
*network delete* <name>
|
*network delete* <name>
|
||||||
Disconnect and delete a network.
|
Disconnect and delete a network.
|
||||||
|
|
||||||
|
*network quote* <name> <command>
|
||||||
|
Send a raw IRC line as-is to a network.
|
||||||
|
|
||||||
*network status*
|
*network status*
|
||||||
Show a list of saved networks and their current status.
|
Show a list of saved networks and their current status.
|
||||||
|
|
||||||
|
30
service.go
30
service.go
@ -222,6 +222,11 @@ func init() {
|
|||||||
desc: "delete a network",
|
desc: "delete a network",
|
||||||
handle: handleServiceNetworkDelete,
|
handle: handleServiceNetworkDelete,
|
||||||
},
|
},
|
||||||
|
"quote": {
|
||||||
|
usage: "<name> <command>",
|
||||||
|
desc: "send a raw line to a network",
|
||||||
|
handle: handleServiceNetworkQuote,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"certfp": {
|
"certfp": {
|
||||||
@ -577,6 +582,31 @@ func handleServiceNetworkDelete(dc *downstreamConn, params []string) error {
|
|||||||
return nil
|
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 {
|
func handleServiceCertfpGenerate(dc *downstreamConn, params []string) error {
|
||||||
fs := newFlagSet()
|
fs := newFlagSet()
|
||||||
keyType := fs.String("key-type", "rsa", "key type to generate (rsa, ecdsa, ed25519)")
|
keyType := fs.String("key-type", "rsa", "key type to generate (rsa, ecdsa, ed25519)")
|
||||||
|
Loading…
Reference in New Issue
Block a user