gobotapi

package module
v1.6.7 Latest Latest
Warning

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

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

README



AutoGenerated Telegram BotAPI Framework for GoLang
Examples Documentation Sources

GoBotAPI

pkg.go.dev GO Version GitHub OS Architectures

An elegant and modern BotAPI Framework for GoLang

package main

import "github.com/GoBotApiOfficial/gobotapi"
import "github.com/GoBotApiOfficial/gobotapi/types"
import "github.com/GoBotApiOfficial/gobotapi/methods"

func main() {
    client := gobotapi.NewClient("YOUR_TOKEN")
    client.OnMessage(func(ctx *gobotapi.Client, message types.Message) {
        ctx.Invoke(&methods.SendMessage{
            ChatID: message.Chat.ID,
            Text:   "Hello World!",
        })
    })
    client.Run()
}

GoBotAPI is a modern and elegant AutoGenerated BotAPI Framework. This Framework provides a pure Go implementation without any external libs

In addition to the official API, this Framework also provides some high-level functions that make it easier to use the API.

The Telegram API scheme depends on your build, but if you don't want to compile by your self you can use the package compiled from pkg.go.dev/github.com/GoBotApiOfficial/gobotapi.

How to install?

Here's how to add the GoBotApi Framework to your project, the command are given below:

go get -u github.com/GoBotApiOfficial/gobotapi

GoBotAPI Generator

GO Version GitHub OS Architectures

GoBotAPI Generator is the generator for the GoBotAPI Framework. It generates a new BotAPI Framework from the given BotAPI schema.

How to use?

Just run the binary file from releases and choose the binary file you want to use on your operating system.

Credits

Big thanks to @Laky-64 for making this project possible, special thanks to @geiccobs for his own package as starting point for this project, also thanks to @empijei for help about the project design and to @LucaTheHacker for optimizations.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Idle

func Idle()

Types

type BasicClient

type BasicClient struct {
	BotApiConfig        Config
	NoUpdates           bool
	DownloadRefreshRate time.Duration
	AllowedUpdates      []string
	Beta                bool
	SleepThreshold      int
	MaxGoRoutines       int
	LoggingLevel        logger.LogLevel
	LoggerColorful      bool
	LoggerWriter        Writer
	AntiFloodData       map[int64]*rawTypes.AntiFloodData
	// contains filtered or unexported fields
}

func (*BasicClient) Clone

func (ctx *BasicClient) Clone(token string, dropUpdates bool, maxConnections int) error

func (*BasicClient) OnAnyEditedMessage

func (ctx *BasicClient) OnAnyEditedMessage(handler func(client *Client, update types.Message))

func (*BasicClient) OnAnyMessage

func (ctx *BasicClient) OnAnyMessage(handler func(client *Client, update types.Message))

func (*BasicClient) OnAnyMessageEvent

func (ctx *BasicClient) OnAnyMessageEvent(handler func(client *Client, update types.Message))

func (*BasicClient) OnBusinessConnection added in v1.6.7

func (ctx *BasicClient) OnBusinessConnection(handler func(client *Client, update types.BusinessConnection))

func (*BasicClient) OnBusinessMessage added in v1.6.7

func (ctx *BasicClient) OnBusinessMessage(handler func(client *Client, update types.Message))

func (*BasicClient) OnCallbackQuery

func (ctx *BasicClient) OnCallbackQuery(handler func(client *Client, update types.CallbackQuery))

func (*BasicClient) OnChannelPost

func (ctx *BasicClient) OnChannelPost(handler func(client *Client, update types.Message))

func (*BasicClient) OnChatBoost added in v1.6.3

func (ctx *BasicClient) OnChatBoost(handler func(client *Client, update types.ChatBoostUpdated))

func (*BasicClient) OnChatJoinRequest

func (ctx *BasicClient) OnChatJoinRequest(handler func(client *Client, update types.ChatJoinRequest))

func (*BasicClient) OnChatMember

func (ctx *BasicClient) OnChatMember(handler func(client *Client, update types.ChatMemberUpdated))

func (*BasicClient) OnChosenInlineResult

func (ctx *BasicClient) OnChosenInlineResult(handler func(client *Client, update types.ChosenInlineResult))

func (*BasicClient) OnDeletedBusinessMessages added in v1.6.7

func (ctx *BasicClient) OnDeletedBusinessMessages(handler func(client *Client, update types.BusinessMessagesDeleted))

func (*BasicClient) OnEditedBusinessMessage added in v1.6.7

func (ctx *BasicClient) OnEditedBusinessMessage(handler func(client *Client, update types.Message))

func (*BasicClient) OnEditedChannelPost

func (ctx *BasicClient) OnEditedChannelPost(handler func(client *Client, update types.Message))

func (*BasicClient) OnEditedMessage

func (ctx *BasicClient) OnEditedMessage(handler func(client *Client, update types.Message))

func (*BasicClient) OnInlineQuery

func (ctx *BasicClient) OnInlineQuery(handler func(client *Client, update types.InlineQuery))

func (*BasicClient) OnMessage

func (ctx *BasicClient) OnMessage(handler func(client *Client, update types.Message))

func (*BasicClient) OnMessageReaction added in v1.6.3

func (ctx *BasicClient) OnMessageReaction(handler func(client *Client, update types.MessageReactionUpdated))

func (*BasicClient) OnMessageReactionCount added in v1.6.3

func (ctx *BasicClient) OnMessageReactionCount(handler func(client *Client, update types.MessageReactionCountUpdated))

func (*BasicClient) OnMyChatMember

func (ctx *BasicClient) OnMyChatMember(handler func(client *Client, update types.ChatMemberUpdated))

func (*BasicClient) OnPoll

func (ctx *BasicClient) OnPoll(handler func(client *Client, update types.Poll))

func (*BasicClient) OnPollAnswer

func (ctx *BasicClient) OnPollAnswer(handler func(client *Client, update types.PollAnswer))

func (*BasicClient) OnPreCheckoutQuery

func (ctx *BasicClient) OnPreCheckoutQuery(handler func(client *Client, update types.PreCheckoutQuery))

func (*BasicClient) OnRawUpdate

func (ctx *BasicClient) OnRawUpdate(handler func(client *Client, update types.Update))

func (*BasicClient) OnRemovedChatBoost added in v1.6.3

func (ctx *BasicClient) OnRemovedChatBoost(handler func(client *Client, update types.ChatBoostRemoved))

func (*BasicClient) OnShippingQuery

func (ctx *BasicClient) OnShippingQuery(handler func(client *Client, update types.ShippingQuery))

func (*BasicClient) SetupBotAPI

func (ctx *BasicClient) SetupBotAPI(hostName string, port int, https bool)

func (*BasicClient) Stop

func (ctx *BasicClient) Stop()

type Client

type Client struct {
	*BasicClient

	Token string
	// contains filtered or unexported fields
}

func (*Client) DownloadBytes

func (ctx *Client) DownloadBytes(fileId string, progress rawTypes.ProgressCallable) ([]byte, error)

func (*Client) DownloadFile

func (ctx *Client) DownloadFile(fileId, filePath string, progress rawTypes.ProgressCallable) error

func (*Client) DownloadMedia

func (ctx *Client) DownloadMedia(message types.Message, filePath string, progress rawTypes.ProgressCallable) error

func (*Client) Invoke

func (ctx *Client) Invoke(method rawTypes.Method) (*rawTypes.Result, error)

func (*Client) IsRunning

func (ctx *Client) IsRunning() bool

func (*Client) Self

func (ctx *Client) Self() types.User

type Config

type Config struct {
	HostName string
	Port     int
	HTTPS    bool
}

type Logger

type Logger interface {
	Debug(*Client, string, ...any)
	Info(*Client, string, ...any)
	Warn(*Client, string, ...any)
	Error(*Client, string, ...any)
}

func NewLogger

func NewLogger(writer Writer, config logger.Config) Logger

type PollingClient

type PollingClient struct {
	*Client
	PollingTimeout time.Duration
	// contains filtered or unexported fields
}

func NewClient

func NewClient(token string) *PollingClient

func (*PollingClient) Run

func (ctx *PollingClient) Run() error

func (*PollingClient) Start

func (ctx *PollingClient) Start() error

type ServerConfig

type ServerConfig struct {
	HostName             string
	Port                 int
	IsLocalWebHookServer bool
}

type WebhookClient

type WebhookClient struct {
	*BasicClient
	WebhookConfig *WebhookConfig
	// contains filtered or unexported fields
}

func NewWebhook

func NewWebhook(hostname string, port int, isLocalWebhookServer bool) *WebhookClient

func NewWebhookWithCert

func NewWebhookWithCert(hostname string, port int, certFile, keyFile string) (*WebhookClient, error)

func (*WebhookClient) Run

func (ctx *WebhookClient) Run() error

func (*WebhookClient) Start

func (ctx *WebhookClient) Start() error

func (*WebhookClient) Stop

func (ctx *WebhookClient) Stop()

type WebhookConfig

type WebhookConfig struct {
	Config          ServerConfig
	CertificateFile string
	KeyFile         string
	// contains filtered or unexported fields
}

func (*WebhookConfig) GetAddress

func (ctx *WebhookConfig) GetAddress() string

type Writer

type Writer interface {
	Printf(string, ...any)
}

Directories

Path Synopsis
raw

Jump to

Keyboard shortcuts

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