Documentation ¶
Index ¶
- func LogReceiveToLogger(logger logrus.StdLogger, endpoint interface{}, message *telebot.Message, ...)
- func LogReceiveToLogrus(logger *logrus.Logger, endpoint interface{}, message *telebot.Message, ...)
- func LogReplyToLogger(logger logrus.StdLogger, received, replied *telebot.Message, err error, ...)
- func LogReplyToLogrus(logger *logrus.Logger, received, replied *telebot.Message, err error, ...)
- func LogSendToLogger(logger logrus.StdLogger, chat *telebot.Chat, sent *telebot.Message, err error, ...)
- func LogSendToLogrus(logger *logrus.Logger, chat *telebot.Chat, sent *telebot.Message, err error, ...)
- func WithExtraFields(fields map[string]interface{}) logop.LoggerOption
- func WithExtraFieldsV(fields ...interface{}) logop.LoggerOption
- func WithExtraText(text string) logop.LoggerOption
- type BotData
- func (b *BotData) ClearCaches(chatID int64)
- func (b *BotData) DeleteStatus(chatID int64)
- func (b *BotData) GetCache(chatID int64, key string) (interface{}, bool)
- func (b *BotData) GetCacheChats() []int64
- func (b *BotData) GetCacheOr(chatID int64, key string, fallbackValue interface{}) interface{}
- func (b *BotData) GetChatCaches(chatID int64) (map[string]interface{}, bool)
- func (b *BotData) GetStatus(chatID int64) (ChatStatus, bool)
- func (b *BotData) GetStatusChats() []int64
- func (b *BotData) GetStatusOr(chatID int64, fallbackStatus ChatStatus) ChatStatus
- func (b *BotData) GetStatusOrInit(chatID int64) ChatStatus
- func (b *BotData) RemoveCache(chatID int64, key string)
- func (b *BotData) ResetStatus(chatID int64)
- func (b *BotData) SetCache(chatID int64, key string, value interface{})
- func (b *BotData) SetStatus(chatID int64, status ChatStatus)
- type BotDataOption
- type ChatStatus
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LogReceiveToLogger ¶
func LogReceiveToLogger(logger logrus.StdLogger, endpoint interface{}, message *telebot.Message, options ...logop.LoggerOption)
LogReceiveToLogger logs a receive-event message to logrus.StdLogger using given endpoint and handler's telebot.Message.
func LogReceiveToLogrus ¶
func LogReceiveToLogrus(logger *logrus.Logger, endpoint interface{}, message *telebot.Message, options ...logop.LoggerOption)
LogReceiveToLogrus logs a receive-event message to logrus.Logger using given endpoint and handler's telebot.Message.
func LogReplyToLogger ¶
func LogReplyToLogger(logger logrus.StdLogger, received, replied *telebot.Message, err error, options ...logop.LoggerOption)
LogReplyToLogger logs a reply-event message to logrus.StdLogger using given received, replied telebot.Message and error.
func LogReplyToLogrus ¶
func LogReplyToLogrus(logger *logrus.Logger, received, replied *telebot.Message, err error, options ...logop.LoggerOption)
LogReplyToLogrus logs a reply-event message to logrus.Logger using given received, replied telebot.Message and error.
func LogSendToLogger ¶
func LogSendToLogger(logger logrus.StdLogger, chat *telebot.Chat, sent *telebot.Message, err error, options ...logop.LoggerOption)
LogSendToLogger logs a send-event message to logrus.StdLogger using given telebot.Chat, sent telebot.Message and error.
func LogSendToLogrus ¶
func LogSendToLogrus(logger *logrus.Logger, chat *telebot.Chat, sent *telebot.Message, err error, options ...logop.LoggerOption)
LogSendToLogrus logs a send-event message to logrus.Logger using given telebot.Chat, sent telebot.Message and error.
func WithExtraFields ¶
func WithExtraFields(fields map[string]interface{}) logop.LoggerOption
WithExtraFields creates a logger option to log with extra fields.
func WithExtraFieldsV ¶
func WithExtraFieldsV(fields ...interface{}) logop.LoggerOption
WithExtraFieldsV creates a logger option to log with extra fields in vararg.
func WithExtraText ¶
func WithExtraText(text string) logop.LoggerOption
WithExtraText creates a logger option to log with extra text.
Types ¶
type BotData ¶
type BotData struct {
// contains filtered or unexported fields
}
BotData represents a set of chats data in a bot.
func NewBotData ¶
func NewBotData(options ...BotDataOption) *BotData
NewBotData creates a new BotData with BotDataOption-s.
func (*BotData) ClearCaches ¶
ClearCaches clears a chat's all caches.
func (*BotData) DeleteStatus ¶
DeleteStatus deletes a chat's status.
func (*BotData) GetCache ¶
GetCache returns a chat's cache data, returns false if no cache is set or the key is not found.
func (*BotData) GetCacheChats ¶
GetCacheChats returns all ids from chats which has been set cache, the returned slice has no order.
func (*BotData) GetCacheOr ¶
GetCacheOr returns a chat's cache data, returns fallback value if no cache is set or the key is not found.
func (*BotData) GetChatCaches ¶
GetChatCaches returns a chat's all caches data, returns false if no cache is set.
func (*BotData) GetStatus ¶
func (b *BotData) GetStatus(chatID int64) (ChatStatus, bool)
GetStatus returns a chat's status, returns false if no status is set.
func (*BotData) GetStatusChats ¶
GetStatusChats returns all ids from chats which has been set status, the returned slice has no order.
func (*BotData) GetStatusOr ¶
func (b *BotData) GetStatusOr(chatID int64, fallbackStatus ChatStatus) ChatStatus
GetStatusOr returns a chat's status, returns the fallback status if no status is set.
func (*BotData) GetStatusOrInit ¶
func (b *BotData) GetStatusOrInit(chatID int64) ChatStatus
GetStatusOrInit returns a chat's status, sets to the initial status and returns it if no status is set.
func (*BotData) RemoveCache ¶
RemoveCache removes a chat's cache data.
func (*BotData) ResetStatus ¶
ResetStatus resets a chat's status to the initial status.
func (*BotData) SetStatus ¶
func (b *BotData) SetStatus(chatID int64, status ChatStatus)
SetStatus sets a chat's status.
type BotDataOption ¶
type BotDataOption func(*botDataConfig)
BotDataOption represents an option for BotData, created by WithXXX functions.
func WithInitialStatus ¶
func WithInitialStatus(initialStatus ChatStatus) BotDataOption
WithInitialStatus creates an option for initial chat's status, this defaults to `ChatStatus(0)`.
type ChatStatus ¶
type ChatStatus uint64
ChatStatus represents a status of a chat, can be used in fsm.