设置默认5分钟同步一次热存储数据 (#192)
This commit is contained in:
parent
fb20b70ebf
commit
71fe8b87ec
5
bot.go
5
bot.go
@ -79,6 +79,9 @@ func (b *Bot) Login() error {
|
||||
// HotLogin 热登录,可实现在单位时间内免重复扫码登录
|
||||
func (b *Bot) HotLogin(storage HotReloadStorage, opts ...HotLoginOptionFunc) error {
|
||||
hotLogin := &HotLogin{storage: storage}
|
||||
// 进行相关设置。
|
||||
// 如果相对默认的行为进行修改,在opts里面进行追加即可。
|
||||
opts = append(defaultHotLoginOpts[:], opts...)
|
||||
for _, opt := range opts {
|
||||
opt(&hotLogin.opt)
|
||||
}
|
||||
@ -331,7 +334,7 @@ func NewBot(c context.Context) *Bot {
|
||||
}
|
||||
|
||||
// DefaultBot 默认的Bot的构造方法,
|
||||
// mode不传入默认为 openwechat.Desktop,详情见mode
|
||||
// mode不传入默认为 openwechat.Normal,详情见mode
|
||||
//
|
||||
// bot := openwechat.DefaultBot(openwechat.Desktop)
|
||||
func DefaultBot(opts ...BotOptionFunc) *Bot {
|
||||
|
@ -4,6 +4,10 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
defaultHotStorageSyncDuration = time.Minute * 5
|
||||
)
|
||||
|
||||
// BotLogin 定义了一个Login的接口
|
||||
type BotLogin interface {
|
||||
Login(bot *Bot) error
|
||||
@ -52,6 +56,10 @@ func HotLoginWithSyncReloadData(duration time.Duration) HotLoginOptionFunc {
|
||||
}
|
||||
}
|
||||
|
||||
var defaultHotLoginOpts = [...]HotLoginOptionFunc{
|
||||
HotLoginWithSyncReloadData(defaultHotStorageSyncDuration),
|
||||
}
|
||||
|
||||
// HotLogin 热登录模式
|
||||
type HotLogin struct {
|
||||
storage HotReloadStorage
|
||||
@ -138,6 +146,7 @@ func PushLoginWithSyncReloadData(duration time.Duration) PushLoginOptionFunc {
|
||||
var defaultPushLoginOpts = [...]PushLoginOptionFunc{
|
||||
PushLoginWithoutUUIDCallback(true),
|
||||
PushLoginWithoutScanCallback(true),
|
||||
PushLoginWithSyncReloadData(defaultHotStorageSyncDuration),
|
||||
}
|
||||
|
||||
// PushLogin 免扫码登录模式
|
||||
|
Loading…
x
Reference in New Issue
Block a user