formatting

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const ParseMode = tgbotapi.ModeMarkdownV2

Variables

View Source
var (
	InternalError    = Escape("Internal error occured.")
	PermissionDenied = Escape("Permission denied.")
	UsageRestricted  = Escape("Bot usage is currently restricted.")
)
View Source
var ErrInvalidTimeFormat = errors.New("invalid time format")

Functions

func Bold added in v0.0.2

func Bold(s string) string

func Escape added in v0.0.2

func Escape(s string) string

Escape makes arbitrary text valid when parsed with ParseMode.

func Escapef added in v0.0.2

func Escapef(format string, a ...any) string

Escapef is a formatted version of Escape, but it does not escape a. This means that these values must be valid when parsed via ParseMode.

func FormatCommandHelp added in v0.0.2

func FormatCommandHelp(cmd commandtypes.Desc) string

func FormatCommandShortHelp added in v0.0.2

func FormatCommandShortHelp(cmd commandtypes.Desc) string

func FormatCommandUsage added in v0.0.2

func FormatCommandUsage(cmd commandtypes.Desc) string

func FormatHelp added in v0.0.2

func FormatHelp(cmds []commandtypes.Desc) string

func FormatMessageCreated added in v0.0.2

func FormatMessageCreated(id string) string

func FormatMessages

func FormatMessages(header string, msgs []*standup.Message) string

FormatMessages formats a list of messages for the report. If present, header must be valid when parsed with ParseMode (see Escape).

func Mono added in v0.0.2

func Mono(s string) string

func MustRenderTemplate added in v0.0.2

func MustRenderTemplate(tmpl string, data any) string

MustRenderTemplate acts like RenderTemplate, but panics on errors.

func ParseTime

func ParseTime(s string, now time.Time) (time.Time, error)

func RenderTemplate added in v0.0.2

func RenderTemplate(tmpl string, data any) (string, error)

RenderTemplate renders text/template.Template tmpl. All plaint text nodes of the template are escaped via Escape. The following functions are also availible in template context:

- "bold" -> Bold

- "mono" -> Mono

- "esc" -> Escape

Types

type Printable added in v0.0.2

type Printable interface {
	Printable() string
}

type SyntaxError added in v0.0.2

type SyntaxError struct {
	Msg string
	Cmd *commandtypes.Desc
}

func NewCommandSyntaxErrorf added in v0.0.2

func NewCommandSyntaxErrorf(cmd commandtypes.Desc, format string, a ...any) SyntaxError

func NewSyntaxErrorf added in v0.0.2

func NewSyntaxErrorf(format string, a ...any) SyntaxError

func (SyntaxError) Error added in v0.0.2

func (e SyntaxError) Error() string

func (SyntaxError) Printable added in v0.0.2

func (e SyntaxError) Printable() string

Jump to

Keyboard shortcuts

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