Documentation ¶
Index ¶
- Variables
- func Contains(slice []string, text string) bool
- func EncodeURL(input string, params map[string]string) string
- func Fatal(format string, a ...interface{})
- func LoadEnv(path string)
- func LogDebug(format string, a ...interface{})
- func LogError(format string, a ...interface{})
- func LogInfo(format string, a ...interface{})
- func LogSuccess(format string, a ...interface{})
- func OpenCache() (cache *redis.Client)
- func OpenDirs()
- func ParseTelegramMessage(input string) (output string)
- type Bot
- type Command
- type Flag
- type Level
- type Logger
Constants ¶
This section is empty.
Variables ¶
var StandardLogger = Logger{ Format: "2006-01-02 15:04:05 — ", Output: os.Stdout, Levels: map[string]Level{ "debug": {"💾", color.New(color.FgWhite)}, "info": {"▶", color.New(color.FgCyan)}, "success": {"✅", color.New(color.FgHiGreen)}, "error": {"‼", color.New(color.FgRed)}, }, }
StandardLogger is the default logger for the app, with predetermined parameters and levels
var TempDir string
var WorkDir string
Functions ¶
func Fatal ¶
func Fatal(format string, a ...interface{})
Fatal prints an error log using the StandardLogger and exists the program
func LoadEnv ¶
func LoadEnv(path string)
LoadEnv loads all the environment variables stored in a .env file
func LogDebug ¶
func LogDebug(format string, a ...interface{})
LogDebug prints a debug log using the StandardLogger (if debug mode is enabled)
func LogError ¶
func LogError(format string, a ...interface{})
LogError prints an error log using the StandardLogger (if debug mode is enabled)
func LogInfo ¶
func LogInfo(format string, a ...interface{})
LogInfo prints an information log using the StandardLogger
func LogSuccess ¶
func LogSuccess(format string, a ...interface{})
LogSuccess prints a success log using the StandardLogger
func OpenCache ¶
func OpenCache() (cache *redis.Client)
OpenCache creates the Redis client and connects to the cache
func ParseTelegramMessage ¶
ParseTelegramMessage escapes all the characters required to print MarkdownV2 content
Types ¶
type Bot ¶
type Bot struct { // The Telegram API that is merged into our structure *telegram.BotAPI // A list of the slash commands available to the user Commands map[string]Command // The Redis client the bot will connect to Cache *redis.Client }
Bot is a structure that holds the Telegram API and other assets and is unique
type Command ¶
type Command struct { // Name of the command as shown in Telegram UI Name string // A complete description of the command to show in the help message Description string // The list of flags that can be passed by the user Flags map[string]Flag // The command actions Execute func(bot *Bot, update *telegram.Update, chatID int64, args []string, flags map[string]interface{}) error }
Command describes a Telegram commands with all its information
type Flag ¶
type Flag struct { // A complete description of the flag to show in the help message Description string // Default value of the flag. Currently supported types: string, integer, float Value interface{} // A list of accepted strings for this flag Enum *[]string }
Flag holds the data of a command flag, that's to say an optional parameter passed at the beginning
type Logger ¶
type Logger struct { // Format used for the date, uses `time` package Format string // Print all debug and error messages or not Debug bool // Where to print the logs Output io.Writer // List of the log levels (debug, info, success and error) Levels map[string]Level }
Logger is an instance that displays logs with a defined style in the console