utils

package
v0.9.20 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2024 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const MinSendCommandParts = 3

MinSendCommandParts is minimal count of space-separated parts for !pm send command

Variables

View Source
var ErrInvalidArgs = fmt.Errorf("invalid arguments")

ErrInvalidArgs returned when a command's arguments are invalid

Functions

func AddrIP added in v0.9.10

func AddrIP(addr net.Addr) string

AddrIP returns IP from a network address

func Bool

func Bool(str string) bool

Bool converts string to boolean

func Chunks added in v0.9.16

func Chunks[T any](slice []T, chunkSize int) [][]T

Chunks divides slice by chunks with specified size

func EmailParts added in v0.9.16

func EmailParts(email string) (mailbox, sub, hostname string)

EmailParts parses email address into mailbox, subaddress, and hostname

func EmailsList added in v0.9.9

func EmailsList(mailbox, domain string) string

EmailsList returns human-readable list of mailbox's emails for all available domains

func Hostname

func Hostname(email string) string

Hostname returns hostname part from email address

func Int added in v0.9.9

func Int(str string) int

Int converts string to integer

func Int64 added in v0.9.15

func Int64(str string) int64

Int64 converts string into int64

func Mailbox

func Mailbox(email string) string

Mailbox returns mailbox part from email address

func MapKeys added in v0.9.16

func MapKeys[V any](data map[string]V) []string

MapKeys returns sorted keys of the map

func ParseSend added in v0.9.1

func ParseSend(commandSlice []string) (to, subject, body string, err error)

ParseSend parses "!pm send" command, returns to, subject, body, err

func SanitizeBoolString

func SanitizeBoolString(str string) string

SanitizeBoolString converts string to boolean and back to string

func SanitizeDomain added in v0.9.9

func SanitizeDomain(domain string) string

SanitizeDomain checks that input domain is available for use

func SanitizeIntString added in v0.9.9

func SanitizeIntString(str string) string

SanitizeBoolString converts string to integer and back to string

func SanitizeStringSlice added in v0.9.6

func SanitizeStringSlice(str string) string

SanitizeBoolString converts string to slice and back to string

func SanitizeURL added in v0.9.19

func SanitizeURL(str string) string

SanitizeURL checks that input URL is valid

func SetDomains added in v0.9.9

func SetDomains(slice []string)

SetDomains for later use

func SliceString added in v0.9.15

func SliceString(strs []string) string

SliceString converts slice into comma-separated string

func StringSlice added in v0.9.6

func StringSlice(str string) []string

StringSlice converts comma-separated string to slice

func Subaddress added in v0.9.16

func Subaddress(email string) string

Subaddress returns sub address part form email address

Types

type File

type File struct {
	Name    string
	Type    string
	MsgType event.MessageType
	Length  int
	Content []byte
}

func NewFile

func NewFile(name string, content []byte) *File

func (*File) Convert

func (f *File) Convert() *mautrix.ReqUploadMedia

type Mutex added in v0.9.10

type Mutex map[string]*sync.Mutex

Mutex map

func NewMutex added in v0.9.10

func NewMutex() Mutex

NewMutex map

func (Mutex) Lock added in v0.9.10

func (m Mutex) Lock(key string)

Lock by key

func (Mutex) Unlock added in v0.9.10

func (m Mutex) Unlock(key string)

Unlock by key

Jump to

Keyboard shortcuts

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