Documentation
¶
Index ¶
- func AsMap(input interface{}) map[string]interface{}
- func BotIDFromToken(token string) string
- func Dump(input map[string]interface{})
- func IsBool(value string) bool
- func IsInt(value string) bool
- func KeyExists(m map[string]interface{}, key string) bool
- func MakeError(code int, message string) map[string]interface{}
- func MakeObject(requestType string, params Params) map[string]interface{}
- func Marshal(input map[string]interface{}) (string, error)
- func MarshalWithIndent(input map[string]interface{}) (string, error)
- func PanicOnErr(err interface{}, msg string, v interface{}, exit bool)
- func Type(update map[string]interface{}) string
- func Unmarshal(input string) (map[string]interface{}, error)
- func UnmarshalWithTarget(input []byte, target interface{}) error
- func UnsafeMarshal(input map[string]interface{}) string
- func UnsafeMarshalWithIndent(input map[string]interface{}) string
- func UnsafeUnmarshal(input string) map[string]interface{}
- type IdGenerator
- type Params
- type SafeResultsMap
- func (srm *SafeResultsMap) ClearChannels(send_abort bool)
- func (srm *SafeResultsMap) Delete(key string, send_abort bool)
- func (srm *SafeResultsMap) Get(key string) (chan map[string]interface{}, bool)
- func (srm *SafeResultsMap) Make(key string) chan map[string]interface{}
- func (srm *SafeResultsMap) SafeSend(ch chan<- map[string]interface{}, value map[string]interface{})
- type Scheduler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AsMap ¶
func AsMap(input interface{}) map[string]interface{}
AsMap attempts to convert the provided input to a map[string]interface{}.
If the conversion is successful, it returns the map; otherwise, it returns nil.
func BotIDFromToken ¶
BotIDFromToken extracts and returns the bot ID from the provided token string.
If the token is longer than 80 characters or does not contain ':', it returns an empty string.
func KeyExists ¶
KeyExists checks whether the specified key exists in the given map[string]interface{}.
It returns true if the key exists, otherwise false.
func MakeObject ¶
MakeObject creates a map with the given requestType and additional parameters.
func Marshal ¶
Marshal encodes the provided map[string]interface{} input into a JSON string.
If an error occurs during encoding, it returns an empty string and the error.
func MarshalWithIndent ¶
MarshalWithIndent encodes the provided map[string]interface{} input into a 4-indented JSON string.
If an error occurs during encoding, it returns an empty string and the error.
func PanicOnErr ¶
PanicOnErr checks the error or boolean value and either panics or exits based on the exit flag.
func Type ¶
Type returns the "@type" field from the provided TDLib object as a string.
If the "@type" field is missing, it returns an empty string.
func Unmarshal ¶
Unmarshal decodes the input JSON string into a map[string]interface{}.
If an error occurs during decoding, it returns nil and the error.
func UnmarshalWithTarget ¶ added in v0.1.7
UnmarshalWithTarget decodes the input JSON string into the target struct. The target must be a pointer to a struct.
If an error occurs during decoding, it returns the error.
func UnsafeMarshal ¶
UnsafeMarshal encodes the provided map[string]interface{} input into a JSON string.
If an error occurs during encoding, it prints the error and returns an empty string.
func UnsafeMarshalWithIndent ¶
UnsafeMarshalWithIndent encodes the provided map[string]interface{} input into an indented JSON string.
If an error occurs during encoding, it prints the error and returns an empty string.
func UnsafeUnmarshal ¶
UnsafeUnmarshal decodes the input JSON string into a map[string]interface{}.
If an error occurs during decoding, it prints the error and returns nil.
Types ¶
type IdGenerator ¶
type IdGenerator struct {
// contains filtered or unexported fields
}
IdGenerator is a thread-safe generator for unique request IDs.
func NewIdGenerator ¶
func NewIdGenerator() *IdGenerator
NewIdGenerator creates and returns a new instance of IdGenerator,
func (*IdGenerator) GenerateID ¶
func (id *IdGenerator) GenerateID() int
GenerateID increments the current request ID and returns the new value.
This method is thread-safe.
type Params ¶
type Params map[string]interface{}
Params represents a map of string keys to interface{} values, used to store various parameters in requests and responses.
type SafeResultsMap ¶
type SafeResultsMap struct {
// contains filtered or unexported fields
}
SafeResultsMap is a thread-safe map for managing channels associated with TDLib responses to requests.
func NewSafeResultsMap ¶
func NewSafeResultsMap() *SafeResultsMap
NewSafeResultsMap creates and returns a new SafeResultsMap instance.
func (*SafeResultsMap) ClearChannels ¶
func (srm *SafeResultsMap) ClearChannels(send_abort bool)
ClearChannels closes all channels in the SafeResultsMap and deletes them.
If send_abort is true, it sends TDLib "Request aborted" error to each channel before closing it.
func (*SafeResultsMap) Delete ¶
func (srm *SafeResultsMap) Delete(key string, send_abort bool)
Delete removes the channel for the specified key, closing it and optionally sending an abort message.
func (*SafeResultsMap) Get ¶
func (srm *SafeResultsMap) Get(key string) (chan map[string]interface{}, bool)
Get retrieves the channel for the specified key.
func (*SafeResultsMap) Make ¶
func (srm *SafeResultsMap) Make(key string) chan map[string]interface{}
Make creates and returns a new channel for the specified key.
func (*SafeResultsMap) SafeSend ¶
func (srm *SafeResultsMap) SafeSend(ch chan<- map[string]interface{}, value map[string]interface{})
SafeSend safely sends TDLib object to the channel, recovering if the channel is closed.
type Scheduler ¶ added in v0.1.9
type Scheduler struct {
// contains filtered or unexported fields
}