mytgbot

package module
v1.1.9 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2025 License: BSD-3-Clause Imports: 11 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AlertCallback added in v1.0.22

func AlertCallback(bot *tgbotapi.BotAPI, cbId string, message string, configFn func(callbackConfig *tgbotapi.CallbackConfig)) (tgbotapi.Message, error)
func CreatePermanentInviteLink(token string, chatId int64) (ret string, err error)

生成群永久链接,这个链接中永久的,唯一的,多次生成,则新的替换成旧的 。

func EditMessage added in v1.0.21

func EditMessage(bot *tgbotapi.BotAPI, chatId int64, editMessageID int, text string, configFn func(editMsgConfig *tgbotapi.EditMessageTextConfig)) (tgbotapi.Message, error)

func EditMessageCaption added in v1.0.21

func EditMessageCaption(bot *tgbotapi.BotAPI, chatId int64, editMessageID int, caption string, configFn func(editMsgConfig *tgbotapi.EditMessageCaptionConfig)) (tgbotapi.Message, error)
func GenUserLink(userID int64) string
func GenUserNameLink(userName string) string

func GetChatDesc added in v1.1.0

func GetChatDesc(bot *tgbotapi.BotAPI, chatID int64) (tgbotapi.Chat, error)

func HtmlLinkText added in v1.0.11

func HtmlLinkText(showText, linkText string) string

func ImpGroup added in v1.0.1

func ImpGroup() group

func ImpInline added in v1.1.6

func ImpInline() inLine

func MarkdownCopyText added in v1.0.11

func MarkdownCopyText(showText string) string

func MarkdownLinkText added in v1.0.11

func MarkdownLinkText(showText, linkText string) string

关于markdown 格式的特别显示

func PingMessage added in v1.1.4

func PingMessage(bot *tgbotapi.BotAPI, chatID int64, messagaId int, notifaicationFlag bool) error

func SendAnimation added in v1.0.8

func SendAnimation(bot *tgbotapi.BotAPI, chatID int64, animationFileFn func() tgbotapi.RequestFileData, configCb func(photoConfig *tgbotapi.AnimationConfig)) (messageID int, animationFileId string, err error)

func SendMessage

func SendMessage(bot *tgbotapi.BotAPI, chatId int64, message string, configCb func(messageCfg *tgbotapi.MessageConfig)) (*tgbotapi.Message, error)

func SendMessageByAutoDel added in v1.0.10

func SendMessageByAutoDel(bot *tgbotapi.BotAPI, chatId int64, message string, configCb func(messageCfg *tgbotapi.MessageConfig), autoDele time.Duration) error

func SendMessageByToken added in v1.0.4

func SendMessageByToken(token string, toChatId int64, message string, configFn func(values url.Values)) error

func SendPhoto added in v1.0.6

func SendPhoto(bot *tgbotapi.BotAPI, chatId int64, imageFileFn func() tgbotapi.RequestFileData, configCb func(photoConfig *tgbotapi.PhotoConfig)) (messageID int, imageFileId string, err error)

func SendPhotoByToken added in v1.0.18

func SendPhotoByToken(token string, toChatId int64, photoName string, photoData []byte, caption string, configFn func(values *multipart.Writer)) error

func WebhookHandler added in v1.0.19

func WebhookHandler(w http.ResponseWriter, r *http.Request, cbFun func(update tgbotapi.Update))

Types

type BotInfo added in v1.1.5

type BotInfo struct {
	Ok     bool `json:"ok"`
	Result struct {
		ID                      int64  `json:"id"`
		IsBot                   bool   `json:"is_bot"`
		FirstName               string `json:"first_name"`
		Username                string `json:"username"`
		CanJoinGroups           bool   `json:"can_join_groups"`
		CanReadAllGroupMessages bool   `json:"can_read_all_group_messages"`
		SupportsInlineQueries   bool   `json:"supports_inline_queries"`
	} `json:"result"`
}

func GetBotInfo added in v1.1.5

func GetBotInfo(token string) (*BotInfo, error)

type ChatResp added in v1.1.1

type ChatResp[T any] struct {
	Ok     bool `json:"ok"`
	Result T    `json:"result"`
}

type ErrStatus

type ErrStatus int
const (
	ErrStatusNil          ErrStatus = 0
	ErrStatusKicked       ErrStatus = 1   //对话已被踢出群聊
	ErrStatusGroupDeleted ErrStatus = 2   //群组被删除
	ErrStatusUnknown      ErrStatus = 100 //未知的错误
)

func CheckErrStatus

func CheckErrStatus(err error) ErrStatus

type InviteTempData added in v1.0.17

type InviteTempData struct {
	InviteLink         string `json:"invite_link"`
	Name               string `json:"name"`
	ExpireDate         int    `json:"expire_date"`
	MemberLimit        int    `json:"member_limit"`
	CreatesJoinRequest bool   `json:"creates_join_request"`
}
func CreateTempInviteLink(token string, chatId int64, name string, expireDate time.Time, maxLimit int, joinCheck bool) (ret *InviteTempData, err error)

生成临时邀请链接 ,可为不同人生成,场景更丰富

type TelegramChat added in v1.1.2

type TelegramChat struct {
	ID          int64  `json:"id"`
	Type        string `json:"type"`        // "group", "supergroup", "channel"
	Title       string `json:"title"`       // 群组或频道的名称
	Username    string `json:"username"`    // 可能为空
	Description string `json:"description"` // 仅频道有
	InviteLink  string `json:"invite_link"`
}

群组/频道信息

func GetChatByToken added in v1.1.1

func GetChatByToken(token string, groupID int64) (*TelegramChat, error)

type TelegramUser added in v1.1.2

type TelegramUser struct {
	ID        int64  `json:"id"`
	Type      string `json:"type"`     // 必须是 "private"
	Username  string `json:"username"` // 可能为空
	FirstName string `json:"first_name"`
	LastName  string `json:"last_name"`
}

用户信息

func GetUserByToken added in v1.1.2

func GetUserByToken(token string, userID int64) (*TelegramUser, error)

Jump to

Keyboard shortcuts

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