wechat_bot

package module
v0.0.0-...-573eaf6 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2024 License: MIT Imports: 15 Imported by: 0

README

wechat-bot

运行在docker中的微信机器人支持批量部署代理设置。 文件发送与接收图片解析多语言sdk,http接口方便对接。

docker-compose

version: "3"
services:
  wechat-bot:
    image: danbai225/wechat-bot:latest
    container_name: wechat-bot
    restart: always
    ports:
      - "8080:8080"
      - "5555:5555"
      - "5556:5556"
      - "5900:5900"
    extra_hosts:
      - "dldir1.qq.com:127.0.0.1"
    volumes:
      - "./data:/home/app/data"
      - "./wxFiles:/home/app/WeChat Files"
    environment:
      #- PROXY_IP=1.1.1.115 #如果设置则使用代理
      - PROXY_PORT=7777
      - PROXY_USER=user
      - PROXY_PASS=pass

use

package main

import (
	logs "github.com/danbai225/go-logs"
	wechatbot "github.com/danbai225/wechat-bot"
)

func main() {
	client, err := wechatbot.NewClient("ws://serverIP:5555", "http://serverIP:5556")
	if err != nil {
		logs.Err(err)
		return
	}
	client.SetOnWXmsg(func(msg []byte, Type int, reply *wechatbot.Reply) {
		if Type == 1 {
			logs.Info(string(msg))
		}
	})
	select {}
}

Documentation

Index

Constants

View Source
const AtMsg = 550
View Source
const AttatchFile = 5003
View Source
const ChatroomMemberNick = 5020
View Source
const HeartBeat = 5005
View Source
const PersonalDetail = 6550
View Source
const PersonalInfo = 6500
View Source
const PicMsg = 500
View Source
const RecvFileMsg = 49
View Source
const RecvPicMsg = 3
View Source
const RecvTxtMsg = 1
View Source
const TxtMsg = 555
View Source
const UserList = 5000

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(ws, qrHttp string) (*Client, error)

func (*Client) GetContactList

func (c *Client) GetContactList() ([]*Contact, error)

func (*Client) GetNickFormRoom

func (c *Client) GetNickFormRoom(wxid, roomid string) (string, error)

func (*Client) GetPersonal

func (c *Client) GetPersonal() (*Info, error)

func (*Client) GetPersonalDetail

func (c *Client) GetPersonalDetail(wxid string) (*Info, error)

func (*Client) LastHeartbeatTime

func (c *Client) LastHeartbeatTime() int64

func (*Client) QR

func (c *Client) QR() ([]byte, error)

QR * 获取扫描登录二维码

func (*Client) RCon

func (c *Client) RCon() error

RCon 重连

func (*Client) SendAtMsg

func (c *Client) SendAtMsg(content string, atWXid, to, nickname string) error

SendAtMsg *发送@消息 *content:消息内容 *atWXid:被@的人的wxid *to:群wxid *nickname:被@的人的昵称

func (*Client) SendFile

func (c *Client) SendFile(path, wxid string) error

SendFile *发送文件 *content:消息内容 *atWXid:被@的人的wxid *to:群wxid *nickname:被@的人的昵称

func (*Client) SendPicMsg

func (c *Client) SendPicMsg(path, wxid string) error

SendPicMsg *发送图片信息 *content:消息内容 *atWXid:被@的人的wxid *to:群wxid *nickname:被@的人的昵称

func (*Client) SendTxt

func (c *Client) SendTxt(content string, to string) error

SendTxt *发送文本消息 *content:消息内容 *to:接收者的wxid 个人消息为个人wxid 群消息为群wxid

func (*Client) SetOnWXmsg

func (c *Client) SetOnWXmsg(onMsg func(msg []byte, Type int, reply *Reply))

SetOnWXmsg type 1是文本 2是图片 3是文件

func (*Client) ShutDown

func (c *Client) ShutDown() error

type Contact

type Contact struct {
	Headimg string `json:"headimg"`
	Name    string `json:"name"`
	Node    int    `json:"node"`
	Remarks string `json:"remarks"`
	Wxcode  string `json:"wxcode"`
	Wxid    string `json:"wxid"`
}

Contact 联系人

type Dic

type Dic struct {
	// contains filtered or unexported fields
}

type ImgMsg

type ImgMsg struct {
	Content string `json:"content"`
	Detail  string `json:"detail"`
	Id1     string `json:"id1"`
	Id2     string `json:"id2"`
	Thumb   string `json:"thumb"`
}

func ParsePictureMessage

func ParsePictureMessage(msg []byte) *ImgMsg

func (*ImgMsg) GetData

func (im *ImgMsg) GetData(client *Client) ([]byte, error)

type Info

type Info struct {
	BigHeadimg    string `json:"big_headimg"`
	Cover         string `json:"cover"`
	LittleHeadimg string `json:"little_headimg"`
	Signature     string `json:"signature"`
	WxCode        string `json:"wx_code"`
	WxHeadImage   string `json:"wx_head_image"`
	WxId          string `json:"wx_id"`
	WxName        string `json:"wx_name"`
	Nick          string `json:"nick"`
}

Info 该结构体多个返回结果在公用不保证所有字段都有,自行判断

type Reply

type Reply struct {
	// contains filtered or unexported fields
}

Reply 快速回复

func (*Reply) AtMsg

func (r *Reply) AtMsg(content string) error

func (*Reply) Bytes2Path

func (r *Reply) Bytes2Path(data []byte) (string, error)

func (*Reply) File

func (r *Reply) File(path string) error

func (*Reply) GetMsgID

func (r *Reply) GetMsgID() string

func (*Reply) GetNick

func (r *Reply) GetNick() string

func (*Reply) GetPrivateWxID

func (r *Reply) GetPrivateWxID() string

GetPrivateWxID 返回用户ID

func (*Reply) GetWxID

func (r *Reply) GetWxID() string

GetWxID 如果是群消息,返回群ID,如果是私聊消息,返回用户ID

func (*Reply) IsSendByFriend

func (r *Reply) IsSendByFriend() bool

IsSendByFriend 来自私聊

func (*Reply) IsSendByGroup

func (r *Reply) IsSendByGroup() bool

func (*Reply) Msg

func (r *Reply) Msg(content string) error

func (*Reply) PicMsg

func (r *Reply) PicMsg(path string) error

func (*Reply) PrivateChat

func (r *Reply) PrivateChat(content string) error

func (*Reply) PrivateFile

func (r *Reply) PrivateFile(path string) error

func (*Reply) PrivatePicMsg

func (r *Reply) PrivatePicMsg(path string) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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