handler

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2024 License: MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxHFSteps      = 20
	MaxNum          = 9
	DefaultCfgScale = 9
	DefaultSteps    = 20
	DefaultNum      = 1
)
View Source
const (
	T_Prohibit permissions = iota
	T_Guest
	T_Subscribe
)
View Source
const (
	GuestImgMaxSize = 737280
)
View Source
const MAXONEPAGEOBJ = MAXROW * 7
View Source
const MAXROW = 3

Variables

View Source
var AllMode = [...]string{"DPM++ 2M Karras", "DPM++ 2M SDE Karras", "DPM++ SDE Karras", "Euler a", "DPM2", "DPM adaptive", "DPM2 a Karras", "DPM2 Karras", "DPM++ 2M", "DPM++ 2S a", "DPM++ 2S a Karras", "DPM++ SDE", "LMS Karras", "Euler", "DDIM", "Heun", "UniPC"}
View Source
var Ucmap = map[string]string{
	"low quality": "cropped, worst quality, low quality, normal quality, jpeg artifacts, signature, watermark, username, blurry",
	"bad anatomy": "bad anatomy, bad hands, error, missing fingers, extra digit, fewer digits",
}

Functions

func DefauleUC added in v0.2.3

func DefauleUC() string

func ReplaceColon added in v0.2.3

func ReplaceColon(s string) string

func ReplaceString added in v0.2.3

func ReplaceString(src string) string

Types

type ConfigFunc added in v0.2.0

type ConfigFunc func(h *Handler)

func WithCache added in v0.2.0

func WithCache(cache cache.Cache) ConfigFunc

func WithDefaultCfgScale added in v0.2.3

func WithDefaultCfgScale(DefaultCfgScale int) ConfigFunc

func WithDefaultNum added in v0.2.3

func WithDefaultNum(DefaultNum int) ConfigFunc

func WithDefaultSteps added in v0.2.3

func WithDefaultSteps(DefaultSteps int) ConfigFunc

func WithDefaultUC added in v0.2.3

func WithDefaultUC(DefaultUC string) ConfigFunc

func WithExtraModel added in v0.2.3

func WithExtraModel(ExtraModel []gconfig.ExtraModel) ConfigFunc

func WithGroup added in v0.2.3

func WithGroup(Group string) ConfigFunc

func WithGuide added in v0.2.3

func WithGuide(Guide string) ConfigFunc

func WithImgMaxSize added in v0.2.3

func WithImgMaxSize(ImgMaxSize int) ConfigFunc

func WithMaxHFSteps added in v0.2.3

func WithMaxHFSteps(MaxHFSteps int) ConfigFunc

func WithMaxNum added in v0.2.3

func WithMaxNum(MaxNum int) ConfigFunc

func WithModels added in v0.2.3

func WithModels(models []gconfig.Model) ConfigFunc

func WithModes added in v0.2.3

func WithModes(mode []string) ConfigFunc

func WithOwnerID added in v0.2.0

func WithOwnerID(id int64) ConfigFunc

func WithWebhook added in v0.2.0

func WithWebhook(webhookHost string) ConfigFunc

https only

type ConfigFuncCorrentCfg added in v0.2.3

type ConfigFuncCorrentCfg func(*CorrectConfig)

func WithCtrlPhoto added in v0.2.3

func WithCtrlPhoto() ConfigFuncCorrentCfg

func WithMode added in v0.2.3

func WithMode() ConfigFuncCorrentCfg

func WithModel added in v0.2.3

func WithModel() ConfigFuncCorrentCfg

func WithSeed added in v0.2.3

func WithSeed() ConfigFuncCorrentCfg

func WithStrength added in v0.2.3

func WithStrength() ConfigFuncCorrentCfg

func WithTag added in v0.2.3

func WithTag() ConfigFuncCorrentCfg

func WithTransTag added in v0.2.3

func WithTransTag() ConfigFuncCorrentCfg

func WithTransUc added in v0.2.3

func WithTransUc() ConfigFuncCorrentCfg

func WithUc added in v0.2.3

func WithUc() ConfigFuncCorrentCfg

type CorrectConfig added in v0.2.3

type CorrectConfig struct {
	Tag       bool
	Uc        bool
	Strength  bool
	CtrlPhoto bool
	TransTag  bool
	TransUc   bool
	Seed      bool
	Mode      bool
	Model     bool
}

type Handler added in v0.2.0

type Handler struct {
	Api         *api.API
	DB          *db.DB
	UserHandler *UserHandler

	Models                                                                    []gconfig.Model
	MaxHFSteps, MaxNum, DefaultCfgScale, DefaultSteps, DefaultNum, ImgMaxSize int
	DefaultUC, DefaultMode                                                    string
	ControlPreProcess                                                         []gconfig.ControlPreProcess
	ControlProcess                                                            []gconfig.ControlProcess
	ExtraModel                                                                []gconfig.ExtraModel

	ExtraModelAllGroup []string
	// contains filtered or unexported fields
}

func New added in v0.2.0

func New(tgToken string, api *api.API, db *db.DB, configs ...ConfigFunc) (*Handler, error)

func (*Handler) Bot added in v0.2.0

func (h *Handler) Bot() *tgbotapi.BotAPI

func (*Handler) Cache added in v0.2.0

func (h *Handler) Cache() cache.Cache

func (*Handler) CorrectCfg added in v0.2.3

func (h *Handler) CorrectCfg(cfg *db.Config, u *UserInfo, c ...ConfigFuncCorrentCfg)

func (*Handler) DefaultConfig added in v0.2.3

func (h *Handler) DefaultConfig() *db.Config

func (*Handler) GroupIndex2ExtraModels added in v0.2.3

func (h *Handler) GroupIndex2ExtraModels(groupIndex int) []gconfig.ExtraModel

func (*Handler) HandleCallback added in v0.2.0

func (h *Handler) HandleCallback(CallbackQuery *tgbotapi.CallbackQuery)

func (*Handler) HandleCmd added in v0.2.0

func (h *Handler) HandleCmd(Message tgbotapi.Message)

func (*Handler) HandleMsg added in v0.2.0

func (h *Handler) HandleMsg(Message *tgbotapi.Message)

func (*Handler) Index2ExtraModel added in v0.2.3

func (h *Handler) Index2ExtraModel(GroupIndex, LoraIndex int) gconfig.ExtraModel

func (*Handler) MODELFILETONAME added in v0.2.3

func (h *Handler) MODELFILETONAME(file string) (string, error)

func (*Handler) Name2Model added in v0.2.3

func (h *Handler) Name2Model(name string) (gconfig.Model, error)

func (*Handler) Name2Process added in v0.2.3

func (h *Handler) Name2Process(name string) (gconfig.ControlProcess, error)

func (*Handler) NewDrawConfig added in v0.2.3

func (h *Handler) NewDrawConfig(cfg *db.Config, initPhoto, ControlPhoto []byte) *api.Config

func (*Handler) ParseCfgScalse added in v0.2.3

func (h *Handler) ParseCfgScalse(scale int) int

func (*Handler) ParseNum added in v0.2.3

func (h *Handler) ParseNum(num int) int

func (*Handler) ParsePreProcess added in v0.2.3

func (h *Handler) ParsePreProcess(PreProcess string) string

func (*Handler) ParseProcess added in v0.2.3

func (h *Handler) ParseProcess(Process string) string

func (*Handler) ParseSteps added in v0.2.3

func (h *Handler) ParseSteps(steps int) int

func (*Handler) Run added in v0.2.0

func (h *Handler) Run(ctx context.Context)

func (*Handler) SetCommand added in v0.2.0

func (h *Handler) SetCommand()

func (*Handler) WebhookEnabled added in v0.2.0

func (h *Handler) WebhookEnabled() bool

func (*Handler) WebhookHandler added in v0.2.0

func (h *Handler) WebhookHandler() func(w http.ResponseWriter, r *http.Request)

only Enable Webhook

func (*Handler) WebhookUriPath added in v0.2.0

func (h *Handler) WebhookUriPath() string

type Task added in v0.2.3

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

func GetTask added in v0.2.3

func GetTask(userID int64, types TaskType) (*Task, error)

func (*Task) Down added in v0.2.3

func (task *Task) Down()

func (*Task) ID added in v0.2.3

func (task *Task) ID() int64

func (*Task) Set added in v0.2.3

func (t *Task) Set(key string, value any)

func (*Task) Type added in v0.2.3

func (task *Task) Type() TaskType

func (*Task) Value added in v0.2.3

func (t *Task) Value(key string) any

type TaskType added in v0.2.3

type TaskType uint
const (
	T_Draw TaskType = iota
	T_GuessTag
	T_CtrlPhoto
	T_SuperResolution
)

type UserHandler added in v0.2.3

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

func NewUserHandler added in v0.2.3

func NewUserHandler(handler *Handler, db *gorm.DB) *UserHandler

func (*UserHandler) LoadAndInitUser added in v0.2.3

func (uh *UserHandler) LoadAndInitUser(bot *tgbotapi.BotAPI, userID int64) (u *UserInfo, err error)

func (*UserHandler) LoadUser added in v0.2.3

func (uh *UserHandler) LoadUser(bot *tgbotapi.BotAPI, userID int64) (u *UserInfo, err error)

type UserInfo added in v0.2.3

type UserInfo struct {
	UserInfo   *db.UserInfo
	Subscribe  *db.Subscribe
	ChatMember *tgbotapi.ChatMember
	LastUpdate time.Time
	// contains filtered or unexported fields
}

func (*UserInfo) AddTask added in v0.2.3

func (u *UserInfo) AddTask(types TaskType) (*Task, error)

func (*UserInfo) ChangeDefaultMODE added in v0.2.3

func (u *UserInfo) ChangeDefaultMODE(mode string) error

func (*UserInfo) ChangeDefaultNumber added in v0.2.3

func (u *UserInfo) ChangeDefaultNumber(num int) error

func (*UserInfo) ChangeDefaultScale added in v0.2.3

func (u *UserInfo) ChangeDefaultScale(scale int) error

func (*UserInfo) ChangeDefaultSteps added in v0.2.3

func (u *UserInfo) ChangeDefaultSteps(steps int) error

func (*UserInfo) ChangeDefaultUC added in v0.2.3

func (u *UserInfo) ChangeDefaultUC(uc string) error

func (*UserInfo) ChangeShare added in v0.2.3

func (u *UserInfo) ChangeShare(share bool) error

func (*UserInfo) DefaultConfig added in v0.2.3

func (u *UserInfo) DefaultConfig() *db.Config

func (*UserInfo) LoadExtraLang added in v0.2.3

func (u *UserInfo) LoadExtraLang(tag string) string

func (*UserInfo) LoadLang added in v0.2.3

func (u *UserInfo) LoadLang(tag string) string

func (*UserInfo) Passwd added in v0.2.3

func (u *UserInfo) Passwd() string

userID -> passwd

func (*UserInfo) Permissions added in v0.2.3

func (u *UserInfo) Permissions() permissions

func (*UserInfo) ProhibitString added in v0.2.3

func (u *UserInfo) ProhibitString(bot *tgbotapi.BotAPI) string

func (*UserInfo) SetLang added in v0.2.3

func (u *UserInfo) SetLang(langType string) error

func (*UserInfo) UseFree added in v0.2.3

func (u *UserInfo) UseFree(n int)

Jump to

Keyboard shortcuts

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