Documentation ¶
Index ¶
- Constants
- func EscapeHTMLSymbols(str string) string
- func EscapeStringForMarkdownV2(src string) string
- func FullNameFromFirstAndLastName(firstName, lastName string) string
- func MapChatTypeToChineseText(chatType telegram.ChatType) string
- func MapMemberStatusToChineseText(memberStatus telegram.MemberStatus) string
- func NewDispatcher() func(logger *logger.Logger) *Dispatcher
- func RemoveHTMLBlocksFromString(str string) string
- func ReplaceMarkdownTitlesToTelegramBoldElement(text string) string
- func SplitMessagesAgainstLengthLimitIntoMessageGroups(originalSlice []string) [][]string
- type Bot
- func (b *Bot) AssignOneCallbackQueryData(route string, data any) (string, error)
- func (b *Bot) DeleteAllDeleteLaterMessages(forUserID int64) error
- func (b *Bot) IsBotAdministrator(chatID int64) (bool, error)
- func (b *Bot) IsBotWasBlockedByTheUserErr(err error) bool
- func (b *Bot) IsCannotInitiateChatWithUserErr(err error) bool
- func (b *Bot) IsGroupAnonymousBot(user *tgbotapi.User) bool
- func (b *Bot) IsUserMemberStatus(chatID int64, userID int64, status []telegram.MemberStatus) (bool, error)
- func (b *Bot) MayRequest(chattable tgbotapi.Chattable) *tgbotapi.APIResponse
- func (b *Bot) MaySend(chattable tgbotapi.Chattable) *tgbotapi.Message
- func (b *Bot) PushOneDeleteLaterMessage(forUserID int64, chatID int64, messageID int) error
- type BotService
- type BotServiceOptions
- type CallOption
- type Command
- type Context
- func (c *Context) Abort()
- func (c *Context) BindFromCallbackQueryData(dst any) error
- func (c *Context) IsAborted() bool
- func (c *Context) IsBotAdministrator() (bool, error)
- func (c *Context) IsUserMemberStatus(userID int64, status []telegram.MemberStatus) (bool, error)
- func (c *Context) NewEditMessageReplyMarkup(messageID int, replyMarkup tgbotapi.InlineKeyboardMarkup) EditMessageResponse
- func (c *Context) NewEditMessageText(messageID int, text string) EditMessageResponse
- func (c *Context) NewEditMessageTextAndReplyMarkup(messageID int, text string, replyMarkup tgbotapi.InlineKeyboardMarkup) EditMessageResponse
- func (c *Context) NewMessage(message string) MessageResponse
- func (c *Context) NewMessageReplyTo(message string, replyToMessageID int) MessageResponse
- func (c *Context) UpdateType() UpdateType
- type Dispatcher
- func (d *Dispatcher) Dispatch(bot *tgbotapi.BotAPI, update tgbotapi.Update, rueidisClient rueidis.Client)
- func (d *Dispatcher) OnCallbackQuery(route string, h Handler)
- func (d *Dispatcher) OnCancelCommand(cancelHandler func(c *Context) (bool, error), handler Handler)
- func (d *Dispatcher) OnChannelPost(handler Handler)
- func (d *Dispatcher) OnCommand(cmd, commandHelp string, h Handler)
- func (d *Dispatcher) OnCommandGroup(groupName string, group []Command)
- func (d *Dispatcher) OnStartCommand(h Handler)
- func (d *Dispatcher) Use(middleware MiddlewareFunc)
- type EditMessageResponse
- func NewEditMessageReplyMarkup(chatID int64, messageID int, replyMarkup tgbotapi.InlineKeyboardMarkup) EditMessageResponse
- func NewEditMessageText(chatID int64, messageID int, text string) EditMessageResponse
- func NewEditMessageTextAndReplyMarkup(chatID int64, messageID int, text string, ...) EditMessageResponse
- func (r EditMessageResponse) WithEditMessageCaptionConfig(config tgbotapi.EditMessageCaptionConfig) EditMessageResponse
- func (r EditMessageResponse) WithEditMessageLiveLocationConfig(config tgbotapi.EditMessageLiveLocationConfig) EditMessageResponse
- func (r EditMessageResponse) WithEditMessageMediaConfig(config tgbotapi.EditMessageMediaConfig) EditMessageResponse
- func (r EditMessageResponse) WithEditMessageReplyMarkupConfig(config tgbotapi.EditMessageReplyMarkupConfig) EditMessageResponse
- func (r EditMessageResponse) WithEditMessageTextConfig(config tgbotapi.EditMessageTextConfig) EditMessageResponse
- func (r EditMessageResponse) WithInlineReplyMarkup(inlineMarkup tgbotapi.InlineKeyboardMarkup) EditMessageResponse
- func (r EditMessageResponse) WithParseModeHTML() EditMessageResponse
- type ExceptionError
- func (e ExceptionError) Error() string
- func (e ExceptionError) WithDeleteLater(userID int64, chatID int64) ExceptionError
- func (e ExceptionError) WithEdit(message *tgbotapi.Message) ExceptionError
- func (e ExceptionError) WithMessage(message string) ExceptionError
- func (e ExceptionError) WithReply(message *tgbotapi.Message) ExceptionError
- func (e ExceptionError) WithReplyMarkup(replyMarkup tgbotapi.InlineKeyboardMarkup) ExceptionError
- type HandleFunc
- type Handler
- type HandlerGroup
- type MessageError
- func (e MessageError) Error() string
- func (e MessageError) WithDeleteLater(userID int64, chatID int64) MessageError
- func (e MessageError) WithEdit(message *tgbotapi.Message) MessageError
- func (e MessageError) WithParseModeHTML() MessageError
- func (e MessageError) WithReply(message *tgbotapi.Message) MessageError
- func (e MessageError) WithReplyMarkup(replyMarkup tgbotapi.InlineKeyboardMarkup) MessageError
- type MessageResponse
- func (r MessageResponse) WithDeleteLater(userID int64, chatID int64) MessageResponse
- func (r MessageResponse) WithMessageConfig(config tgbotapi.MessageConfig) MessageResponse
- func (r MessageResponse) WithParseModeHTML() MessageResponse
- func (r MessageResponse) WithReplyMarkup(replyMarkup any) MessageResponse
- type MiddlewareFunc
- type Response
- type UpdateType
Constants ¶
View Source
const (
MessageLengthLimit = 4096
)
Variables ¶
This section is empty.
Functions ¶
func EscapeStringForMarkdownV2 ¶
EscapeForMarkdownV2
1. 任何字符码表在 1 到 126 之间的字符都可以加前缀 '\' 字符来转义,在这种情况下,它被视为一个普通字符,而不是标记的一部分。这意味着 '\' 字符通常必须加前缀 '\' 字符来转义。 2. 在 pre 和 code 的实体中,所有 '`' 和 '\' 字符都必须加前缀 '\' 字符转义。 3. 在所有其他地方,字符 '_', '*', '[', ']', '(', ')', '~', '`', '>', '#', '+', '-', '=', '|', '{', '}', '.', '!' 必须加前缀字符 '\' 转义。
func MapMemberStatusToChineseText ¶
func MapMemberStatusToChineseText(memberStatus telegram.MemberStatus) string
func NewDispatcher ¶
func NewDispatcher() func(logger *logger.Logger) *Dispatcher
func RemoveHTMLBlocksFromString ¶ added in v0.14.0
RemoveHTMLBlocksFromString
<any> with "" </any> with ""
Types ¶
type Bot ¶
func (*Bot) AssignOneCallbackQueryData ¶ added in v0.14.0
func (*Bot) DeleteAllDeleteLaterMessages ¶ added in v0.14.0
func (*Bot) IsBotAdministrator ¶ added in v0.14.0
func (*Bot) IsBotWasBlockedByTheUserErr ¶ added in v0.14.0
func (*Bot) IsCannotInitiateChatWithUserErr ¶ added in v0.14.0
func (*Bot) IsGroupAnonymousBot ¶ added in v0.14.0
func (*Bot) IsUserMemberStatus ¶ added in v0.14.0
func (*Bot) MayRequest ¶ added in v0.14.0
func (b *Bot) MayRequest(chattable tgbotapi.Chattable) *tgbotapi.APIResponse
type BotService ¶
func NewBotService ¶
func NewBotService(callOpts ...CallOption) (*BotService, error)
func (*BotService) Bot ¶ added in v0.14.0
func (b *BotService) Bot() *Bot
type BotServiceOptions ¶
type BotServiceOptions struct {
// contains filtered or unexported fields
}
type CallOption ¶
type CallOption func(*BotServiceOptions)
func WithDispatcher ¶
func WithDispatcher(dispatcher *Dispatcher) CallOption
func WithLogger ¶
func WithLogger(logger *logger.Logger) CallOption
func WithRueidisClient ¶ added in v0.14.0
func WithRueidisClient(client rueidis.Client) CallOption
func WithToken ¶
func WithToken(token string) CallOption
func WithWebhookPort ¶
func WithWebhookPort(port string) CallOption
func WithWebhookURL ¶
func WithWebhookURL(url string) CallOption
type Context ¶
type Context struct { Bot *Bot Update tgbotapi.Update Logger *logger.Logger // contains filtered or unexported fields }
func NewContext ¶
func (*Context) BindFromCallbackQueryData ¶ added in v0.14.0
func (*Context) IsBotAdministrator ¶ added in v0.14.0
func (*Context) IsUserMemberStatus ¶ added in v0.14.0
func (*Context) NewEditMessageReplyMarkup ¶ added in v0.14.0
func (c *Context) NewEditMessageReplyMarkup(messageID int, replyMarkup tgbotapi.InlineKeyboardMarkup) EditMessageResponse
func (*Context) NewEditMessageText ¶
func (c *Context) NewEditMessageText(messageID int, text string) EditMessageResponse
func (*Context) NewEditMessageTextAndReplyMarkup ¶
func (c *Context) NewEditMessageTextAndReplyMarkup(messageID int, text string, replyMarkup tgbotapi.InlineKeyboardMarkup) EditMessageResponse
func (*Context) NewMessage ¶
func (c *Context) NewMessage(message string) MessageResponse
func (*Context) NewMessageReplyTo ¶
func (c *Context) NewMessageReplyTo(message string, replyToMessageID int) MessageResponse
func (*Context) UpdateType ¶
func (c *Context) UpdateType() UpdateType
type Dispatcher ¶
func (*Dispatcher) OnCallbackQuery ¶
func (d *Dispatcher) OnCallbackQuery(route string, h Handler)
func (*Dispatcher) OnCancelCommand ¶ added in v0.14.0
func (d *Dispatcher) OnCancelCommand(cancelHandler func(c *Context) (bool, error), handler Handler)
func (*Dispatcher) OnChannelPost ¶
func (d *Dispatcher) OnChannelPost(handler Handler)
func (*Dispatcher) OnCommand ¶
func (d *Dispatcher) OnCommand(cmd, commandHelp string, h Handler)
func (*Dispatcher) OnCommandGroup ¶ added in v0.14.0
func (d *Dispatcher) OnCommandGroup(groupName string, group []Command)
func (*Dispatcher) OnStartCommand ¶ added in v0.14.0
func (d *Dispatcher) OnStartCommand(h Handler)
func (*Dispatcher) Use ¶
func (d *Dispatcher) Use(middleware MiddlewareFunc)
type EditMessageResponse ¶
type EditMessageResponse struct {
// contains filtered or unexported fields
}
func NewEditMessageReplyMarkup ¶ added in v0.14.0
func NewEditMessageReplyMarkup(chatID int64, messageID int, replyMarkup tgbotapi.InlineKeyboardMarkup) EditMessageResponse
func NewEditMessageText ¶
func NewEditMessageText(chatID int64, messageID int, text string) EditMessageResponse
func NewEditMessageTextAndReplyMarkup ¶
func NewEditMessageTextAndReplyMarkup(chatID int64, messageID int, text string, replyMarkup tgbotapi.InlineKeyboardMarkup) EditMessageResponse
func (EditMessageResponse) WithEditMessageCaptionConfig ¶
func (r EditMessageResponse) WithEditMessageCaptionConfig(config tgbotapi.EditMessageCaptionConfig) EditMessageResponse
func (EditMessageResponse) WithEditMessageLiveLocationConfig ¶
func (r EditMessageResponse) WithEditMessageLiveLocationConfig(config tgbotapi.EditMessageLiveLocationConfig) EditMessageResponse
func (EditMessageResponse) WithEditMessageMediaConfig ¶
func (r EditMessageResponse) WithEditMessageMediaConfig(config tgbotapi.EditMessageMediaConfig) EditMessageResponse
func (EditMessageResponse) WithEditMessageReplyMarkupConfig ¶
func (r EditMessageResponse) WithEditMessageReplyMarkupConfig(config tgbotapi.EditMessageReplyMarkupConfig) EditMessageResponse
func (EditMessageResponse) WithEditMessageTextConfig ¶
func (r EditMessageResponse) WithEditMessageTextConfig(config tgbotapi.EditMessageTextConfig) EditMessageResponse
func (EditMessageResponse) WithInlineReplyMarkup ¶ added in v0.14.0
func (r EditMessageResponse) WithInlineReplyMarkup(inlineMarkup tgbotapi.InlineKeyboardMarkup) EditMessageResponse
func (EditMessageResponse) WithParseModeHTML ¶
func (r EditMessageResponse) WithParseModeHTML() EditMessageResponse
type ExceptionError ¶
type ExceptionError struct {
// contains filtered or unexported fields
}
func NewExceptionError ¶
func NewExceptionError(err error) ExceptionError
func (ExceptionError) Error ¶
func (e ExceptionError) Error() string
func (ExceptionError) WithDeleteLater ¶ added in v0.14.0
func (e ExceptionError) WithDeleteLater(userID int64, chatID int64) ExceptionError
func (ExceptionError) WithEdit ¶
func (e ExceptionError) WithEdit(message *tgbotapi.Message) ExceptionError
func (ExceptionError) WithMessage ¶
func (e ExceptionError) WithMessage(message string) ExceptionError
func (ExceptionError) WithReply ¶
func (e ExceptionError) WithReply(message *tgbotapi.Message) ExceptionError
func (ExceptionError) WithReplyMarkup ¶ added in v0.14.0
func (e ExceptionError) WithReplyMarkup(replyMarkup tgbotapi.InlineKeyboardMarkup) ExceptionError
type HandleFunc ¶
type Handler ¶
func NewHandler ¶
func NewHandler(h HandleFunc) Handler
type HandlerGroup ¶
type HandlerGroup interface {
Install(dispatcher *Dispatcher)
}
type MessageError ¶
type MessageError struct {
// contains filtered or unexported fields
}
func NewMessageError ¶
func NewMessageError(message string) MessageError
func (MessageError) Error ¶
func (e MessageError) Error() string
func (MessageError) WithDeleteLater ¶ added in v0.14.0
func (e MessageError) WithDeleteLater(userID int64, chatID int64) MessageError
func (MessageError) WithEdit ¶
func (e MessageError) WithEdit(message *tgbotapi.Message) MessageError
func (MessageError) WithParseModeHTML ¶ added in v0.14.0
func (e MessageError) WithParseModeHTML() MessageError
func (MessageError) WithReply ¶
func (e MessageError) WithReply(message *tgbotapi.Message) MessageError
func (MessageError) WithReplyMarkup ¶ added in v0.14.0
func (e MessageError) WithReplyMarkup(replyMarkup tgbotapi.InlineKeyboardMarkup) MessageError
type MessageResponse ¶
type MessageResponse struct {
// contains filtered or unexported fields
}
func NewMessage ¶
func NewMessage(chatID int64, message string) MessageResponse
func NewMessageReplyTo ¶
func NewMessageReplyTo(chatID int64, message string, replyToMessageID int) MessageResponse
func (MessageResponse) WithDeleteLater ¶ added in v0.14.0
func (r MessageResponse) WithDeleteLater(userID int64, chatID int64) MessageResponse
func (MessageResponse) WithMessageConfig ¶
func (r MessageResponse) WithMessageConfig(config tgbotapi.MessageConfig) MessageResponse
func (MessageResponse) WithParseModeHTML ¶
func (r MessageResponse) WithParseModeHTML() MessageResponse
func (MessageResponse) WithReplyMarkup ¶
func (r MessageResponse) WithReplyMarkup(replyMarkup any) MessageResponse
type MiddlewareFunc ¶
type MiddlewareFunc func(ctx *Context, next func())
type UpdateType ¶
type UpdateType string
const ( UpdateTypeUnknown UpdateType = "unknown" UpdateTypeMessage UpdateType = "message" UpdateTypeEditedMessage UpdateType = "edited_message" UpdateTypeChannelPost UpdateType = "channel_post" UpdateTypeEditedChannelPost UpdateType = "edited_channel_post" UpdateTypeInlineQuery UpdateType = "inline_query" UpdateTypeChosenInlineResult UpdateType = "chosen_inline_result" UpdateTypeCallbackQuery UpdateType = "callback_query" UpdateTypeShippingQuery UpdateType = "shipping_query" UpdateTypePreCheckoutQuery UpdateType = "pre_checkout_query" UpdateTypePoll UpdateType = "poll" UpdateTypePollAnswer UpdateType = "poll_answer" UpdateTypeMyChatMember UpdateType = "my_chat_member" UpdateTypeChatMember UpdateType = "chat_member" UpdateTypeChatJoinRequest UpdateType = "chat_join_request" )
Click to show internal directories.
Click to hide internal directories.