gobotapi

package module
v1.5.2 Latest Latest
Warning

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

Go to latest
Published: May 27, 2023 License: GPL-3.0 Imports: 24 Imported by: 0

README

gopher logo

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/Squirrel-Network/gobotapi"
import "github.com/Squirrel-Network/gobotapi/types"
import "github.com/Squirrel-Network/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/Squirrel-Network/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/Squirrel-Network/gobotapi

gopher logo

Releases Sources

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.

Just because the thanks aren't enough... Huge thanks to @MikiMleam for the cool logo and to @BluLupo for helping to fix some stuff.

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) 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) 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) 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) 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) 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
}

type WebhookClient

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

func NewWebhook

func NewWebhook(hostname string, port int) *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