utils

package
v1.8.5 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2026 License: AGPL-3.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ArtworkHTMLCaption

func ArtworkHTMLCaption(artwork shared.ArtworkLike) string

func ArtworkInputMedias added in v1.5.0

func ArtworkInputMedias(
	ctx context.Context,
	serv *service.Service,
	meta *metautil.MetaData,
	artwork shared.ArtworkLike,
	caption string,
	items []MediaItem,
	start, end int,
) (*ioutil.Closer[[]telego.InputMedia], error)

ArtworkInputMedias creates input medias from MediaItems (supports mixed photos and videos)

func ArtworkPostKeyboard

func ArtworkPostKeyboard(meta *metautil.MetaData, cbId string) [][]telego.InlineKeyboardButton

func CheckPermissionForQuery

func CheckPermissionForQuery(ctx context.Context, serv *service.Service, query telego.CallbackQuery, permissions ...shared.Permission) bool

func CheckPermissionInGroup

func CheckPermissionInGroup(ctx context.Context, serv *service.Service, message telego.Message, permissions ...shared.Permission) bool

func EscapeHTML added in v1.8.1

func EscapeHTML(s string) string

https://core.telegram.org/bots/api#html-style

func FindSourceURLInMessage

func FindSourceURLInMessage(serv *service.Service, message *telego.Message) string

func GetMediaInputMedia added in v1.5.0

func GetMediaInputMedia(ctx context.Context,
	serv *service.Service,
	meta *metautil.MetaData,
	artwork shared.ArtworkLike,
	media shared.MediaLike) (*ioutil.Closer[telego.InputMedia], error)

MediaLike 转换为对应的 InputMedia

第一个 Media 意为 MediaLike, 第二个 Media 意为tg的 MediaInputFile

func GetMessagePhotoFile

func GetMessagePhotoFile(ctx *telegohandler.Context, message *telego.Message) ([]byte, error)

func GetMssageOriginChannel

func GetMssageOriginChannel(message *telego.Message) *telego.MessageOriginChannel

func GetPictureDocumentInputFile

func GetPictureDocumentInputFile(ctx context.Context, serv *service.Service, meta *metautil.MetaData, artwork shared.ArtworkLike, picture shared.PictureLike) (*ioutil.Closer[telego.InputFile], error)

func GetPicturePhotoInputFile

func GetPicturePhotoInputFile(ctx context.Context, serv *service.Service, meta *metautil.MetaData, picture shared.PictureLike) (*ioutil.Closer[telego.InputFile], error)

func GetPostedArtworkInlineKeyboardButton

func GetPostedArtworkInlineKeyboardButton(artwork *entity.Artwork, meta *metautil.MetaData) []telego.InlineKeyboardButton

func GetUgoiraVideoDocumentInputFile

func GetUgoiraVideoDocumentInputFile(ctx context.Context, serv *service.Service, meta *metautil.MetaData, artwork shared.ArtworkLike, ugoira shared.UgoiraMetaLike) (*ioutil.Closer[telego.InputFile], error)

func GetUgoiraVideoInputFile added in v1.5.0

func GetUgoiraVideoInputFile(ctx context.Context, serv *service.Service, meta *metautil.MetaData, ugoira shared.UgoiraMetaLike) (*ioutil.Closer[telego.InputFile], error)

func GetVideoDocumentInputFile added in v1.5.0

func GetVideoDocumentInputFile(ctx context.Context, serv *service.Service, meta *metautil.MetaData, artwork shared.ArtworkLike, video shared.VideoLike) (*ioutil.Closer[telego.InputFile], error)

func GetVideoVideoInputFile added in v1.5.0

func GetVideoVideoInputFile(ctx context.Context, serv *service.Service, meta *metautil.MetaData, video shared.VideoLike) (*ioutil.Closer[telego.InputFile], error)

func ParseCommandBy

func ParseCommandBy(text string, splitChar, quoteChar string) (string, string, []string)

func PostAndCreateArtwork

func PostAndCreateArtwork(
	ctx context.Context,
	bot *telego.Bot,
	serv *service.Service,
	meta *metautil.MetaData,
	artwork *entity.CachedArtworkData,
	fromChatID telego.ChatID,
	toChatID telego.ChatID,
	messageID int,
) error

func ReplyMessage

func ReplyMessage(ctx *telegohandler.Context, message telego.Message, text string) (*telego.Message, error)

func ReplyMessageWithHTML

func ReplyMessageWithHTML(ctx *telegohandler.Context, message telego.Message, text string) (*telego.Message, error)

func SendArtworkInfo

func SendArtworkInfo(ctx context.Context,
	bot *telego.Bot,
	meta *metautil.MetaData,
	serv *service.Service,
	sourceUrl string,
	chatID telego.ChatID,
	opts SendArtworkInfoOptions) error

将作品信息附带操作按钮发送到指定聊天, 用于提供给管理员发布或修改作品

需要区分已发布的作品, 已标记为删除的作品, 和未发布的作品

func UpdateCachedArtworkFileID added in v1.4.0

func UpdateCachedArtworkFileID(ctx context.Context,
	results []MediaGroupResultMessage,
	serv *service.Service,
	meta *metautil.MetaData,
	artwork *entity.CachedArtworkData) error

Types

type ArtworkCaptionData

type ArtworkCaptionData struct {
	ID          string
	SourceURL   string
	Title       string
	ArtistName  string
	Description template.HTML
	Tags        template.HTML
	// 用于对未发布到频道的作品的标记
	IsCache bool
}

type CreateArtworkInfoReplyMarkupOptions

type CreateArtworkInfoReplyMarkupOptions struct {
	CreatedArtwork bool
	HasPermission  bool
}

type MediaGroupResultMessage

type MediaGroupResultMessage struct {
	Message telego.Message
	FileID  string // Telegram file ID
	Type    MediaResultType
	Index   int
}

func SendArtworkMediaGroup

func SendArtworkMediaGroup(
	ctx context.Context,
	bot *telego.Bot,
	serv *service.Service,
	meta *metautil.MetaData,
	chatID telego.ChatID,
	artwork shared.ArtworkLike) ([]MediaGroupResultMessage, error)

type MediaItem added in v1.5.0

type MediaItem struct {
	Picture      shared.PictureLike
	Ugoira       shared.UgoiraMetaLike
	Video        shared.VideoLike
	TelegramInfo shared.TelegramInfo
	Type         MediaResultType
	Index        int // original index in pictures, ugoiras or videos array
}

MediaItem represents a photo, ugoira or video for unified processing

type MediaResultType added in v1.5.0

type MediaResultType uint
const (
	MediaResultTypePhoto MediaResultType = iota + 1
	MediaResultTypeUgoira
	MediaResultTypeVideo // although ugoira is also be sent as video, we need to distinguish them for file ID update purposes
)

type SendArtworkInfoOptions

type SendArtworkInfoOptions struct {
	ReplyParameters *telego.ReplyParameters
	AppendCaption   string
	HasPermission   bool
}

type SendOption

type SendOption struct {
	ReplyTo int
}

Jump to

Keyboard shortcuts

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