wechat

package
v0.0.0-...-5ff0099 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 9, 2020 License: GPL-3.0 Imports: 21 Imported by: 2

Documentation

Index

Constants

View Source
const (
	StatusSuccess = 0
)
View Source
const (
	UserAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.109 Safari/537.36"
)

Variables

View Source
var (
	SaveSubFolders = map[string]string{"webwxgeticon": "icons",
		"webwxgetheadimg": "headimgs",
		"webwxgetmsgimg":  "msgimgs",
		"webwxgetvideo":   "videos",
		"webwxgetvoice":   "voices",
		"_showQRCodeImg":  "qrcodes",
	}
	AppID        = "wx782c26e4c19acffb"
	Lang         = "zh_CN"
	LastCheckTs  = time.Now()
	LoginUrl     = "https://login.weixin.qq.com/jslogin"
	QrUrl        = "https://login.weixin.qq.com/qrcode/"
	TuringUrl    = "http://www.tuling123.com/openapi/api"
	APIKEY       = "391ad66ebad2477b908dce8e79f101e7"
	TUringUserId = "abc123"
)
View Source
var (
	SpecialUsers = []string{
		"newsapp", "fmessage", "filehelper", "weibo", "qqmail",
		"tmessage", "qmessage", "qqsync", "floatbottle", "lbsapp",
		"shakeapp", "medianote", "qqfriend", "readerapp", "blogapp",
		"facebookapp", "masssendapp", "meishiapp", "feedsapp", "voip",
		"blogappweixin", "weixin", "brandsessionholder", "weixinreminder", "wxid_novlwrv3lqwv11",
		"gh_22b87fa7cb3c", "officialaccounts", "notification_messages", "wxitil", "userexperience_alarm",
	}

	SyncHosts = []string{
		"wx2.qq.com",
		"webpush.wx2.qq.com",
		"wx8.qq.com",
		"webpush.wx8.qq.com",
		"qq.com",
		"webpush.wx.qq.com",
		"web2.wechat.com",
		"webpush.web2.wechat.com",
		"wechat.com",
		"webpush.web.wechat.com",
		"webpush.weixin.qq.com",
		"webpush.wechat.com",
		"webpush1.wechat.com",
		"webpush2.wechat.com",
		"webpush.wx.qq.com",
		"webpush2.wx.qq.com",
	}
)

Functions

This section is empty.

Types

type AppInfo

type AppInfo struct {
	Type  int
	AppID string
}

type BaseRequest

type BaseRequest struct {
	XMLName    xml.Name `xml:"error" json:"-"`
	Ret        int      `xml:"ret" json:"-"`
	Message    string   `xml:"message" json:"-"`
	Skey       string   `xml:"skey" json:"Skey"`
	Wxsid      string   `xml:"wxsid" json:"Sid"`
	Wxuin      int64    `xml:"wxuin" json:"Uin"`
	PassTicket string   `xml:"pass_ticket" json:"-"`
	DeviceID   string   `xml:"-" json:"DeviceID"`
}

type BaseResponse

type BaseResponse struct {
	Ret    int
	ErrMsg string
}

type Caller

type Caller interface {
	IsSuccess() bool
	Error() error
}

type Config

type Config struct {
	AutoReply bool     `json:"auto_reply"`
	AutoSave  bool     `json:"auto_save"`
	ReplyMsgs []string `json:"reply_msgs"`
}

type GetUUIDParams

type GetUUIDParams struct {
	AppID    string  `json:"appid"`
	Fun      string  `json:"fun"`
	Lang     string  `json:"lang"`
	UnixTime float64 `json:"-"`
}

func NewGetUUIDParams

func NewGetUUIDParams(appid, fun, lang string, times float64) *GetUUIDParams

type InitResp

type InitResp struct {
	Response
	User                User    `json:"User"`
	Count               int     `json:"Count"`
	ContactList         []User  `json:"ContactList"`
	SyncKey             SyncKey `json:"SyncKey"`
	ChatSet             string  `json:"ChatSet"`
	SKey                string  `json:"SKey"`
	ClientVersion       int     `json:"ClientVersion"`
	SystemTime          int     `json:"SystemTime"`
	GrayScale           int     `json:"GrayScale"`
	InviteStartCount    int     `json:"InviteStartCount"`
	MPSubscribeMsgCount int     `json:"MPSubscribeMsgCount"`
	//MPSubscribeMsgList  string  `json:"MPSubscribeMsgList"`
	ClickReportInterval int `json:"ClickReportInterval"`
}

type KeyVal

type KeyVal struct {
	Key int `json:"Key"`
	Val int `json:"Val"`
}

type Member

type Member struct {
	Uin              int64
	UserName         string
	NickName         string
	HeadImgUrl       string
	ContactFlag      int
	MemberCount      int
	MemberList       []User
	RemarkName       string
	HideInputBarFlag int
	Sex              int
	Signature        string
	VerifyFlag       int
	OwnerUin         int
	PYInitial        string
	PYQuanPin        string
	RemarkPYInitial  string
	RemarkPYQuanPin  string
	StarFriend       int
	AppAccountFlag   int
	Statues          int
	AttrStatus       int
	Province         string
	City             string
	Alias            string
	SnsFlag          int
	UniFriend        int
	DisplayName      string
	ChatRoomId       int
	KeyWord          string
	EncryChatRoomId  string
}

func (*Member) IsNormal

func (this *Member) IsNormal(mySelf string) bool

func (*Member) IsSpecail

func (this *Member) IsSpecail() bool

type MemberResp

type MemberResp struct {
	Response
	MemberCount  int
	ChatRoomName string
	MemberList   []Member
	Seq          int
}

type Message

type Message struct {
	FromUserName         string
	PlayLength           int
	RecommendInfo        []string
	Content              string
	StatusNotifyUserName string
	StatusNotifyCode     int
	Status               int
	VoiceLength          int
	ToUserName           string
	ForwardFlag          int
	AppMsgType           int
	AppInfo              AppInfo
	Url                  string
	ImgStatus            int
	MsgType              int
	ImgHeight            int
	MediaId              string
	FileName             string
	FileSize             string
	FromUserNickName     string
	ToUserNickName       string
}

func (Message) String

func (m Message) String() string

type MessageOut

type MessageOut struct {
	ToUserName string
	Content    string
	Type       int
}

type MsgResp

type MsgResp struct {
	Response
}

type NotifyParams

type NotifyParams struct {
	BaseRequest  *BaseRequest
	Code         int
	FromUserName string
	ToUserName   string
	ClientMsgId  int
}

type NotifyResp

type NotifyResp struct {
	Response
	MsgID string
}

type Request

type Request struct {
	BaseRequest *BaseRequest

	MemberCount int    `json:",omitempty"`
	MemberList  []User `json:",omitempty"`
	Topic       string `json:",omitempty"`

	ChatRoomName  string `json:",omitempty"`
	DelMemberList string `json:",omitempty"`
	AddMemberList string `json:",omitempty"`
}

type Response

type Response struct {
	BaseResponse *BaseResponse `json:"BaseResponse"`
}

func (*Response) Error

func (r *Response) Error() error

func (*Response) IsSuccess

func (r *Response) IsSuccess() bool

type SyncCheckResp

type SyncCheckResp struct {
	RetCode  int `json:"retcode"`
	Selector int `json:"selector"`
}

type SyncKey

type SyncKey struct {
	Count int      `json:"Count"`
	List  []KeyVal `json:"List"`
}

type SyncParams

type SyncParams struct {
	BaseRequest BaseRequest `json:"BaseRequest"`
	SyncKey     SyncKey     `json:"SyncKey"`
	RR          int64       `json:"rr"`
}

type SyncResp

type SyncResp struct {
	Response
	SyncKey      SyncKey       `json:"SyncKey"`
	ContinueFlag int           `json:"ContinueFlag"`
	AddMsgList   []interface{} `json:"AddMsgList"`
}

type User

type User struct {
	UserName          string `json:"UserName"`
	Uin               int64  `json:"Uin"`
	NickName          string `json:"NickName"`
	HeadImgUrl        string `json:"HeadImgUrl" xml:""`
	RemarkName        string `json:"RemarkName" xml:""`
	PYInitial         string `json:"PYInitial" xml:""`
	PYQuanPin         string `json:"PYQuanPin" xml:""`
	RemarkPYInitial   string `json:"RemarkPYInitial" xml:""`
	RemarkPYQuanPin   string `json:"RemarkPYQuanPin" xml:""`
	HideInputBarFlag  int    `json:"HideInputBarFlag" xml:""`
	StarFriend        int    `json:"StarFriend" xml:""`
	Sex               int    `json:"Sex" xml:""`
	Signature         string `json:"Signature" xml:""`
	AppAccountFlag    int    `json:"AppAccountFlag" xml:""`
	VerifyFlag        int    `json:"VerifyFlag" xml:""`
	ContactFlag       int    `json:"ContactFlag" xml:""`
	WebWxPluginSwitch int    `json:"WebWxPluginSwitch" xml:""`
	HeadImgFlag       int    `json:"HeadImgFlag" xml:""`
	SnsFlag           int    `json:"SnsFlag" xml:""`
}

type Wechat

type Wechat struct {
	User            User
	Root            string
	Debug           bool
	Uuid            string
	BaseUri         string
	RedirectedUri   string
	Uin             string
	Sid             string
	Skey            string
	PassTicket      string
	DeviceId        string
	BaseRequest     map[string]string
	LowSyncKey      string
	SyncKeyStr      string
	SyncHost        string
	SyncKey         SyncKey
	Users           []string
	InitContactList []User   //谈话的人
	MemberList      []Member //
	ContactList     []Member //好友
	GroupList       []string //群
	GroupMemberList []Member //群友
	PublicUserList  []Member //公众号
	SpecialUserList []Member //特殊账号

	AutoReplyMode bool //default false
	AutoOpen      bool
	Interactive   bool
	TotalMember   int
	TimeOut       int // 同步时间间隔   default:20
	MediaCount    int // -1
	SaveFolder    string
	QrImagePath   string
	Client        *http.Client
	Request       *BaseRequest
	Log           *log.Logger
	MemberMap     map[string]Member
	ChatSet       []string

	AutoReply    bool     //是否自动回复
	ReplyMsgs    []string // 回复的消息列表
	AutoReplySrc bool     //默认false,自动回复,列表。true调用AI机器人。
	// contains filtered or unexported fields
}

func NewWechat

func NewWechat(logger *log.Logger) *Wechat

func (*Wechat) AddMember

func (w *Wechat) AddMember(name string) (err error)

func (*Wechat) AutoReplyMsg

func (w *Wechat) AutoReplyMsg() string

func (*Wechat) CreateRoom

func (w *Wechat) CreateRoom(name string) (err error)

func (*Wechat) GetContacts

func (w *Wechat) GetContacts() (err error)

func (*Wechat) GetContactsInBatch

func (w *Wechat) GetContactsInBatch() (err error)

func (*Wechat) GetGroupName

func (w *Wechat) GetGroupName(id string) (name string)

func (*Wechat) GetQR

func (w *Wechat) GetQR() (err error)

func (*Wechat) GetTuringReply

func (w *Wechat) GetTuringReply(msg string) (retMsg string, err error)

func (*Wechat) GetUUID

func (w *Wechat) GetUUID() (err error)

func (*Wechat) GetUnixTime

func (w *Wechat) GetUnixTime() int

func (*Wechat) Login

func (w *Wechat) Login() (err error)

func (*Wechat) MsgDaemon

func (w *Wechat) MsgDaemon(msgOut chan MessageOut, autoReply chan int)

func (*Wechat) Post

func (w *Wechat) Post(url string, data url.Values, jsonFmt bool) (result string)

func (*Wechat) PullMsg

func (w *Wechat) PullMsg()

func (*Wechat) Send

func (w *Wechat) Send(apiURI string, body io.Reader, call Caller) (err error)

func (*Wechat) SendImage

func (w *Wechat) SendImage(name, fileName string) (err error)

func (*Wechat) SendMsg

func (w *Wechat) SendMsg(toUserName, message string, isFile bool) (err error)

func (*Wechat) SendMsgToAll

func (w *Wechat) SendMsgToAll(word string) (err error)

func (*Wechat) SendTest

func (w *Wechat) SendTest(apiURI string, body io.Reader, call Caller) (err error)

func (*Wechat) SetCookies

func (w *Wechat) SetCookies()

func (*Wechat) SetSynKey

func (w *Wechat) SetSynKey()

func (*Wechat) StatusNotify

func (w *Wechat) StatusNotify() (err error)

func (*Wechat) SyncCheck

func (w *Wechat) SyncCheck() (resp SyncCheckResp, err error)

func (*Wechat) SyncDaemon

func (w *Wechat) SyncDaemon(msgIn chan Message)

同步守护goroutine

func (*Wechat) TestCheck

func (w *Wechat) TestCheck() (err error)

func (*Wechat) WaitForLogin

func (w *Wechat) WaitForLogin() (err error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL