Browse Source

Remove wallet and convs from options, and instead automatically enable them if the correct handlers are present

main
Sam 4 years ago
parent
commit
0feb664405
  1. 35
      chat.go
  2. 2
      types.go

35
chat.go

@ -115,37 +115,38 @@ func getNewMessages(k *Keybase, subs *SubscriptionChannels, execOptions []string @@ -115,37 +115,38 @@ func getNewMessages(k *Keybase, subs *SubscriptionChannels, execOptions []string
}
// Run runs `keybase chat api-listen`, and passes incoming messages to the message handler func
func (k *Keybase) Run(handlers Handlers, options ...RunOptions) {
func (k *Keybase) Run(handlers Handlers, options *RunOptions) {
var channelCapacity = 100
runOptions := make([]string, 0)
if len(options) > 0 {
if options[0].Capacity > 0 {
channelCapacity = options[0].Capacity
}
if options[0].Wallet {
runOptions = append(runOptions, "--wallet")
}
if options[0].Convs {
runOptions = append(runOptions, "--convs")
if handlers.WalletHandler != nil {
runOptions = append(runOptions, "--wallet")
}
if handlers.ConversationHandler != nil {
runOptions = append(runOptions, "--convs")
}
if options != nil {
if options.Capacity > 0 {
channelCapacity = options.Capacity
}
if options[0].Local {
if options.Local {
runOptions = append(runOptions, "--local")
}
if options[0].HideExploding {
if options.HideExploding {
runOptions = append(runOptions, "--hide-exploding")
}
if options[0].Dev {
if options.Dev {
runOptions = append(runOptions, "--dev")
}
if len(options[0].FilterChannels) > 0 {
if len(options.FilterChannels) > 0 {
runOptions = append(runOptions, "--filter-channels")
runOptions = append(runOptions, createFiltersString(options[0].FilterChannels))
runOptions = append(runOptions, createFiltersString(options.FilterChannels))
}
if options[0].FilterChannel.Name != "" {
if options.FilterChannel.Name != "" {
runOptions = append(runOptions, "--filter-channel")
runOptions = append(runOptions, createFilterString(options[0].FilterChannel))
runOptions = append(runOptions, createFilterString(options.FilterChannel))
}
}

2
types.go

@ -16,8 +16,6 @@ type RunOptions struct { @@ -16,8 +16,6 @@ type RunOptions struct {
Local bool // Subscribe to local messages
HideExploding bool // Ignore exploding messages
Dev bool // Subscribe to dev channel messages
Wallet bool // Subscribe to wallet events
Convs bool // Subscribe to new-conversation events
FilterChannel chat1.ChatChannel // Only subscribe to messages from specified channel
FilterChannels []chat1.ChatChannel // Only subscribe to messages from specified channels
}

Loading…
Cancel
Save