utils

package
v0.0.0-...-e3dc589 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2023 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrMalformedDates = errors.New("malformed lived in dates")
View Source
var ErrUnknownSourceKind = errors.New("unknown source kind")
View Source
var MergeOrDeleteCurrentLibraryReplyMarkup = models.InlineKeyboardMarkup{
	InlineKeyboard: [][]models.InlineKeyboardButton{
		{
			{Text: "merge", CallbackData: mergeLibraryCallbackData},
			{Text: "delete", CallbackData: deleteLibraryCallbackData},
		},
	},
}

Functions

func EditMapToJsonArticle

func EditMapToJsonArticle(baseSource *db.Source, editMap map[string]string) ([]byte, error)

func EditMapToJsonBook

func EditMapToJsonBook(baseSource *db.Source, editMap map[string]string) ([]byte, error)

func EditMapToJsonPerson

func EditMapToJsonPerson(baseSource *db.Source, editMap map[string]string) ([]byte, error)

func IsValidSourceKind

func IsValidSourceKind(sourceKind string) bool

func MakeSourceKeyboardCallbacks

func MakeSourceKeyboardCallbacks(sourceID int64) (string, string)

func MakeSourceKeyboardPagesCallbacks

func MakeSourceKeyboardPagesCallbacks(firstSourceID, lastSourceID int64) (string, string)

func MakeToggleOutputStateCallback

func MakeToggleOutputStateCallback(output *db.Output) (string, error)

returns callback command in format replaceMsgWith-command-data

func NewBotLogger

func NewBotLogger(dev bool, logPath string) (zerolog.Logger, error)

func NewSourceDeactiverLogger

func NewSourceDeactiverLogger(dev bool, logPath string) (zerolog.Logger, error)

func OutputsReplyMarkup

func OutputsReplyMarkup(outputs []db.Output) (models.InlineKeyboardMarkup, error)

func ParseSourceData

func ParseSourceData(sourceKind db.SourceKind, sourceData pgtype.JSON) (any, error)

func SourcesReplyMarkup

func SourcesReplyMarkup(sources []db.Source, firstPage, lastPage bool) models.InlineKeyboardMarkup

func TextMessage

func TextMessage(chatID int64, text string) bot.SendMessageParams

func TextReplyToMessage

func TextReplyToMessage(message *models.Message, text string) bot.SendMessageParams

Types

type Quote

type Quote struct {
	Text       string
	MainSource string
	Sources    []string
	Tags       []string
}

func ParseQuote

func ParseQuote(text string) (*Quote, error)

type Reaction

type Reaction struct {
	Messages     []bot.SendMessageParams
	EditMessages []bot.EditMessageTextParams
}

func ReplyReaction

func ReplyReaction(message *models.Message, text string) Reaction

func TextReaction

func TextReaction(chatID int64, text string) Reaction

func (Reaction) Do

func (r Reaction) Do(ctx context.Context, bot *bot.Bot) error

Jump to

Keyboard shortcuts

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