xtelebot

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2021 License: MIT Imports: 6 Imported by: 0

README

xtelebot

Dependencies

  • gopkg.in/tucnak/telebot.v2
  • github.com/sirupsen/logrus

Documents

Types
  • type ChatStatus uint64
  • type BotDataOption func
  • type BotData struct
Variables
  • None
Constants
  • None
Functions
  • func WithInitialStatus(initialStatus ChatStatus) BotDataOption
  • func NewBotData(options ...BotDataOption) *BotData
  • func WithExtraText(text string) logop.LoggerOption
  • func WithExtraFields(fields map[string]interface{}) logop.LoggerOption
  • func WithExtraFieldsV(fields ...interface{}) logop.LoggerOption
  • func LogReceiveToLogrus(logger *logrus.Logger, endpoint interface{}, message *telebot.Message, options ...logop.LoggerOption)
  • func LogReplyToLogrus(logger *logrus.Logger, received, replied *telebot.Message, err error, options ...logop.LoggerOption)
  • func LogSendToLogrus(logger *logrus.Logger, chat *telebot.Chat, sent *telebot.Message, err error, options ...logop.LoggerOption)
  • func LogReceiveToLogger(logger logrus.StdLogger, endpoint interface{}, message *telebot.Message, options ...logop.LoggerOption)
  • func LogReplyToLogger(logger logrus.StdLogger, received, replied *telebot.Message, err error, options ...logop.LoggerOption)
  • func LogSendToLogger(logger logrus.StdLogger, chat *telebot.Chat, sent *telebot.Message, err error, options ...logop.LoggerOption)
Methods
  • func (b *BotData) GetStatusChats() []int64
  • func (b *BotData) GetStatus(chatID int64) (ChatStatus, bool)
  • func (b *BotData) GetStatusOr(chatID int64, fallbackStatus ChatStatus) ChatStatus
  • func (b *BotData) GetStatusOrInit(chatID int64) ChatStatus
  • func (b *BotData) SetStatus(chatID int64, status ChatStatus)
  • func (b *BotData) ResetStatus(chatID int64)
  • func (b *BotData) DeleteStatus(chatID int64)
  • func (b *BotData) GetCacheChats() []int64
  • func (b *BotData) GetCache(chatID int64, key string) (interface{}, bool)
  • func (b *BotData) GetCacheOr(chatID int64, key string, fallbackValue interface{}) interface{}
  • func (b *BotData) GetChatCaches(chatID int64) (map[string]interface{}, bool)
  • func (b *BotData) SetCache(chatID int64, key string, value interface{})
  • func (b *BotData) RemoveCache(chatID int64, key string)
  • func (b *BotData) ClearCaches(chatID int64)

Documentation

Index

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

func (b *BotData) ClearCaches(chatID int64)

ClearCaches clears a chat's all caches.

func (*BotData) DeleteStatus

func (b *BotData) DeleteStatus(chatID int64)

DeleteStatus deletes a chat's status.

func (*BotData) GetCache

func (b *BotData) GetCache(chatID int64, key string) (interface{}, bool)

GetCache returns a chat's cache data, returns false if no cache is set or the key is not found.

func (*BotData) GetCacheChats

func (b *BotData) GetCacheChats() []int64

GetCacheChats returns all ids from chats which has been set cache, the returned slice has no order.

func (*BotData) GetCacheOr

func (b *BotData) GetCacheOr(chatID int64, key string, fallbackValue interface{}) interface{}

GetCacheOr returns a chat's cache data, returns fallback value if no cache is set or the key is not found.

func (*BotData) GetChatCaches

func (b *BotData) GetChatCaches(chatID int64) (map[string]interface{}, bool)

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

func (b *BotData) GetStatusChats() []int64

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

func (b *BotData) RemoveCache(chatID int64, key string)

RemoveCache removes a chat's cache data.

func (*BotData) ResetStatus

func (b *BotData) ResetStatus(chatID int64)

ResetStatus resets a chat's status to the initial status.

func (*BotData) SetCache

func (b *BotData) SetCache(chatID int64, key string, value interface{})

SetCache sets a chat's cache data using the given key and value.

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.

Jump to

Keyboard shortcuts

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