utils

package
v1.7.5 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2025 License: GPL-3.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ChatActionTyping       = ChatAction("typing")
	ChatActionUploadPhoto  = ChatAction("upload_photo")
	ChatActionSendDocument = ChatAction("upload_document")
)
View Source
const MB = 1 << 20

Variables

Functions

func BotGetFile

func BotGetFile(config tgbotapi.FileConfig) (tgbotapi.File, error)

func BotGetSelf added in v1.4.3

func BotGetSelf() tgbotapi.User

func BotGetStickerSet

func BotGetStickerSet(config tgbotapi.GetStickerSetConfig) (tgbotapi.StickerSet, error)

func BotRequest

func BotRequest(c tgbotapi.Chattable) error

func BotSend

func BotSend(c tgbotapi.Chattable) (tgbotapi.Message, error)

func CallBack

func CallBack(callbackQueryID string, text string)

func CallBackWithAlert

func CallBackWithAlert(callbackQueryID string, text string)

func CheckUserSubscription added in v1.7.5

func CheckUserSubscription(update *tgbotapi.Update, channelUsername string) bool

CheckUserSubscription 检查用户是否订阅频道

func CleanTmp

func CleanTmp()

func Compress

func Compress(src, dest string) error

Compress 压缩文件 files 文件数组,可以是不同dir下的文件或者文件夹 dest 压缩文件存放地址

func CopyFile

func CopyFile(src, dst string) error

func DeleteMsg

func DeleteMsg(chatID int64, MsgID int)

func DownloadFile

func DownloadFile(fileUrl string) (string, error)

func EditMsgText

func EditMsgText(chatID int64, msgID int, msg string, entity ...tgbotapi.MessageEntity)

func EditMsgTextAndMarkup

func EditMsgTextAndMarkup(chatID int64, msgID int, msg string, markup tgbotapi.InlineKeyboardMarkup)

func EntityBold

func EntityBold(text, boldPart string) tgbotapi.MessageEntity

func EntityCode

func EntityCode(text, part string) tgbotapi.MessageEntity
func EntityLink(text, part, url string) tgbotapi.MessageEntity

func EntityMention

func EntityMention(text, part string) tgbotapi.MessageEntity

func EntityTag

func EntityTag(text, part string) tgbotapi.MessageEntity
func EntityTextLink(text, part, url string) tgbotapi.MessageEntity

func EntityUnderline

func EntityUnderline(text, boldPart string) tgbotapi.MessageEntity

func GetChatID

func GetChatID(update *tgbotapi.Update) int64

func GetFileExtName

func GetFileExtName(fileName string) string

func GetLogPrefixCallbackQuery

func GetLogPrefixCallbackQuery(update *tgbotapi.Update) string

func GetLogPrefixMessage

func GetLogPrefixMessage(update *tgbotapi.Update) string

func GetUID

func GetUID(update *tgbotapi.Update) int64

func Init

func Init(api *tgbotapi.BotAPI)

func IsExist

func IsExist(path string) bool

func JsonEncode

func JsonEncode(data any) string

func LogUserInfo

func LogUserInfo(update *tgbotapi.Update) string

func MD5

func MD5(v string) string

func MD5File

func MD5File(filename string) (string, error)

func MD5Short

func MD5Short(v string) string

func RandString

func RandString() string

func RemoveFile

func RemoveFile(path string)

func SendAction

func SendAction(chaiID int64, action ChatAction)

func SendFileByFileID added in v1.6.0

func SendFileByFileID(update *tgbotapi.Update, fileID string) error

SendFileByFileID 发送文件

传入文件 file_id

func SendFileByPath added in v1.6.0

func SendFileByPath(update *tgbotapi.Update, filePath string) (tgbotapi.Message, error)

SendFileByPath 发送文件

传入文件本地存储地址

func SendImg

func SendImg(update *tgbotapi.Update, fileData []byte) (msgSent tgbotapi.Message)

func SendPlainText

func SendPlainText(update *tgbotapi.Update, text string, entity ...tgbotapi.MessageEntity)

func SendPlainTextWithKeyboard

func SendPlainTextWithKeyboard(update *tgbotapi.Update, text string, keyboard *tgbotapi.ReplyKeyboardMarkup, entity ...tgbotapi.MessageEntity)

func SendSticker

func SendSticker(update *tgbotapi.Update, fileID string)

Types

type ChatAction

type ChatAction string

type ConvertTask added in v1.5.0

type ConvertTask struct {
	//Input file for converting
	InputFilePath string

	//Input file extension
	//support: webp,webm,tgs
	InputExtension string

	//Output file for converting
	OutputFilePath string
}

func (*ConvertTask) Run added in v1.5.0

func (task *ConvertTask) Run(ctx context.Context) error

type UploadFile

type UploadFile struct {
	ZipPath    string
	FolderPath string
	CleanList  []string
}

func NewUploadFile

func NewUploadFile(zipPath, folderPath string) *UploadFile

func (*UploadFile) Clean

func (f *UploadFile) Clean()

func (*UploadFile) UploadFragment

func (f *UploadFile) UploadFragment(update *tgbotapi.Update) error

func (*UploadFile) UploadSingle added in v1.7.3

func (f *UploadFile) UploadSingle(update *tgbotapi.Update) error

Jump to

Keyboard shortcuts

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