robot

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

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

Go to latest
Published: Jun 18, 2023 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ChatTalk  = 1
	RoomTalk  = 2
	AllTalk   = 3
	AdminPerm = 4
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Admin

type Admin struct {
	Name string

	Option map[string]interface{}

	Rooms   []*Room
	Friends []string
	// contains filtered or unexported fields
}

func NewAdmin

func NewAdmin(name string) *Admin

func (*Admin) AdminCommand

func (m *Admin) AdminCommand(cmd string, msg xmpp.Chat)

admin 命令

func (*Admin) BotCommand

func (m *Admin) BotCommand(cmd string, msg xmpp.Chat)

bot 命令

func (*Admin) Chat

func (m *Admin) Chat(msg xmpp.Chat)

func (*Admin) CheckEnv

func (m *Admin) CheckEnv() bool

func (*Admin) CronCommand

func (m *Admin) CronCommand(cmd string, msg xmpp.Chat)

cron 命令处理

func (*Admin) Description

func (m *Admin) Description() string

func (*Admin) GetCmdString

func (m *Admin) GetCmdString(cmd string) string

func (*Admin) GetName

func (m *Admin) GetName() string

BotInterface

func (*Admin) GetOptions

func (m *Admin) GetOptions() map[string]string

func (*Admin) GetRooms

func (m *Admin) GetRooms() []*Room

AdminInterface

func (*Admin) GetSummary

func (m *Admin) GetSummary() string

func (*Admin) HasPerm

func (m *Admin) HasPerm(name string, msg xmpp.Chat) bool

func (*Admin) Help

func (m *Admin) Help() string

func (*Admin) HelpCommand

func (m *Admin) HelpCommand(cmd string, msg xmpp.Chat)

help 命令

func (*Admin) IsAdminID

func (m *Admin) IsAdminID(jid string) bool

func (*Admin) IsCmd

func (m *Admin) IsCmd(text string) bool

func (*Admin) IsFriendID

func (m *Admin) IsFriendID(jid string) bool

func (*Admin) IsRoomID

func (m *Admin) IsRoomID(jid string) bool

jid 是已进入的聊天室吗?

func (*Admin) IsSysAdminID

func (m *Admin) IsSysAdminID(jid string) bool

func (*Admin) LoginTime

func (m *Admin) LoginTime() time.Time

func (*Admin) PluginCommand

func (m *Admin) PluginCommand(cmd string, msg xmpp.Chat)

plugin 命令

func (*Admin) Presence

func (m *Admin) Presence(pres xmpp.Presence)

func (*Admin) Restart

func (m *Admin) Restart()

func (*Admin) RoomCommand

func (m *Admin) RoomCommand(cmd string, msg xmpp.Chat)

room 命令

func (*Admin) SetOption

func (m *Admin) SetOption(key, val string)

func (*Admin) SetPerm

func (m *Admin) SetPerm(name string, perm int)

func (*Admin) ShowPerm

func (m *Admin) ShowPerm(name string) string

func (*Admin) Start

func (m *Admin) Start(bot *Bot)

func (*Admin) Stop

func (m *Admin) Stop()

type AdminIface

type AdminIface interface {
	GetRooms() []*Room
	IsAdminID(jid string) bool
	IsFriendID(jid string) bool
	IsCmd(text string) bool
	IsRoomID(jid string) bool
	GetCmdString(cmd string) string
	LoginTime() time.Time
	HasPerm(name string, msg xmpp.Chat) bool
	ShowPerm(name string) string
	SetPerm(name string, perm int)
}

type Bot

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

func NewBot

func NewBot(client *xmpp.Client, cfg config.Config, f NewFunc) *Bot

func (*Bot) AddHandler

func (b *Bot) AddHandler(mod, path string, handler http.HandlerFunc, name string)

func (*Bot) AddPlugin

func (b *Bot) AddPlugin(name string)

按名称加载某个模块

func (*Bot) ApproveSubscription

func (b *Bot) ApproveSubscription(jid string)

func (*Bot) BlockRemote

func (b *Bot) BlockRemote(msg xmpp.Chat) bool

此人在聊天中被忽略了吗?

func (*Bot) Called

func (b *Bot) Called(msg xmpp.Chat) (ok bool, text string)

bot 在群里被点名了吗?

func (*Bot) Chat

func (b *Bot) Chat(chat xmpp.Chat)

Interface(), 模块收到消息时的处理

func (*Bot) DelHandler

func (b *Bot) DelHandler(mod, name string)

func (*Bot) GetCmdString

func (b *Bot) GetCmdString(cmd string) string

func (*Bot) GetConfig

func (b *Bot) GetConfig() config.Config

func (*Bot) GetCron

func (b *Bot) GetCron() *cron.Cron

func (*Bot) GetPluginByName

func (b *Bot) GetPluginByName(name string) PluginIface

获取模块

func (*Bot) GetPluginOption

func (b *Bot) GetPluginOption(name string) map[string]interface{}

func (*Bot) GetPlugins

func (b *Bot) GetPlugins() []PluginIface

func (*Bot) HasPerm

func (b *Bot) HasPerm(name string, msg xmpp.Chat) bool

func (*Bot) Init

func (b *Bot) Init(f NewFunc)

Interface(), 初始化并加载所有模块

func (*Bot) InviteToMUC

func (b *Bot) InviteToMUC(jid, roomid, reason string)

func (*Bot) IsAdminID

func (b *Bot) IsAdminID(jid string) bool

func (*Bot) IsCmd

func (b *Bot) IsCmd(text string) bool

func (*Bot) IsRoomID

func (b *Bot) IsRoomID(jid string) bool

func (*Bot) JoinMUC

func (b *Bot) JoinMUC(jid, nickname string)

func (*Bot) JoinProtectedMUC

func (b *Bot) JoinProtectedMUC(jid, nickname, password string)

func (*Bot) LeaveMUC

func (b *Bot) LeaveMUC(jid string)

func (*Bot) Presence

func (b *Bot) Presence(presence xmpp.Presence)

Interface(), 模块收到Presence消息时的处理

func (*Bot) RemovePlugin

func (b *Bot) RemovePlugin(name string)

按名称卸载某个模块

func (*Bot) ReplyAuto

func (b *Bot) ReplyAuto(recv xmpp.Chat, text string)

回复好友消息,或聊天室私聊消息

func (*Bot) ReplyPub

func (b *Bot) ReplyPub(recv xmpp.Chat, text string)

回复好友消息,或聊天室公共消息

func (*Bot) RequestSubscription

func (b *Bot) RequestSubscription(jid string)

func (*Bot) Restart

func (b *Bot) Restart()

Interface(), 重新载入并初始化各模块

func (*Bot) RevokeSubscription

func (b *Bot) RevokeSubscription(jid string)

func (*Bot) Roster

func (b *Bot) Roster() error

func (*Bot) Run

func (b *Bot) Run(quit chan<- bool)

func (*Bot) SendAuto

func (b *Bot) SendAuto(to, text string)

发送到好友消息,或聊天室私聊消息

func (*Bot) SendHtml

func (b *Bot) SendHtml(chat xmpp.Chat)

func (*Bot) SendPub

func (b *Bot) SendPub(to, text string)

发送聊天室公共消息

func (*Bot) SentThis

func (b *Bot) SentThis(msg xmpp.Chat) bool

消息是由bot自己发出的吗?

func (*Bot) SetPerm

func (b *Bot) SetPerm(name string, perm int)

func (*Bot) SetRobert

func (b *Bot) SetRobert(jid string) (n int, err error)

func (*Bot) SetRoomNick

func (b *Bot) SetRoomNick(r *Room, nick string) (n int, err error)

func (*Bot) SetStatus

func (b *Bot) SetStatus(status, info string) (n int, err error)

设置状态消息

func (*Bot) ShowPerm

func (b *Bot) ShowPerm(name string) string

func (*Bot) Start

func (b *Bot) Start()

func (*Bot) Stop

func (b *Bot) Stop()

Interface(), 模块卸载时的处理函数

type CronEntry

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

type NewFunc

type NewFunc func(name string, opt map[string]interface{}) PluginIface

type PluginIface

type PluginIface interface {
	Help() string
	GetName() string
	GetSummary() string
	Description() string
	CheckEnv() bool
	Start(bot *Bot)
	Stop()
	Restart()
	Chat(chat xmpp.Chat)
	Presence(pres xmpp.Presence)
	GetOptions() map[string]string
	SetOption(key, val string)
}

type Room

type Room struct {
	JID      string
	Nickname string
	Password string
	Block    []string
}

func NewRoom

func NewRoom(jid, nickname, password string) *Room

func (*Room) BlockOne

func (r *Room) BlockOne(nick string)

func (*Room) GetJID

func (r *Room) GetJID() string

func (*Room) GetNick

func (r *Room) GetNick() string

func (*Room) GetPassword

func (r *Room) GetPassword() string

func (*Room) IsBlocked

func (r *Room) IsBlocked(nick string) bool

func (*Room) ListBlocks

func (r *Room) ListBlocks() string

func (*Room) SetNick

func (r *Room) SetNick(nick string)

func (*Room) UnBlockOne

func (r *Room) UnBlockOne(nick string)

type WebServer

type WebServer struct {
	Dispatcher *mux.Router
	Server     *graceful.Server
	Urls       map[string]func(w http.ResponseWriter, r *http.Request)
}

func NewWebServer

func NewWebServer(host string, port int) *WebServer

func (*WebServer) Destroy

func (s *WebServer) Destroy(name string)

func (*WebServer) Handler

func (s *WebServer) Handler(path string, handler http.HandlerFunc, name string)

func (*WebServer) Start

func (s *WebServer) Start()

func (*WebServer) Stop

func (s *WebServer) Stop()

Jump to

Keyboard shortcuts

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