core

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var UserAgent = fmt.Sprintf("%s/%s (%s %s/%s)", name, version,
	runtime.Version(), runtime.GOOS, runtime.GOARCH)

Functions

func Bind

func Bind(bot interface{}, withContext bool, token string)

Bind create invoke functions for all function type fields on bot.

Types

type Agent

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

The underlying API performer

func NewAgent

func NewAgent(client *http.Client) *Agent

func (*Agent) Invoke

func (a *Agent) Invoke(ctx context.Context, url string, params, result interface{}) (err error)

Invoke the API.

type ApiParameters

type ApiParameters interface {
	// Make HTTP request for specific URL.
	RequestFor(ctx context.Context, url string) (req *http.Request, err error)
}

All API paramaeters should implement this interface.

type ApiResponse

type ApiResponse struct {
	// Success flag.
	Ok bool `json:"ok"`
	// Result data when successful.
	Result json.RawMessage `json:"result"`
	// Error code.
	ErrorCode int `json:"error_code"`
	// Human-readable error description.
	Description string `json:"description"`
	// Extend information for unsuccessful request.
	Parameters *ResponseParameters `json:"parameters"`
}

type ResponseParameters

type ResponseParameters struct {
	// Target chat id has been upgrade to the specific id.
	MigrateToChatId int64 `json:"migrate_to_chat_id"`
	// Next request should be schedule after the specific seconds.
	RetryAfter int `json:"retry_after"`
}

Jump to

Keyboard shortcuts

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