bot

package
v0.0.0-...-417840b Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2021 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Trace miraiLogLevel = "TRACE"
	Debug miraiLogLevel = "DEBUG"
	Info  miraiLogLevel = "INFO"
	Warn  miraiLogLevel = "WARNING"
	Error miraiLogLevel = "ERROR"
)

Variables

View Source
var (
	ErrSessionNotExist = errors.New("session file not exists")
	ErrReadSessionFile = errors.New("failed to read session file")

	ErrLoginFailed = errors.New("login failed")
)
View Source
var ErrUnknownLogLevel = errors.New("unknown mirai loglevel")

Functions

func DispatchMessage

func DispatchMessage(m interface{}, o DispatchTo)

func ExtractLastTextElement

func ExtractLastTextElement(m MessageStringer) (ret *message.TextElement)

func ExtractMsgSenderUin

func ExtractMsgSenderUin(m interface{}) (uin int64)

func IsPrivateMsg

func IsPrivateMsg(m interface{}) bool

func RegisterEvent

func RegisterEvent(e EventListener)

用于event向bot注册event listener

Types

type Bot

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

bot

func NewBot

func NewBot(uid int64, pw string) *Bot

func (*Bot) ExtractMysPostID

func (b *Bot) ExtractMysPostID(m interface{}) (rest.GameType, int)

func (*Bot) Login

func (b *Bot) Login() (err error)

func (*Bot) LookupGroupMessage

func (b *Bot) LookupGroupMessage(groupCode int64, messageID int32) *message.GroupMessage

func (*Bot) LookupPrivateMessage

func (b *Bot) LookupPrivateMessage(sender int64, messageID int32) *message.PrivateMessage

func (*Bot) M

func (b *Bot) M() *mys.UserManager

func (*Bot) MByMsg

func (b *Bot) MByMsg(m interface{}) *mys.Clientset

从消息自动获取对应的 mys client

func (*Bot) Q

func (b *Bot) Q() *client.QQClient

func (*Bot) RecordMessage

func (b *Bot) RecordMessage(m interface{})

func (*Bot) ReplyStr

func (b *Bot) ReplyStr(m interface{}, reply string)

func (*Bot) SendOrReplyStrByMsg

func (b *Bot) SendOrReplyStrByMsg(m interface{}, toSend string)

func (*Bot) SendStrByMsg

func (b *Bot) SendStrByMsg(m interface{}, toSend string)

type DispatchTo

type DispatchTo struct {
	// debug message.
	// indicate where the message from
	From string
	// GroupMessage callback
	Group func(gm *message.GroupMessage)
	// PrivateMessage callback
	Private func(pm *message.PrivateMessage)
	// Unknown type message callback
	Default func(m interface{})
}

type EventListener

type EventListener interface {
	Register(c *Bot)
	Start()
}

由 event listener 实现

type LightAppShare

type LightAppShare struct {
	App    string `json:"app"`
	Config struct {
		AutoSize bool                  `json:"autosize"`
		CTime    runtime.UnixTimestamp `json:"ctime"`
		Forward  bool                  `json:"forward"`
		Token    string                `json:"token"`
		Type     string                `json:"type"`
	} `json:"config"`
	Descr string `json:"desc"`
	Extra struct {
		AppType int   `json:"app_type"`
		AppID   int   `json:"appid"`
		MsgSeq  int64 `json:"msg_seq"`
		Uin     int64 `json:"uin"`
	} `json:"extra"`
	Meta struct {
		View map[string]struct {
			Action         string `json:"action"`
			AndroidPkgName string `json:"android_pkg_name"`
			AppType        int    `json:"app_type"`
			AppID          int64  `json:"appid"`
			Descr          string `json:"desc"`
			JumpURL        string `json:"jump_url"`
			Preview        string `json:"preview"`
			SourceIcon     string `json:"source_icon"`
			SourceURL      string `json:"source_url"`
			Tag            string `json:"tag"`
			Title          string `json:"title"`
		} `json:",inline"`
	} `json:"meta"`
	Prompt string `json:"prompt"`
	Ver    string `json:"ver"`
	View   string `json:"view"`
}

type MessageStringer

type MessageStringer interface {
	ToString() string
}

Jump to

Keyboard shortcuts

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