Plug

package module
v0.0.0-...-aa70a60 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2023 License: MIT Imports: 0 Imported by: 0

README

Go-Wechaty-Bot-Plugin

Add Features

.
├── Admin
│    └── Admin.go
package Admin

import (
	"fmt"
	. "github.com/XRSec/Go-Wechaty-Bot/General"
	. "github.com/XRSec/Go-Wechaty-Bot/Plug"
	"github.com/wechaty/go-wechaty/wechaty"
	"github.com/wechaty/go-wechaty/wechaty-puppet/schemas"
	"github.com/wechaty/go-wechaty/wechaty/user"
)

var (
	err error
)

const name = "Admin"

func New() *wechaty.Plugin {
	plug := wechaty.NewPlugin()
	plug.OnMessage(onMessage)
	return plug
}

func onMessage(context *wechaty.Context, message *user.Message) {
	m, ok := (context.GetData("msgInfo")).(MessageInfo)
	if !ok {
		fmt.Println()
		return
	}

	fmt.Println(message.Text())

	if m.Status {
		fmt.Println("Room")
		m.PassResult = fmt.Sprintf("Is Room: [%v]", m.RoomName)
		m.Pass = true
		goto end
	} else {
		fmt.Println("Friend")
	}

end:
	context.SetData("msgInfo", m)
}

PreProcessing

  • Server/General/Pretreatment.go
  • Server/main -> main_Bot.Use (from top to bottom)
flowchart LR
    Bot-->onMessage-->Pretreatment
    Pretreatment-->any_More-->ExportMessages-->DingMessage

LogicalProcessing

  • Server/General/Pretreatment.go
flowchart LR
Bot-->onMessage-->Pretreatment
Pretreatment-->ObjectType
Pretreatment-->MessageType
Pretreatment-->ChatStatus
Pretreatment-->Pass
Pretreatment-->Reply

ObjectType-->NightMode
MessageType-->NightMode
ChatStatus-->NightMode
Pass-->NightMode
Reply-->NightMode

NightMode-->chatTimeLimit

chatTimeLimit-->Last_onMessage

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MessageInfo

type MessageInfo struct {
	ID          string `json:"ID" gorm:"column:id;comment:消息ID;primaryKey"`               // 消息ID
	Date        string `json:"Date" gorm:"column:date;comment:日期"`                        // 时间
	Status      bool   `json:"Status" gorm:"column:status;comment:群聊?"`                   // 群聊属性
	AtMe        bool   `json:"AtMe" gorm:"column:atme;comment:提及?"`                       // 是否@我
	RoomName    string `json:"RoomName" gorm:"column:room_name;comment:群聊名称"`             // 群聊名称
	RoomID      string `json:"RoomID" gorm:"column:room_id;comment:群聊ID"`                 // 群聊ID
	UserName    string `json:"UserName" gorm:"column:user_name;comment:用户名"`              // 用户名称
	UserID      string `json:"UserID" gorm:"column:user_id;comment:用户ID"`                 // 用户ID
	Content     string `json:"Content" gorm:"column:content;comment:内容;type:TEXT(10000)"` // 聊天内容
	ReplyResult string `json:"ReplyResult" gorm:"column:reply_result;comment:回复状态"`       // 自动回复
	Reply       bool   `json:"Reply" gorm:"column:reply;comment:回复内容;type:TEXT(10000)"`   // 自动回复状态
	PassResult  string `json:"PassResult" gorm:"column:pass_result;comment:跳过?"`          // Pass原因
	Pass        bool   `json:"Pass" gorm:"column:pass;comment:跳过原因"`                      // Pass状态
}

Jump to

Keyboard shortcuts

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