store

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2024 License: BSD-2-Clause Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatusWaitingToStart Status = "Waiting to start"
	StatusJobQueued      Status = "Job queued"
	StatusProcessing     Status = "Processing"
	StatusComplete       Status = "Complete"
	StatusUnknown        Status = "Unknown"

	FourBoxGrid = "FourBoxGrid"
	PU          = "PU"
	DN          = "DN"
	Unknown     = "Unknown"

	TypeImagine         = "Imagine"
	TypeUpscale         = "Upscale"
	TypeUpscaleXTwo     = "UpscaleXTwo"
	TypeReroll          = "Reroll"
	TypeBlend           = "Blend"
	TypeUpscaleXFour    = "UpscaleXFour"
	TypeVariation       = "Variation"
	TypeVariationStrong = "VariationStrong"
	TypeVariationSubtle = "VariationSubtle"
	TypeVariationRegion = "VariationRegion"
	TypePanUp           = "PanUp"
	TypePanRight        = "PanRight"
	TypePanLeft         = "PanLeft"
	TypePanDown         = "PanDown"
	TypePicReader       = "PicReader"
	TypeZoomOutOneX     = "ZoomOutOneX"
	TypeZoomOutTwoX     = "ZoomOutTwoX"
	TypeUnknown         = "Unknown"

	TypeUpscaleKey         = "Upscale"
	TypeUpscaleXFourKey    = "UpscaleXFour"
	TypeUpscaleXTwoKey     = "UpscaleXTwo"
	TypeUpscaleSubtleKey   = "UpscaleSubtle"
	TypeUpscaleCreativeKey = "UpscaleCreative"
	TypeVariationKey       = "Variation"
	TypeVariationStrongKey = "VariationStrong"
	TypeVariationSubtleKey = "VariationSubtle"
	TypeVariationRegionKey = "VariationRegion"
	TypeRerollKey          = "Reroll"
	TypePanUpKey           = "PanUp"
	TypePanRightKey        = "PanRight"
	TypePanLeftKey         = "PanLeft"
	TypePanDownKey         = "PanDown"
	TypePicReaderKey       = "PicReader"
	TypePicReadRetryKey    = "PicReadRetry"
	TypeZoomOutOneXKey     = "ZoomOutOneX"
	TypeZoomOutTwoXKey     = "ZoomOutTwoX"
	TemporaryKey           = "Temporary"

	AdvancedKey   = "advanced"
	PanParamUp    = "pan_up"
	PanParamRight = "pan_right"
	PanParamLeft  = "pan_left"
	PanParamDown  = "pan_down"

	DimensionPortrait  = "portrait"
	DimensionLandscape = "landscape"

	DrmMidjourneyCaptcha               = `drm:midjourney_server`
	Expired              time.Duration = 3 * 24 * time.Hour
	TemporaryExpired     time.Duration = 30 * time.Minute

	ImageStart           = `\*\*(.*?)\*\* - <@\d+> \((.*?)\)`
	UpscaleRun           = `\*\*(.*?)\*\* - Image #(\d+) <@\d+>`
	UpscaleStart         = `Upscaling image #(\d+)`
	UpscaleMultipleStart = `\*\*(.*?)\*\* - Upscaled \((.*?)\) by <@\d+> \((.*?)\)`
	VariationRun         = `\*\*(.*?)\*\* - Variations by <@\d+> \((.*?)\)`
	VariationStart       = `Making variations for image #(\d+)`
)

Variables

This section is empty.

Functions

func CreateKey

func CreateKey(items ...string) string

func CreateKeysOfZoomAndUp

func CreateKeysOfZoomAndUp(id string) []string

func ExtractURLsFromString

func ExtractURLsFromString(input string) []string

func GetFinalURL

func GetFinalURL(url string) (string, error)

func GetKey

func GetKey(s string) string

func SplitKey

func SplitKey(key string) []string

Types

type CompleteInfo

type CompleteInfo struct {
	ID          string
	Attachments []map[string]any
}

type Config

type Config struct {
	Redis Redis
}

type Error

type Error struct {
	Code api.Codes
	Msg  string
}

func (Error) Error

func (e Error) Error() string

type Key

type Key string

type MetaData

type MetaData struct {
	ID                  string `redis:"id"`
	Prompt              string `redis:"prompt"`
	Type                string `redis:"type"`
	Status              Status `redis:"status"`
	ProcessRate         string `redis:"process_rate"`
	Attachments         string `redis:"attachments"`
	StartTime           int64  `redis:"start_time"`
	CompleteTime        int64  `redis:"complete_time"`
	Webhook             string `redis:"webhook"`
	CompleteMessageID   string `redis:"complete_message_id"`
	Mode                string `redis:"mode"`
	RequestId           string `redis:"request_id"`
	IsQuadrilateralGrid string `redis:"is_quadrilateral_grid"`
	MemberId            string `redis:"member_id"`
}

func (*MetaData) GetImageURL

func (md *MetaData) GetImageURL() (string, error)

type Redis

type Redis struct {
	Address  string
	Password string
}

type Status

type Status string

type Store

type Store struct {
	*redis.Client
}

func NewStore

func NewStore(config *Config) *Store

func (*Store) CheckPrompt

func (s *Store) CheckPrompt(ctx context.Context, prompt string) error

func (*Store) CheckStatusByKey

func (s *Store) CheckStatusByKey(ctx context.Context, key string) (bool, error)

func (*Store) CompleteTask

func (s *Store) CompleteTask(ipAddress string)

完成任务恢复并发数

func (*Store) GetID

func (s *Store) GetID(ctx context.Context, key string) (string, error)

func (*Store) GetMetaData

func (s *Store) GetMetaData(ctx context.Context, id string) (*MetaData, error)

func (*Store) GetType

func (s *Store) GetType(ctx context.Context, key string) (isQuadrilateralGrid, mjType string, err error)

通过referenced_message_id反向查询对应的类型

func (*Store) GetZoomOutKey

func (s *Store) GetZoomOutKey(ctx context.Context, msgId string) (string, error)

func (*Store) SaveMeta

func (s *Store) SaveMeta(
	ctx context.Context,
	key,
	id,
	typ,
	prompt string,
	status Status,
	start_time int64,
) error

func (*Store) SaveWebhook

func (s *Store) SaveWebhook(ctx context.Context, id, webhook, reqId, memberId string) error

func (*Store) SaveWithComplete

func (s *Store) SaveWithComplete(ctx context.Context, completeMessageID, quadrilateralGrid, prompt, key, mode, attachments, ipAddress string, webhookFunc func(*MetaData)) error

func (*Store) UpdateProcessRate

func (s *Store) UpdateProcessRate(ctx context.Context, id, processRate string, attachments string, webhookFunc func(*MetaData)) error

type Type

type Type string

Jump to

Keyboard shortcuts

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