- Timestamp:
- Dec 14, 2020, 7:54:02 PM (4 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/doc/soju.1.scd
r426 r436 171 171 Show a list of saved networks and their current status. 172 172 173 *channel update* <name> [options...] 174 Update the options of an existing channel. 175 176 Options are: 177 178 *-relay-detached* <mode> 179 Set when to relay messages from detached channels to the user with a BouncerServ NOTICE. 180 181 Modes are: 182 183 *message* 184 Relay any message from this channel when detached. 185 186 *highlight* 187 Relay only messages mentioning you when detached. 188 189 *none* 190 Don't relay any messages from this channel when detached. 191 192 *default* 193 Currently same as *highlight*. This is the default behaviour. 194 195 *-reattach-on* <mode> 196 Set when to automatically reattach to detached channels. 197 198 Modes are: 199 200 *message* 201 Reattach to this channel when any message is received. 202 203 *highlight* 204 Reattach to this channel when any message mentioning you is received. 205 206 *none* 207 Never automatically reattach to this channel. 208 209 *default* 210 Currently same as *none*. This is the default behaviour. 211 212 *-detach-after* <duration> 213 Automatically detach this channel after the specified duration has elapsed without receving any message corresponding to *-detach-on*. 214 215 Example duration values: *1h30m*, *30s*, *2.5h*. 216 217 Setting this value to 0 will disable this behaviour, i.e. this channel will never be automatically detached. This is the default behaviour. 218 219 *-detach-on* <mode> 220 Set when to reset the auto-detach timer used by *-detach-after*, causing it to wait again for the auto-detach duration timer before detaching. 221 Joining, reattaching, sending a message, or changing any channel option will reset the timer, in addition to the messages specified by the mode. 222 223 Modes are: 224 225 *message* 226 Receiving any message from this channel will reset the auto-detach timer. 227 228 *highlight* 229 Receiving any message mentioning you from this channel will reset the auto-detach timer. 230 231 *none* 232 Receiving messages from this channel will not reset the auto-detach timer. Sending messages or joining the channel will still reset the timer. 233 234 *default* 235 Currently same as *message*. This is the default behaviour. 236 173 237 *certfp generate* [options...] <network name> 174 238 Generate self-signed certificate and use it for authentication (via SASL -
trunk/service.go
r421 r436 219 219 handle: handlePasswordChange, 220 220 }, 221 "channel": { 222 children: serviceCommandSet{ 223 "update": { 224 usage: "<name> [-relay-detached <default|none|highlight|message>] [-reattach-on <default|none|highlight|message>] [-detach-after <duration>] [-detach-on <default|none|highlight|message>]", 225 desc: "update a channel", 226 handle: handleServiceChannelUpdate, 227 }, 228 }, 229 }, 221 230 } 222 231 } … … 428 437 func handleServiceNetworkUpdate(dc *downstreamConn, params []string) error { 429 438 if len(params) < 1 { 430 return fmt.Errorf("expected exactlyone argument")439 return fmt.Errorf("expected at least one argument") 431 440 } 432 441 … … 697 706 return nil 698 707 } 708 709 type channelFlagSet struct { 710 *flag.FlagSet 711 RelayDetached, ReattachOn, DetachAfter, DetachOn *string 712 } 713 714 func newChannelFlagSet() *channelFlagSet { 715 fs := &channelFlagSet{FlagSet: newFlagSet()} 716 fs.Var(stringPtrFlag{&fs.RelayDetached}, "relay-detached", "") 717 fs.Var(stringPtrFlag{&fs.ReattachOn}, "reattach-on", "") 718 fs.Var(stringPtrFlag{&fs.DetachAfter}, "detach-after", "") 719 fs.Var(stringPtrFlag{&fs.DetachOn}, "detach-on", "") 720 return fs 721 } 722 723 func (fs *channelFlagSet) update(channel *Channel) error { 724 if fs.RelayDetached != nil { 725 filter, err := parseFilter(*fs.RelayDetached) 726 if err != nil { 727 return err 728 } 729 channel.RelayDetached = filter 730 } 731 if fs.ReattachOn != nil { 732 filter, err := parseFilter(*fs.ReattachOn) 733 if err != nil { 734 return err 735 } 736 channel.ReattachOn = filter 737 } 738 if fs.DetachAfter != nil { 739 dur, err := time.ParseDuration(*fs.DetachAfter) 740 if err != nil || dur < 0 { 741 return fmt.Errorf("unknown duration for -detach-after %q (duration format: 0, 300s, 22h30m, ...)", *fs.DetachAfter) 742 } 743 channel.DetachAfter = dur 744 } 745 if fs.DetachOn != nil { 746 filter, err := parseFilter(*fs.DetachOn) 747 if err != nil { 748 return err 749 } 750 channel.DetachOn = filter 751 } 752 return nil 753 } 754 755 func handleServiceChannelUpdate(dc *downstreamConn, params []string) error { 756 if len(params) < 1 { 757 return fmt.Errorf("expected at least one argument") 758 } 759 name := params[0] 760 761 fs := newChannelFlagSet() 762 if err := fs.Parse(params[1:]); err != nil { 763 return err 764 } 765 766 uc, upstreamName, err := dc.unmarshalEntity(name) 767 if err != nil { 768 return fmt.Errorf("unknown channel %q", name) 769 } 770 771 ch, ok := uc.network.channels[upstreamName] 772 if !ok { 773 return fmt.Errorf("unknown channel %q", name) 774 } 775 776 if err := fs.update(ch); err != nil { 777 return err 778 } 779 780 uc.updateChannelAutoDetach(upstreamName) 781 782 if err := dc.srv.db.StoreChannel(uc.network.ID, ch); err != nil { 783 return fmt.Errorf("failed to update channel: %v", err) 784 } 785 786 sendServicePRIVMSG(dc, fmt.Sprintf("updated channel %q", name)) 787 return nil 788 }
Note:
See TracChangeset
for help on using the changeset viewer.