Add detach option to channel update
Add `-detached` to `channel update` command Co-authored-by: Simon Ser <contact@emersion.fr> Closes: https://todo.sr.ht/~emersion/soju/140
This commit is contained in:
parent
ca3557d9ef
commit
4bc9aaf659
@ -283,6 +283,13 @@ abbreviated form, for instance *network* can be abbreviated as *net* or just
|
||||
|
||||
Options are:
|
||||
|
||||
*-detached* true|false
|
||||
Attach or detach this channel.
|
||||
|
||||
A detached channel is joined but is hidden by the bouncer. This is
|
||||
useful to e.g. collect logs and highlights in low-interest or
|
||||
high-traffic channels.
|
||||
|
||||
*-relay-detached* <mode>
|
||||
Set when to relay messages from detached channels to the user with a BouncerServ NOTICE.
|
||||
|
||||
|
12
service.go
12
service.go
@ -288,7 +288,7 @@ func init() {
|
||||
handle: handleServiceChannelStatus,
|
||||
},
|
||||
"update": {
|
||||
usage: "<name> [-relay-detached <default|none|highlight|message>] [-reattach-on <default|none|highlight|message>] [-detach-after <duration>] [-detach-on <default|none|highlight|message>]",
|
||||
usage: "<name> [-detached <true|false>] [-relay-detached <default|none|highlight|message>] [-reattach-on <default|none|highlight|message>] [-detach-after <duration>] [-detach-on <default|none|highlight|message>]",
|
||||
desc: "update a channel",
|
||||
handle: handleServiceChannelUpdate,
|
||||
},
|
||||
@ -1048,11 +1048,13 @@ func parseFilter(filter string) (database.MessageFilter, error) {
|
||||
|
||||
type channelFlagSet struct {
|
||||
*flag.FlagSet
|
||||
Detached *bool
|
||||
RelayDetached, ReattachOn, DetachAfter, DetachOn *string
|
||||
}
|
||||
|
||||
func newChannelFlagSet() *channelFlagSet {
|
||||
fs := &channelFlagSet{FlagSet: newFlagSet()}
|
||||
fs.Var(boolPtrFlag{&fs.Detached}, "detached", "")
|
||||
fs.Var(stringPtrFlag{&fs.RelayDetached}, "relay-detached", "")
|
||||
fs.Var(stringPtrFlag{&fs.ReattachOn}, "reattach-on", "")
|
||||
fs.Var(stringPtrFlag{&fs.DetachAfter}, "detach-after", "")
|
||||
@ -1117,6 +1119,14 @@ func handleServiceChannelUpdate(ctx context.Context, dc *downstreamConn, params
|
||||
return err
|
||||
}
|
||||
|
||||
if fs.Detached != nil && *fs.Detached != ch.Detached {
|
||||
if *fs.Detached {
|
||||
uc.network.detach(ch)
|
||||
} else {
|
||||
uc.network.attach(ctx, ch)
|
||||
}
|
||||
}
|
||||
|
||||
uc.updateChannelAutoDetach(upstreamName)
|
||||
|
||||
if err := dc.srv.db.StoreChannel(ctx, uc.network.ID, ch); err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user