Documentation ¶
Index ¶
- Constants
- Variables
- func BotRun(config *entity.ConfigMidjourney) (err error)
- func CustomIdImage(ctx context.Context, tx *gdb.TX, params *CustomIdImageParams) (err error)
- func CustomIdModalImage(params *CustomIdModalImageParams) (err error)
- func GenerateImage(ctx context.Context, tx *gdb.TX, params *GenerateImageParams) (err error)
- func WsRun(config *entity.ConfigMidjourney, callback WsRunConnCallback) (err error)
- type BotClient
- type CustomIdData
- type CustomIdImageParams
- type CustomIdModalData
- type CustomIdModalDataComponentsItem
- type CustomIdModalDataComponentsItemComponentsItem
- type CustomIdModalImageParams
- type DSApplicationCommand
- type DSCommand
- type DSCommandOption
- type DSOption
- type GenerateImageParams
- type MidjourneyClient
- type QueueClient
- type QueueEvent
- type QueueEventMessage
- type QueueTask
- type ReqCommandAttachments
- type ReqCustomIdDiscord
- type ReqCustomIdModalDiscord
- type ReqTriggerDiscord
- type VerifyHuman
- type WsClient
- type WsMessage
- type WsMessageAuth
- type WsMessageAuthProperties
- type WsReceiveMessage
- type WsReceiveMessageDAttachmentsItem
- type WsReceiveMessageDAuthor
- type WsReceiveMessageDCommon
- type WsReceiveMessageDComponentsItem
- type WsReceiveMessageDComponentsItemComponentsItem
- type WsReceiveMessageDComponentsItemComponentsItemEmoji
- type WsReceiveMessageDEmbedsItem
- type WsReceiveMessageDEmbedsItemImage
- type WsReceiveMessageDInteraction
- type WsReceiveMessageDReady
- type WsReceiveMessageDReadyUser
- type WsReceiveMessageDReferencedMessage
- type WsRunConnCallback
Constants ¶
View Source
const ( MJApplicationId = "936929561302675456" // Midjourney在Discord的应用Id MJVersionId = "1166847114203123795" MJCommandGenerateImageId = "938956540159881230" MJCommandGenerateImageDescription = "Create images with Midjourney" )
View Source
const ( NJApplicationId = "1022952195194359889" // Niji在Discord的应用 NJVersionId = "1166842163141816443" NJCommandGenerateImageId = "1023054140580057099" NJCommandGenerateImageDescription = "Create images with Niji journey" )
View Source
const ( MessageTypeGenerate = 0 // 生图 MessageTypeCustomId = 19 // CustomId MessageTypeModal = 20 // CustomId )
View Source
const ( RequestTypeGenerate = 2 // 生图 RequestTypeCustomId = 3 // CustomId RequestTypeModal = 5 // Modal )
View Source
const ApiUrl = "https://discord.com/api/v9/"
ID
View Source
const WsUrl = "wss://gateway.discord.gg/?encoding=json&v=9"
Variables ¶
View Source
var BotClientMap sync.Map
View Source
var WsClientMap sync.Map
Functions ¶
func BotRun ¶
func BotRun(config *entity.ConfigMidjourney) (err error)
func CustomIdImage ¶
CustomIdImage 组件处理图片
func CustomIdModalImage ¶
func CustomIdModalImage(params *CustomIdModalImageParams) (err error)
func GenerateImage ¶
GenerateImage 生成图片
func WsRun ¶
func WsRun(config *entity.ConfigMidjourney, callback WsRunConnCallback) (err error)
Types ¶
type BotClient ¶
type BotClient struct { Session *discordgo.Session Config *entity.ConfigMidjourney }
type CustomIdData ¶
type CustomIdImageParams ¶
type CustomIdModalData ¶
type CustomIdModalData struct { Id string `json:"id"` CustomId string `json:"custom_id"` Components []*CustomIdModalDataComponentsItem `json:"components"` }
type CustomIdModalDataComponentsItem ¶
type CustomIdModalDataComponentsItem struct { Type int64 `json:"type"` Components []*CustomIdModalDataComponentsItemComponentsItem `json:"components"` }
type DSApplicationCommand ¶
type DSApplicationCommand struct { Id string `json:"id"` ApplicationId string `json:"application_id"` Version string `json:"version"` DefaultPermission bool `json:"default_permission"` DefaultMemberPermissions map[string]int `json:"default_member_permissions"` Type int64 `json:"type"` Nsfw bool `json:"nsfw"` Name string `json:"name"` Description string `json:"description"` DmPermission bool `json:"dm_permission"` Options []*DSCommandOption `json:"options"` }
type DSCommand ¶
type DSCommand struct { Version string `json:"version"` Id string `json:"id"` Name string `json:"name"` Type int64 `json:"type"` Options []*DSOption `json:"options"` ApplicationCommand *DSApplicationCommand `json:"application_command"` Attachments []*ReqCommandAttachments `json:"attachments"` }
type DSCommandOption ¶
type GenerateImageParams ¶
type MidjourneyClient ¶
type MidjourneyClient struct { }
MidjourneyClient Midjourney客户端
func (*MidjourneyClient) GetConfig ¶
func (c *MidjourneyClient) GetConfig() (configData *entity.ConfigMidjourney, err error)
GetConfig 获取配置
type QueueClient ¶
type QueueClient struct { Event chan *QueueEvent // contains filtered or unexported fields }
QueueClient Queue客户端
func (*QueueClient) InsertTask ¶
func (q *QueueClient) InsertTask(queueData *entity.QueueMidjourney, callback func(signal int)) (err error)
func (*QueueClient) Run ¶
func (q *QueueClient) Run()
type QueueEvent ¶
type QueueEvent struct { EventType string Config *entity.ConfigMidjourney QueueData *entity.QueueMidjourney Message *QueueEventMessage }
type QueueEventMessage ¶
type QueueEventMessage = WsReceiveMessageDCommon
type QueueTask ¶
type QueueTask struct { Data *entity.QueueMidjourney // 队列数据,与数据库一致 StatusChannel chan int // 状态通道,用来监听任务执行进度情况 Config *entity.ConfigMidjourney // 任务对应的配置信息 防止重复查询所以单提出来 CallbackChannel chan int // 回调通道,用来监听任务完成执行回调方法的通道 }
type ReqCommandAttachments ¶
type ReqCustomIdDiscord ¶
type ReqCustomIdDiscord struct { Type int64 `json:"type"` GuildId string `json:"guild_id"` ChannelId string `json:"channel_id"` MessageFlags int64 `json:"message_flags"` MessageId string `json:"message_id"` ApplicationId string `json:"application_id"` SessionId string `json:"session_id"` Data *CustomIdData `json:"data"` Nonce string `json:"nonce"` }
type ReqCustomIdModalDiscord ¶
type ReqTriggerDiscord ¶
type VerifyHuman ¶
type VerifyHuman struct {
Config *entity.ConfigMidjourney
}
func NewVerifyHuman ¶
func NewVerifyHuman(config *entity.ConfigMidjourney) (v *VerifyHuman, err error)
type WsClient ¶
type WsClient struct { Client *ghttp.WebSocketClient Conn *websocket.Conn Config *entity.ConfigMidjourney UserId int64 SessionId string // contains filtered or unexported fields }
type WsMessageAuth ¶
type WsMessageAuth struct { Token string `json:"token"` Capabilities int `json:"capabilities"` Properties *WsMessageAuthProperties `json:"properties"` Compress bool `json:"compress"` }
type WsMessageAuthProperties ¶
type WsReceiveMessage ¶
type WsReceiveMessageDAuthor ¶
type WsReceiveMessageDCommon ¶
type WsReceiveMessageDCommon struct { Id string `json:"id"` ChannelId string `json:"channel_id"` GuildId string `json:"guild_id"` Type int `json:"type"` Author *WsReceiveMessageDAuthor `json:"author"` Nonce string `json:"nonce"` Content string `json:"content"` Flags int `json:"flags"` Components []*WsReceiveMessageDComponentsItem `json:"components"` Attachments []*discordgo.MessageAttachment `json:"attachments"` Embeds []*WsReceiveMessageDEmbedsItem `json:"embeds"` Interaction *WsReceiveMessageDInteraction `json:"interaction"` ReferencedMessage *WsReceiveMessageDReferencedMessage `json:"referenced_message"` MessageReference *discordgo.MessageReference `json:"message_reference"` }
type WsReceiveMessageDComponentsItem ¶
type WsReceiveMessageDComponentsItem struct { Type int `json:"type"` Components []*WsReceiveMessageDComponentsItemComponentsItem `json:"components"` }
type WsReceiveMessageDComponentsItemComponentsItem ¶
type WsReceiveMessageDComponentsItemComponentsItem struct { Type int `json:"type"` Style int `json:"style"` Label string `json:"label"` Emoji *WsReceiveMessageDComponentsItemComponentsItemEmoji `json:"emoji"` CustomId string `json:"custom_id"` }
type WsReceiveMessageDComponentsItemComponentsItemEmoji ¶
type WsReceiveMessageDComponentsItemComponentsItemEmoji struct {
Name string `json:"name"`
}
type WsReceiveMessageDEmbedsItem ¶
type WsReceiveMessageDEmbedsItem struct { Color int `json:"color"` Description string `json:"description"` Title string `json:"title"` Image *WsReceiveMessageDEmbedsItemImage `json:"image"` }
type WsReceiveMessageDEmbedsItemImage ¶
type WsReceiveMessageDEmbedsItemImage struct {
Url string `json:"url"`
}
type WsReceiveMessageDInteraction ¶
type WsReceiveMessageDInteraction struct { Id string `json:"id"` Name string `json:"name"` Type int `json:"type"` User *WsReceiveMessageDReadyUser `json:"user"` }
type WsReceiveMessageDReady ¶
type WsReceiveMessageDReady struct { User *WsReceiveMessageDReadyUser `json:"user"` SessionId string `json:"session_id"` }
type WsReceiveMessageDReadyUser ¶
type WsReceiveMessageDReadyUser struct {
Id string `json:"id"`
}
type WsReceiveMessageDReferencedMessage ¶
type WsReceiveMessageDReferencedMessage struct { Id string `json:"id"` ChannelId string `json:"channel_id"` Content string `json:"content"` Timestamp string `json:"timestamp"` Components []*WsReceiveMessageDComponentsItem `json:"components"` }
type WsRunConnCallback ¶
type WsRunConnCallback func()
Click to show internal directories.
Click to hide internal directories.