formater

package
v1.9.3 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DateFormatICal is the date format used by iCal
	DateFormatICal = "20060102T150405Z"
	// DateFormatDefault is the default date format used by remindme
	DateFormatDefault = "15:04 02.01.2006 (MST)"
)

Variables

This section is empty.

Functions

func EqMessageType

func EqMessageType(a, b []database.MessageType) bool

EqMessageType tests for equality of two message type lists (entries must have same order)

func GetHomeserverFromUserID

func GetHomeserverFromUserID(userID string) string

GetHomeserverFromUserID returns the homeserver from a user id

func GetMatrixLinkForUser

func GetMatrixLinkForUser(userID string) string

GetMatrixLinkForUser creates a clickable link pointing to the given user id

func GetSuffixInt

func GetSuffixInt(value string) (int, error)

GetSuffixInt returns a suffixed integer in the given string value

func GetUsernameFromUserIdentifier

func GetUsernameFromUserIdentifier(userID string) string

GetUSerNameFromUserIdentififer extracts the username from the user identifier string. E.g. @testuser:matrix.org will result in testuser

func MinutesToIcalRecurrenceRule

func MinutesToIcalRecurrenceRule(minutes uint64, occurences uint64) string

MinutesToIcalRecurrenceRule transfers the given minutes into an iCal recurrence rule https://icalendar.org/iCalendar-RFC-5545/3-8-5-3-recurrence-rule.html

func ParseTime

func ParseTime(msg string, channel *database.Channel, rawDate bool) (time.Time, error)

ParseTime parses the time into the local timezone of a channel. If no timezone is given it defaults to UTC. Days without a time specified default to 9:00

func ReminderToIcalEvent

func ReminderToIcalEvent(reminder *database.Reminder) string

ReminderToIcalEvent formats a reminder into an iCal event

func ReminderToMessage

func ReminderToMessage(reminder *database.Reminder) (message, messageHTML string)

func StripReply

func StripReply(msg string) string

StripReply removes the quoted reply from a message

func StripReplyFormatted

func StripReplyFormatted(msg string) string

StripReplyFormatted removes the quoted reply from a message

func TimeToHourAndMinute

func TimeToHourAndMinute(t time.Time) string

TimeToHourAndMinute converts a time object to an string with the hour and minute in 24h format

func ToLocalTime

func ToLocalTime(datetime time.Time, timezone string) string

ToLocalTime converts the time object to a localized time string

func ToNiceDuration

func ToNiceDuration(d time.Duration) string

ToNiceDuration formats a time.Duration into a nice string

Types

type Formater

type Formater struct {
	// contains filtered or unexported fields
}

Formater is a string builder with additional formating options

func (*Formater) Bold

func (f *Formater) Bold(text string)

Bold adds bold text

func (*Formater) BoldLine

func (f *Formater) BoldLine(text string)

BoldLine adds bold text

func (*Formater) Build

func (f *Formater) Build() (message, messageFormatted string)

Build returns the build formatted and unformatted messages

func (*Formater) DoubleNewLine

func (f *Formater) DoubleNewLine()

DoubleNewLine adds two new lines

func (*Formater) Italic added in v1.8.6

func (f *Formater) Italic(text string)

Italic adds italic text

func (*Formater) ItalicLine

func (f *Formater) ItalicLine(text string)

ItalicLine adds italic text

func (f *Formater) Link(linkText string, url string)

Link adds a link to the formater

func (*Formater) List

func (f *Formater) List(items []string)

List adds a list to the message

func (*Formater) NewLine

func (f *Formater) NewLine()

NewLine adds a new line

func (*Formater) QuoteLine

func (f *Formater) QuoteLine(text string)

QuoteLine quotes the text

func (*Formater) Spoiler

func (f *Formater) Spoiler(text string)

Spoiler adds a spoiler to the message

func (*Formater) SubTitle

func (f *Formater) SubTitle(title string)

SubTitle adds a subtitle to the formater

func (*Formater) Text

func (f *Formater) Text(text string)

Text adds the text

func (*Formater) TextLine

func (f *Formater) TextLine(text string)

TextLine adds the text

func (*Formater) Title

func (f *Formater) Title(title string)

Title adds a title to the formater

func (*Formater) Username

func (f *Formater) Username(username string)

Username adds a username reference to the message

Jump to

Keyboard shortcuts

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