mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-24 07:45:15 +00:00
livenote: add option channel
This commit is contained in:
parent
0b2fdd471e
commit
9b1060e16d
|
@ -4,6 +4,16 @@ import "time"
|
||||||
|
|
||||||
type Option interface{}
|
type Option interface{}
|
||||||
|
|
||||||
|
type OptionChannel struct {
|
||||||
|
Channel string
|
||||||
|
}
|
||||||
|
|
||||||
|
func Channel(channel string) *OptionChannel {
|
||||||
|
return &OptionChannel{
|
||||||
|
Channel: channel,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
type OptionCompare struct {
|
type OptionCompare struct {
|
||||||
Value bool
|
Value bool
|
||||||
}
|
}
|
||||||
|
|
|
@ -241,6 +241,9 @@ func (n *Notifier) PostLiveNote(obj livenote.Object, opts ...livenote.Option) er
|
||||||
var shouldPin bool
|
var shouldPin bool
|
||||||
var ttl time.Duration = 0
|
var ttl time.Duration = 0
|
||||||
|
|
||||||
|
// load the default channel
|
||||||
|
channel := n.channel
|
||||||
|
|
||||||
for _, opt := range opts {
|
for _, opt := range opts {
|
||||||
switch val := opt.(type) {
|
switch val := opt.(type) {
|
||||||
case *livenote.OptionOneTimeMention:
|
case *livenote.OptionOneTimeMention:
|
||||||
|
@ -254,6 +257,10 @@ func (n *Notifier) PostLiveNote(obj livenote.Object, opts ...livenote.Option) er
|
||||||
shouldPin = val.Value
|
shouldPin = val.Value
|
||||||
case *livenote.OptionTimeToLive:
|
case *livenote.OptionTimeToLive:
|
||||||
ttl = val.Duration
|
ttl = val.Duration
|
||||||
|
case *livenote.OptionChannel:
|
||||||
|
if val.Channel != "" {
|
||||||
|
channel = val.Channel
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -265,7 +272,6 @@ func (n *Notifier) PostLiveNote(obj livenote.Object, opts ...livenote.Option) er
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
channel := n.channel
|
|
||||||
note := n.liveNotePool.Update(obj)
|
note := n.liveNotePool.Update(obj)
|
||||||
curObj = note.Object
|
curObj = note.Object
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user