This commit is contained in:
parent
b967eda0d0
commit
c20044dbb1
@ -1,4 +1,6 @@
|
|||||||
# openwechat
|
# openwechat
|
||||||
|
[](https://godoc.org/github.com/eatMoreApple/openwechat)
|
||||||
|
|
||||||
> golang版个人微信号API, 类似开发公众号一样,开发个人微信号
|
> 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) {
|
func (b *Bot) GetCurrentUser() (*Self, error) {
|
||||||
if b.self == nil {
|
if b.self == nil {
|
||||||
return nil, errors.New("user not login")
|
return nil, errors.New("user not login")
|
||||||
@ -42,6 +47,11 @@ func (b *Bot) GetCurrentUser() (*Self, error) {
|
|||||||
return b.self, nil
|
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 {
|
func (b *Bot) HotLogin(storage HotReloadStorage, retry ...bool) error {
|
||||||
b.isHot = true
|
b.isHot = true
|
||||||
b.hotReloadStorage = storage
|
b.hotReloadStorage = storage
|
||||||
@ -275,10 +285,14 @@ func (b *Bot) MessageOnError(h func(err error)) {
|
|||||||
b.GetMessageErrorHandler = h
|
b.GetMessageErrorHandler = h
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Bot的构造方法,需要自己传入Caller
|
||||||
func NewBot(caller *Caller) *Bot {
|
func NewBot(caller *Caller) *Bot {
|
||||||
return &Bot{Caller: caller, storage: &Storage{}, exit: make(chan bool)}
|
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 {
|
func DefaultBot(modes ...mode) *Bot {
|
||||||
var m mode
|
var m mode
|
||||||
if len(modes) == 0 {
|
if len(modes) == 0 {
|
||||||
@ -290,10 +304,12 @@ func DefaultBot(modes ...mode) *Bot {
|
|||||||
return NewBot(DefaultCaller(urlManager))
|
return NewBot(DefaultCaller(urlManager))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 通过uuid获取登录二维码的url
|
||||||
func GetQrcodeUrl(uuid string) string {
|
func GetQrcodeUrl(uuid string) string {
|
||||||
return qrcodeUrl + uuid
|
return qrcodeUrl + uuid
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 打印登录二维码
|
||||||
func PrintlnQrcodeUrl(uuid string) {
|
func PrintlnQrcodeUrl(uuid string) {
|
||||||
println("访问下面网址扫描二维码登录")
|
println("访问下面网址扫描二维码登录")
|
||||||
println(GetQrcodeUrl(uuid))
|
println(GetQrcodeUrl(uuid))
|
||||||
|
@ -91,9 +91,11 @@ var (
|
|||||||
noSuchUserFoundError = errors.New("no such user found")
|
noSuchUserFoundError = errors.New("no such user found")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// ALL跟search函数搭配
|
||||||
|
// friends.Search(openwechat.ALL, )
|
||||||
const ALL = 0
|
const ALL = 0
|
||||||
|
|
||||||
// sex
|
// 性别
|
||||||
const (
|
const (
|
||||||
MALE = 1
|
MALE = 1
|
||||||
FEMALE = 2
|
FEMALE = 2
|
||||||
|
4
url.go
4
url.go
@ -83,9 +83,11 @@ type mode string
|
|||||||
// 向外暴露2种模式
|
// 向外暴露2种模式
|
||||||
const (
|
const (
|
||||||
Normal mode = "normal"
|
Normal mode = "normal"
|
||||||
Desktop mode = "desktop"
|
Desktop mode = "desktop" // 突破网页版登录限制
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// 通过mode获取完善的UrlManager,
|
||||||
|
// mode有且仅有两种模式: Normal && Desktop
|
||||||
func GetUrlManagerByMode(m mode) UrlManager {
|
func GetUrlManagerByMode(m mode) UrlManager {
|
||||||
switch m {
|
switch m {
|
||||||
case Desktop:
|
case Desktop:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user