This commit is contained in:
parent
b967eda0d0
commit
c20044dbb1
@ -1,4 +1,6 @@
|
||||
# openwechat
|
||||
[](https://godoc.org/github.com/eatMoreApple/openwechat)
|
||||
|
||||
> golang版个人微信号API, 类似开发公众号一样,开发个人微信号
|
||||
|
||||
|
||||
|
16
bot.go
16
bot.go
@ -35,6 +35,11 @@ func (b *Bot) Alive() bool {
|
||||
}
|
||||
|
||||
// 获取当前的用户
|
||||
// self, err := bot.GetCurrentUser()
|
||||
// if err != nil {
|
||||
// return
|
||||
// }
|
||||
// fmt.Println(self.NickName)
|
||||
func (b *Bot) GetCurrentUser() (*Self, error) {
|
||||
if b.self == nil {
|
||||
return nil, errors.New("user not login")
|
||||
@ -42,6 +47,11 @@ func (b *Bot) GetCurrentUser() (*Self, error) {
|
||||
return b.self, nil
|
||||
}
|
||||
|
||||
// 热登录,可实现重复登录,
|
||||
// retry设置为true可在热登录失效后进行普通登录行为
|
||||
// storage := NewJsonFileHotReloadStorage("storage.json")
|
||||
// err := bot.HotLogin(storage, true)
|
||||
// fmt.Println(err)
|
||||
func (b *Bot) HotLogin(storage HotReloadStorage, retry ...bool) error {
|
||||
b.isHot = true
|
||||
b.hotReloadStorage = storage
|
||||
@ -275,10 +285,14 @@ func (b *Bot) MessageOnError(h func(err error)) {
|
||||
b.GetMessageErrorHandler = h
|
||||
}
|
||||
|
||||
// Bot的构造方法,需要自己传入Caller
|
||||
func NewBot(caller *Caller) *Bot {
|
||||
return &Bot{Caller: caller, storage: &Storage{}, exit: make(chan bool)}
|
||||
}
|
||||
|
||||
// 默认的Bot的构造方法,
|
||||
// mode不传入默认为openwechat.Normal,详情见mode
|
||||
// bot := openwechat.DefaultBot(openwechat.Desktop)
|
||||
func DefaultBot(modes ...mode) *Bot {
|
||||
var m mode
|
||||
if len(modes) == 0 {
|
||||
@ -290,10 +304,12 @@ func DefaultBot(modes ...mode) *Bot {
|
||||
return NewBot(DefaultCaller(urlManager))
|
||||
}
|
||||
|
||||
// 通过uuid获取登录二维码的url
|
||||
func GetQrcodeUrl(uuid string) string {
|
||||
return qrcodeUrl + uuid
|
||||
}
|
||||
|
||||
// 打印登录二维码
|
||||
func PrintlnQrcodeUrl(uuid string) {
|
||||
println("访问下面网址扫描二维码登录")
|
||||
println(GetQrcodeUrl(uuid))
|
||||
|
@ -91,9 +91,11 @@ var (
|
||||
noSuchUserFoundError = errors.New("no such user found")
|
||||
)
|
||||
|
||||
// ALL跟search函数搭配
|
||||
// friends.Search(openwechat.ALL, )
|
||||
const ALL = 0
|
||||
|
||||
// sex
|
||||
// 性别
|
||||
const (
|
||||
MALE = 1
|
||||
FEMALE = 2
|
||||
|
Loading…
x
Reference in New Issue
Block a user