Categorygithub.com/hyperits/openwechat
modulepackage
0.0.1
Repository: https://github.com/hyperits/openwechat.git
Documentation: pkg.go.dev

# README

openwechat

Go DocReleaseGo Report CardStarsForks

golang版个人微信号API, 突破网页版限制,类似开发公众号一样,开发个人微信号

微信机器人:smiling_imp:,利用微信号完成一些功能的定制化开发⭐

  • 支持定制化开发,如日志记录,自动回复
  • 突破网页版登录限制📣
  • 无需重复扫码登录
  • 支持多个微信号同时登陆

安装

go get

go get github.com/hyperits/openwechat

go mod

require github.com/hyperits/openwechat latest

快速开始

package main

import (
	"fmt"
	"github.com/hyperits/openwechat"
)

func main() {
	bot := openwechat.DefaultBot()
  // bot := openwechat.DefaultBot(openwechat.Desktop) // 桌面模式,上面登录不上的可以尝试切换这种模式

	// 注册消息处理函数
	bot.MessageHandler = func(msg *openwechat.Message) {
		if msg.IsText() && msg.Content == "ping" {
			msg.ReplyText("pong")
		}
	}
	// 注册登陆二维码回调
	bot.UUIDCallback = openwechat.PrintlnQrcodeUrl

	// 登陆
	if err := bot.Login(); err != nil {
		fmt.Println(err)
		return
	}

	// 获取登陆的用户
	self, err := bot.GetCurrentUser()
	if err != nil {
		fmt.Println(err)
		return
	}

	// 获取所有的好友
	friends, err := self.Friends()
	fmt.Println(friends, err)

	// 获取所有的群组
	groups, err := self.Groups()
	fmt.Println(groups, err)

	// 阻塞主goroutine, 直到发生异常或者用户主动退出
	bot.Block()
}

支持功能

  • 消息回复、给指定对象(好友、群组)发送文本、图片、文件、emoji表情等消息
  • 热登陆(无需重复扫码登录)、自定义消息处理、文件下载、消息防撤回
  • 获取对象信息、设置好友备注、拉好友进群等
  • 更多功能请查看文档

文档

点击查看

项目主页

https://github.com/hyperits/openwechat

Thanks

JetBrains

添加微信(EatMoreApple):apple:(备注: openwechat),进群交流:smiling_imp:

如果二维码图片没显示出来,请添加微信号 EatMoreApple

# Packages

No description provided by the author
No description provided by the author

# Functions

DefaultBot 默认的Bot的构造方法, mode不传入默认为 openwechat.Desktop,详情见mode bot := openwechat.DefaultBot(openwechat.Desktop).
DefaultCaller Default Constructor for Caller.
DefaultClient 自动存储cookie 设置客户端不自动跳转.
DispatchMessage 跟 MessageDispatcher 结合封装成 MessageHandler.
No description provided by the author
GetFileContentType 获取文件上传的类型.
GetQrcodeUrl 通过uuid获取登录二维码的url.
GetRandomDeviceId 获取随机设备id.
IgnoreNetworkError 忽略网络请求的错误.
No description provided by the author
MatchFuncList 将多个MatchFunc封装成一个MatchFunc.
NewBot Bot的构造方法.
NewCaller Constructor for Caller.
No description provided by the author
No description provided by the author
NewFriendHelper 这里为了兼容Desktop版本找不到文件传输助手的问题 文件传输助手的微信身份标识符永远是filehelper 这种形式的对象可能缺少一些其他属性 但是不影响发送信息的功能.
No description provided by the author
NewJsonFileHotReloadStorage 创建JsonFileHotReloadStorage Deprecated use os.File instead.
NewMediaSendMessage 媒体消息的构造方法.
NewMessageMatchDispatcher Constructor.
NewRepositories TODO.
NewSendMessage SendMessage的构造方法.
NewTextSendMessage 文本消息的构造方法.
No description provided by the author
PrintlnQrcodeUrl 打印登录二维码.
SenderFriendRequired 只匹配好友.
SenderGroupRequired 只匹配群组.
SenderMatchFunc 抽象的匹配发送者特征的处理函数 dispatcher := NewMessageMatchDispatcher() matchFuncList := MatchFuncList(SenderFriendRequired(), SenderNickNameContainsMatchFunc("多吃点苹果")) dispatcher.RegisterHandler(matchFuncList, func(ctx *MessageContext) { do your own business }).
SenderMpRequired 只匹配公众号.
SenderNickNameContainsMatchFunc 根据用户昵称是否包含指定字符串的匹配函数.
SenderNickNameEqualMatchFunc 根据用户昵称是否等于指定字符串的匹配函数.
SenderRemakeNameContainsFunc 根据用户备注名是否包含指定字符串的匹配函数.
SenderRemarkNameEqualMatchFunc 根据用户备注是否等于指定字符串的匹配函数.
No description provided by the author
ToDSNString TODO.

# Constants

ALL 跟search函数搭配 friends.Search(openwechat.ALL, ).
消息类型.
附件消息.
语音消息.
名片消息.
表情消息.
Emotion.
Good.
图片消息.
Open.
自定义的消息.
地理位置消息.
红包消息.
ScanGood.
文本消息.
转账消息.
文章消息.
视频消息.
VoiceRemind.
性别.
性别.
APP消息.
表情消息.
图片消息.
地理位置消息.
小视频消息.
好友推荐消息.
消息撤回.
名片消息.
系统消息.
文本消息.
认证消息.
视频消息.
语音消息.
VOIP消息.
VOIP邀请.
VOIP结束消息.
登录状态.
登录状态.
登录状态.
登录状态.
No description provided by the author
ZombieText 检测僵尸好友字符串 发送该字符给好友,能正常发送不报错的为正常好友,否则为僵尸好友.

# Variables

No description provided by the author
No description provided by the author
emoji 表情 字段太多了,污染命名空间,封装成struct返回.
errors.
errors.
errors.
errors.
No description provided by the author

# Structs

AppMessageData 获取APP消息的正文 See https://github.com/hyperits/openwechat/issues/62.
BaseRequest 初始的请求信息 几乎所有的请求都要携带该参数.
BaseResponse 大部分返回对象都携带该信息.
No description provided by the author
Caller 调用请求和解析请求 上层模块可以直接获取封装后的请求结果.
Card 名片消息内容.
No description provided by the author
Client http请求客户端 客户端需要维持Session会话 并且客户端不允许跳转.
ConfInfo 配置struct.
No description provided by the author
FriendAddMessage 好友添加消息信息内容.
No description provided by the author
No description provided by the author
JsonFileHotReloadStorage 实现HotReloadStorage接口 默认以json文件的形式存储 Deprecated.
LoginInfo 登录信息.
No description provided by the author
MessageContext 消息处理上下文对象.
MessageMatchDispatcher impl MessageDispatcher interface dispatcher := NewMessageMatchDispatcher() dispatcher.OnText(func(msg *Message){ msg.ReplyText("hello") }) bot := DefaultBot() bot.MessageHandler = DispatchMessage(dispatcher).
No description provided by the author
Mp 公众号对象.
MPSubscribeMsg 公众号的订阅信息.
No description provided by the author
No description provided by the author
RecommendInfo 一些特殊类型的消息会携带该结构体信息.
Repositories TODO.
RevokeMsg 撤回消息Content.
Self 自己,当前登录用户对象.
SendMessage 发送消息的结构体.
SentMessage 已发送的信息.
Storage 身份信息, 维持整个登陆的Session会话.
No description provided by the author
No description provided by the author
No description provided by the author
User 抽象的用户结构: 好友 群组 公众号.
No description provided by the author
No description provided by the author
WebInitResponse 初始化的相应信息.
No description provided by the author
No description provided by the author
No description provided by the author

# Interfaces

HttpHook 请求上下文钩子.
MessageDispatcher 消息分发处理接口 跟 DispatchMessage 结合封装成 MessageHandler.
No description provided by the author

# Type aliases

AppMessageType 以Go惯用形式定义了PC微信所有的官方App消息类型。.
No description provided by the author
No description provided by the author
HotReloadStorage 热登陆存储接口.
No description provided by the author
MatchFunc 消息匹配函数,返回为true则表示匹配.
Members 抽象的用户组.
MessageContextHandler 消息处理函数.
No description provided by the author
MessageHandler 消息处理函数.
No description provided by the author
MessageType 以Go惯用形式定义了PC微信所有的官方消息类型。 详见 message_test.go.
Mps 公众号组对象.
No description provided by the author
No description provided by the author
No description provided by the author