Documentation
¶
Index ¶
- Constants
- Variables
- func AddCron(cronInfo *db.Cron) error
- func C2CMessageEventHandler(event *dto.WSPayload, message *dto.WSC2CMessageData) error
- func CloseTalk(vc *discordgo.VoiceConnection)
- func CreateBot(ctx context.Context) *tgbotapi.BotAPI
- func ExecComWechat(c *db.Cron)
- func ExecCron(c *db.Cron)
- func ExecDing(c *db.Cron)
- func ExecLark(c *db.Cron)
- func ExecPersonalQQ(c *db.Cron)
- func ExecSlack(c *db.Cron)
- func ExecTelegram(c *db.Cron)
- func ExecWechat(c *db.Cron)
- func ForceReply(chatId int64, msgId int, i18MsgId string, bot *tgbotapi.BotAPI) error
- func GetMarkdownContent(content string) string
- func InitCron()
- func LarkMessageHandler(ctx context.Context, message *larkim.P2MessageReceiveV1) error
- func OnChatReceive(ctx context.Context, message *chatbot.BotCallbackDataModel) ([]byte, error)
- func ParseCommand(prompt string) (command string, args string)
- func QQATMessageEventHandler(event *dto.WSPayload, atMessage *dto.WSATMessageData) error
- func QQGroupATMessageEventHandler(event *dto.WSPayload, atMessage *dto.WSGroupATMessageData) error
- func SlackButtonHandler(callback *slack.InteractionCallback)
- func SlackCmdHandler(command *slack.SlashCommand)
- func SlackMessageHandler(message *slackevents.MessageEvent)
- func StartComWechatRobot(ctx context.Context)
- func StartDingRobot(ctx context.Context)
- func StartDiscordRobot(ctx context.Context)
- func StartLarkRobot(ctx context.Context)
- func StartQQRobot(ctx context.Context)
- func StartRobot()
- func StartSlackRobot(ctx context.Context)
- func StartTelegramRobot(ctx context.Context)
- func StartWechatRobot()
- func WechatMsgSent(msgId string)
- func WithContext(ctx context.Context) func(*RobotInfo)
- func WithRobot(robot Robot) func(*RobotInfo)
- func WithSkipCheck(skipCheck bool) func(*RobotInfo)
- func WithUseRecord(userRecord bool) func(*RobotInfo)
- type AccessToken
- type ComWechatRobot
- type DingResp
- type DingRobot
- func (d *DingRobot) CreateDingAuthClient() (_result *dingtalkoauth2.Client, _err error)
- func (d *DingRobot) CreateDingInteractClient() (_result *dingtalkaiinteraction.Client, _err error)
- func (d *DingRobot) CreateDingRobotClient() (result *dingtalkrobot.Client, err error)
- func (d *DingRobot) GetAccessToken() (string, error)
- func (d *DingRobot) GetImageContent(accessToken string, c map[string]interface{}) ([]byte, error)
- func (d *DingRobot) GetMessageContent() (bool, error)
- func (d *DingRobot) ReplyMessage(ctx context.Context, requestBody map[string]interface{}) (*DingResp, error)
- func (d *DingRobot) SimpleReplyMarkdown(ctx context.Context, content []byte) (*DingResp, error)
- func (d *DingRobot) UploadFileWithType(accessToken, fileType, filePath string, fileContent []byte) (string, error)
- func (d *DingRobot) VideoReplyMarkdown(ctx context.Context, mediaId, format string) (*DingResp, error)
- func (d *DingRobot) VoiceReplyMarkdown(ctx context.Context, mediaId string, duration int) (*DingResp, error)
- type DiscordRobot
- type Element
- type FileData
- type LarkRobot
- type MessageItem
- type MessageItemData
- type MessagePostContent
- type MessagePostElement
- type MessagePostMarkdown
- type MessageText
- type MsgChan
- type OneBotResult
- type PersonalQQRobot
- type QQMessage
- type QQRobot
- func (q *QQRobot) GetAttachment() *dto.MessageAttachment
- func (q *QQRobot) PostRichMediaMessage(data []byte, content string) error
- func (q *QQRobot) PostStreamMessage(state, idx int32, id, content string) (string, error)
- func (q *QQRobot) UploadFile(imageContent string, fileType int) ([]byte, error)
- type RawMessage
- type Robot
- type RobotController
- type RobotInfo
- func (r *RobotInfo) AddUserInfo() bool
- func (r *RobotInfo) CreatePhoto(prompt string, lastImageContent []byte) ([]byte, int, error)
- func (r *RobotInfo) CreateVideo(prompt string, lastImageContent []byte) ([]byte, int, error)
- func (r *RobotInfo) Exec()
- func (r *RobotInfo) ExecChain(msgContent string, msgChan *MsgChan)
- func (r *RobotInfo) ExecCmd(cmd string, defaultFunc func(), modeFunc func(string), typesFunc func(string))
- func (r *RobotInfo) ExecLLM(msgContent string, msgChan *MsgChan)
- func (r *RobotInfo) GetAudioContent(audioContent []byte) (string, error)
- func (r *RobotInfo) GetChatIdAndMsgIdAndUserID() (string, string, string)
- func (r *RobotInfo) GetLastImageContent() ([]byte, error)
- func (r *RobotInfo) GetVoiceBaseTTS(content, encoding string) ([]byte, int, error)
- func (r *RobotInfo) HandleUpdate(messageChan *MsgChan, encoding string)
- func (r *RobotInfo) InsertCron(cron, prompt string) error
- func (r *RobotInfo) InsertRecord()
- func (r *RobotInfo) SendMarkdownMsg(msg *param.MsgInfo)
- func (r *RobotInfo) SendMsg(chatId string, msgContent string, replyToMessageID string, mode string, ...) string
- func (r *RobotInfo) TalkingPreCheck(f func())
- type RobotModel
- type SenderInfo
- type SlackRobot
- type SmartModeResult
- type StreamRobot
- type TelegramRobot
- type TencentWechatMessage
- type TextElement
- type UploadFileRequest
- type VolDialog
- type Web
- type WechatRobot
Constants ¶
View Source
const (
AudioMsgLen = 600
)
Variables ¶
View Source
var ( BotName string LarkBotClient *lark.Client )
View Source
var ( QQApi openapi.OpenAPI QQTokenSource oauth2.TokenSource QQRobotInfo *dto.User )
View Source
var ( RobotControl = new(RobotController) TencentMsgMap sync.Map )
View Source
var (
ComWechatApp *work.Work
)
View Source
var (
Cron *cron.Cron
)
View Source
var (
DingBotClient *client.StreamClient
)
View Source
var (
DiscordSession *discordgo.Session
)
View Source
var (
OfficialAccountApp *officialAccount.OfficialAccount
)
View Source
var (
SlackClient *slack.Client
)
View Source
var TelegramBot *tgbotapi.BotAPI
Functions ¶
func C2CMessageEventHandler ¶ added in v1.0.19
func C2CMessageEventHandler(event *dto.WSPayload, message *dto.WSC2CMessageData) error
func CloseTalk ¶ added in v1.0.25
func CloseTalk(vc *discordgo.VoiceConnection)
func ExecComWechat ¶ added in v1.0.35
func ExecPersonalQQ ¶ added in v1.0.35
func ExecTelegram ¶ added in v1.0.35
func ExecWechat ¶ added in v1.0.35
func ForceReply ¶ added in v1.0.24
func GetMarkdownContent ¶
func LarkMessageHandler ¶
func LarkMessageHandler(ctx context.Context, message *larkim.P2MessageReceiveV1) error
func OnChatReceive ¶
func ParseCommand ¶
ParseCommand extracts command and arguments like /photo xxx
func QQATMessageEventHandler ¶ added in v1.0.19
func QQATMessageEventHandler(event *dto.WSPayload, atMessage *dto.WSATMessageData) error
func QQGroupATMessageEventHandler ¶ added in v1.0.19
func QQGroupATMessageEventHandler(event *dto.WSPayload, atMessage *dto.WSGroupATMessageData) error
func SlackButtonHandler ¶
func SlackButtonHandler(callback *slack.InteractionCallback)
func SlackCmdHandler ¶
func SlackCmdHandler(command *slack.SlashCommand)
func SlackMessageHandler ¶
func SlackMessageHandler(message *slackevents.MessageEvent)
func StartComWechatRobot ¶
func StartDingRobot ¶
func StartDiscordRobot ¶
func StartLarkRobot ¶
func StartQQRobot ¶ added in v1.0.19
func StartRobot ¶
func StartRobot()
func StartSlackRobot ¶
func StartTelegramRobot ¶
StartTelegramRobot start listen robot callback
func StartWechatRobot ¶ added in v1.0.19
func StartWechatRobot()
func WechatMsgSent ¶ added in v1.0.19
func WechatMsgSent(msgId string)
func WithContext ¶ added in v1.0.27
func WithSkipCheck ¶ added in v1.0.34
func WithUseRecord ¶ added in v1.0.35
Types ¶
type AccessToken ¶
type ComWechatRobot ¶
type ComWechatRobot struct {
Event contract.EventInterface
Robot *RobotInfo
App *work.Work
Command string
Prompt string
OriginPrompt string
ImageContent []byte
VoiceContent []byte
TextMsg *serverModel.MessageText
VoiceMsg *serverModel.MessageVoice
ImageMsg *serverModel.MessageImage
UserName string
}
func NewComWechatRobot ¶
func NewComWechatRobot(event contract.EventInterface) *ComWechatRobot
type DingRobot ¶
type DingRobot struct {
Robot *RobotInfo
Client *client.StreamClient
Message *chatbot.BotCallbackDataModel
Command string
Prompt string
BotName string
OriginPrompt string
ImageContent []byte
AudioContent []byte
UserName string
}
func NewDingRobot ¶
func NewDingRobot(message *chatbot.BotCallbackDataModel) *DingRobot
func (*DingRobot) CreateDingAuthClient ¶
func (d *DingRobot) CreateDingAuthClient() (_result *dingtalkoauth2.Client, _err error)
func (*DingRobot) CreateDingInteractClient ¶
func (d *DingRobot) CreateDingInteractClient() (_result *dingtalkaiinteraction.Client, _err error)
func (*DingRobot) CreateDingRobotClient ¶
func (d *DingRobot) CreateDingRobotClient() (result *dingtalkrobot.Client, err error)
func (*DingRobot) GetAccessToken ¶
func (*DingRobot) GetImageContent ¶
func (*DingRobot) GetMessageContent ¶
func (*DingRobot) ReplyMessage ¶
func (*DingRobot) SimpleReplyMarkdown ¶
func (*DingRobot) UploadFileWithType ¶
func (*DingRobot) VideoReplyMarkdown ¶
type DiscordRobot ¶
type DiscordRobot struct {
Session *discordgo.Session
Msg *discordgo.MessageCreate
Inter *discordgo.InteractionCreate
Robot *RobotInfo
Prompt string
Command string
ImageContent []byte
AudioContent []byte
UserName string
}
func NewDiscordRobot ¶
func NewDiscordRobot(s *discordgo.Session, msg *discordgo.MessageCreate, i *discordgo.InteractionCreate) *DiscordRobot
func (*DiscordRobot) PlayAudioToDiscord ¶ added in v1.0.25
func (d *DiscordRobot) PlayAudioToDiscord(vc *discordgo.VoiceConnection)
func (*DiscordRobot) Talk ¶ added in v1.0.25
func (d *DiscordRobot) Talk()
type Element ¶ added in v1.0.31
type Element struct {
ElementID string `json:"elementId"`
ElementType int `json:"elementType"`
TextElement *TextElement `json:"textElement,omitempty"`
}
type LarkRobot ¶
type LarkRobot struct {
Message *larkim.P2MessageReceiveV1
Robot *RobotInfo
Client *lark.Client
Command string
Prompt string
BotName string
ImageContent []byte
AudioContent []byte
UserName string
}
func NewLarkRobot ¶
func NewLarkRobot(message *larkim.P2MessageReceiveV1) *LarkRobot
func (*LarkRobot) GetMessageContent ¶
type MessageItem ¶ added in v1.0.31
type MessageItem struct {
Data MessageItemData `json:"data"`
Type string `json:"type"`
}
type MessageItemData ¶ added in v1.0.34
type MessagePostContent ¶
type MessagePostContent struct {
Title string `json:"title"`
Content [][]MessagePostElement `json:"content"`
}
type MessagePostElement ¶
type MessagePostMarkdown ¶
type MessagePostMarkdown struct {
Text string `json:"text,omitempty"`
}
func (*MessagePostMarkdown) IsPost ¶
func (m *MessagePostMarkdown) IsPost()
func (*MessagePostMarkdown) MarshalJSON ¶
func (m *MessagePostMarkdown) MarshalJSON() ([]byte, error)
func (*MessagePostMarkdown) Tag ¶
func (m *MessagePostMarkdown) Tag() string
type MessageText ¶
type MessageText struct {
Text string `json:"text"`
}
type OneBotResult ¶ added in v1.0.32
type PersonalQQRobot ¶ added in v1.0.31
type PersonalQQRobot struct {
Msg *QQMessage
Robot *RobotInfo
Ctx context.Context
Command string
Prompt string
OriginPrompt string
ImageContent []byte
AudioContent []byte
UserName string
}
func NewPersonalQQRobot ¶ added in v1.0.31
func NewPersonalQQRobot(ctx context.Context, msgContent []byte) *PersonalQQRobot
func (*PersonalQQRobot) GetMessageContent ¶ added in v1.0.31
func (q *PersonalQQRobot) GetMessageContent() (bool, error)
type QQMessage ¶ added in v1.0.31
type QQMessage struct {
Font int `json:"font"`
GroupId string `json:"group_id"`
Message []MessageItem `json:"message"`
MessageFormat string `json:"message_format"`
MessageID string `json:"message_id"`
MessageSeq int64 `json:"message_seq"`
MessageType string `json:"message_type"`
PostType string `json:"post_type"`
Raw RawMessage `json:"raw"`
RawMessage string `json:"raw_message"`
RealID int64 `json:"real_id"`
RealSeq string `json:"real_seq"`
SelfID string `json:"self_id"`
Sender SenderInfo `json:"sender"`
SubType string `json:"sub_type"`
TargetID int64 `json:"target_id"`
Time int64 `json:"time"`
UserID string `json:"user_id"`
}
type QQRobot ¶ added in v1.0.19
type QQRobot struct {
Robot *RobotInfo
QQApi openapi.OpenAPI
QQTokenSource oauth2.TokenSource
RobotInfo *dto.User
C2CMessage *dto.WSC2CMessageData
GroupAtMessage *dto.WSGroupATMessageData
ATMessage *dto.WSATMessageData
Command string
Prompt string
BotName string
OriginPrompt string
ImageContent []byte
AudioContent []byte
UserName string
}
func NewQQRobot ¶ added in v1.0.19
func NewQQRobot(c2cMessage *dto.WSC2CMessageData, atGroupMessage *dto.WSGroupATMessageData, atMessage *dto.WSATMessageData) *QQRobot
func (*QQRobot) GetAttachment ¶ added in v1.0.19
func (q *QQRobot) GetAttachment() *dto.MessageAttachment
func (*QQRobot) PostRichMediaMessage ¶ added in v1.0.19
func (*QQRobot) PostStreamMessage ¶ added in v1.0.19
type RawMessage ¶ added in v1.0.31
type RawMessage struct {
ID int64 `json:"id"`
MsgID string `json:"msgId"`
MsgSeq string `json:"msgSeq"`
MsgTime string `json:"msgTime"`
MsgType int `json:"msgType"`
SubMsgType int `json:"subMsgType"`
PeerUin string `json:"peerUin"`
SenderUin string `json:"senderUin"`
SenderUid string `json:"senderUid"`
PeerUid string `json:"peerUid"`
ClientSeq string `json:"clientSeq"`
MsgRandom string `json:"msgRandom"`
SendStatus int `json:"sendStatus"`
SendType int `json:"sendType"`
ChatType int `json:"chatType"`
IsOnlineMsg bool `json:"isOnlineMsg"`
IsImportMsg bool `json:"isImportMsg"`
SourceType int `json:"sourceType"`
FromAppID string `json:"fromAppid"`
FromUid string `json:"fromUid"`
PeerName string `json:"peerName"`
SendNickName string `json:"sendNickName"`
SendMemberName string `json:"sendMemberName"`
SendRemarkName string `json:"sendRemarkName"`
Elements []Element `json:"elements"`
}
RawMessage 部分嵌套字段很多,以下是主要结构(可按需精简)
type RobotController ¶
type RobotController struct {
Cancel context.CancelFunc
}
type RobotInfo ¶
type RobotInfo struct {
Ctx context.Context
Cancel context.CancelFunc
Robot Robot
// contains filtered or unexported fields
}
func (*RobotInfo) AddUserInfo ¶ added in v1.0.31
func (*RobotInfo) CreatePhoto ¶ added in v1.0.23
func (*RobotInfo) CreateVideo ¶ added in v1.0.23
func (*RobotInfo) GetAudioContent ¶
func (*RobotInfo) GetChatIdAndMsgIdAndUserID ¶
func (*RobotInfo) GetLastImageContent ¶
func (*RobotInfo) GetVoiceBaseTTS ¶ added in v1.0.24
func (*RobotInfo) HandleUpdate ¶ added in v1.0.25
func (*RobotInfo) InsertCron ¶ added in v1.0.35
func (*RobotInfo) InsertRecord ¶ added in v1.0.24
func (r *RobotInfo) InsertRecord()
func (*RobotInfo) SendMarkdownMsg ¶ added in v1.0.37
func (*RobotInfo) TalkingPreCheck ¶
func (r *RobotInfo) TalkingPreCheck(f func())
type RobotModel ¶ added in v1.0.31
type SenderInfo ¶ added in v1.0.31
type SlackRobot ¶
type SlackRobot struct {
Event *slackevents.MessageEvent
CmdEvent *slack.SlashCommand
Callback *slack.InteractionCallback
Robot *RobotInfo
Client *slack.Client
Command string
Prompt string
BotName string
ImageContent []byte
VoiceContent []byte
UserName string
}
func NewSlackRobot ¶
func NewSlackRobot(message *slackevents.MessageEvent, command *slack.SlashCommand, callback *slack.InteractionCallback) *SlackRobot
type SmartModeResult ¶ added in v1.0.32
type StreamRobot ¶ added in v1.0.38
type StreamRobot interface {
// contains filtered or unexported methods
}
type TelegramRobot ¶
type TelegramRobot struct {
Update tgbotapi.Update
Bot *tgbotapi.BotAPI
Robot *RobotInfo
Prompt string
Command string
ImageContent []byte
AudioContent []byte
UserName string
}
func NewTelegramRobot ¶
func NewTelegramRobot(update tgbotapi.Update, bot *tgbotapi.BotAPI) *TelegramRobot
func (*TelegramRobot) ExecuteForceReply ¶
func (t *TelegramRobot) ExecuteForceReply()
ExecuteForceReply use force reply interact with user
func (*TelegramRobot) GetAudioContent ¶
func (t *TelegramRobot) GetAudioContent() []byte
func (*TelegramRobot) GetPhotoContent ¶
func (t *TelegramRobot) GetPhotoContent() []byte
type TencentWechatMessage ¶ added in v1.0.22
type TextElement ¶ added in v1.0.31
type TextElement struct {
Content string `json:"content"`
}
type UploadFileRequest ¶ added in v1.0.19
type Web ¶
type Web struct {
Command string
UserId int64
RealUserId string
Prompt string
ImageContent []byte
AudioContent []byte
OriginalPrompt string
W http.ResponseWriter
Flusher http.Flusher
Robot *RobotInfo
// contains filtered or unexported fields
}
func (*Web) AddUserInfo ¶ added in v1.0.31
func (*Web) InsertRecord ¶ added in v1.0.24
func (web *Web) InsertRecord()
type WechatRobot ¶ added in v1.0.19
type WechatRobot struct {
Event contract.EventInterface
Robot *RobotInfo
App *officialAccount.OfficialAccount
Command string
Prompt string
OriginPrompt string
ImageContent []byte
VoiceContent []byte
TextMsg *serverModel.MessageText
VoiceMsg *serverModel.MessageVoice
ImageMsg *serverModel.MessageImage
UserName string
}
func NewWechatRobot ¶ added in v1.0.19
func NewWechatRobot(event contract.EventInterface) (*WechatRobot, bool)
func (*WechatRobot) GetLLMContent ¶ added in v1.0.19
func (w *WechatRobot) GetLLMContent() interface{}
Click to show internal directories.
Click to hide internal directories.