utils

package
v0.0.0-...-6d47440 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2025 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultFastHTTPCaller = &FastHTTPCaller{
	Client: &fasthttp.Client{
		ReadBufferSize:  16 * 1024,
		MaxConnsPerHost: 1024,
	},
}
View Source
var ErrMaxRetryAttempts = errors.New("max retry attempts reached")

Functions

func EscapeHTML

func EscapeHTML(s string) string

func FormatText

func FormatText(text string, entities []telego.MessageEntity) string

func RandomString

func RandomString(n int) string

func ReleaseRequestResources

func ReleaseRequestResources(request *fasthttp.Request, response *fasthttp.Response)

func Request

func Request(Link string, params RequestParams) (*fasthttp.Request, *fasthttp.Response, error)

func ResizeSticker

func ResizeSticker(input []byte) (*os.File, error)

func ResizeThumbnail

func ResizeThumbnail(thumbnail *os.File) error

func SanitizeString

func SanitizeString(input string) string

Some file systems do not support certain characters in file names.

Types

type FastHTTPCaller

type FastHTTPCaller struct {
	Client *fasthttp.Client
}

func (FastHTTPCaller) Call

type RequestParams

type RequestParams struct {
	Method     string            // "GET", "OPTIONS" or "POST"
	Redirects  int               // Number of redirects to follow
	Proxy      bool              // Use proxy for the request
	Headers    map[string]string // Common headers for both GET and POST
	Query      map[string]string // Query parameters for GET
	BodyString []string          // Body of the request for POST
}

type RetryCaller

type RetryCaller struct {
	Caller       *FastHTTPCaller
	MaxAttempts  int
	ExponentBase float64
	StartDelay   time.Duration
	MaxDelay     time.Duration
}

func (*RetryCaller) Request

func (r *RetryCaller) Request(url string, params RequestParams) (*fasthttp.Request, *fasthttp.Response, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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