gobotapi

package module
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2023 License: GPL-3.0 Imports: 24 Imported by: 2

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 added in v1.2.9

func Idle()

Types

type BasicClient added in v1.2.0

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 added in v1.2.0

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

func (*BasicClient) OnAnyEditedMessage added in v1.3.11

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

func (*BasicClient) OnAnyMessage added in v1.3.11

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

func (*BasicClient) OnAnyMessageEvent added in v1.4.1

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

func (*BasicClient) OnCallbackQuery added in v1.2.0

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

func (*BasicClient) OnChannelPost added in v1.2.0

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

func (*BasicClient) OnChatJoinRequest added in v1.2.0

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

func (*BasicClient) OnChatMember added in v1.2.0

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

func (*BasicClient) OnChosenInlineResult added in v1.2.0

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

func (*BasicClient) OnEditedChannelPost added in v1.2.0

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

func (*BasicClient) OnEditedMessage added in v1.2.0

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

func (*BasicClient) OnInlineQuery added in v1.2.0

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

func (*BasicClient) OnMessage added in v1.2.0

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

func (*BasicClient) OnMyChatMember added in v1.2.0

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

func (*BasicClient) OnPoll added in v1.2.0

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

func (*BasicClient) OnPollAnswer added in v1.2.0

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

func (*BasicClient) OnPreCheckoutQuery added in v1.2.0

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

func (*BasicClient) OnRawUpdate added in v1.2.0

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

func (*BasicClient) OnShippingQuery added in v1.2.0

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

func (*BasicClient) SetupBotAPI added in v1.2.0

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

func (*BasicClient) Stop added in v1.2.0

func (ctx *BasicClient) Stop()

type Client

type Client struct {
	*BasicClient

	Token string
	// contains filtered or unexported fields
}

func (*Client) DownloadBytes added in v1.0.8

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

func (*Client) DownloadFile added in v1.0.8

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

func (*Client) DownloadMedia added in v1.1.2

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 added in v1.1.12

func (ctx *Client) IsRunning() bool

func (*Client) Self added in v1.1.12

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

type Config

type Config struct {
	HostName string
	Port     int
	HTTPS    bool
}

type Logger added in v1.3.0

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

func NewLogger added in v1.3.0

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

type PollingClient added in v1.2.0

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

func NewClient

func NewClient(token string) *PollingClient

func (*PollingClient) Run added in v1.2.0

func (ctx *PollingClient) Run() error

func (*PollingClient) Start added in v1.2.0

func (ctx *PollingClient) Start() error

type ServerConfig added in v1.2.0

type ServerConfig struct {
	HostName string
	Port     int
}

type WebhookClient added in v1.2.0

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

func NewWebhook added in v1.2.0

func NewWebhook(hostname string, port int) *WebhookClient

func NewWebhookWithCert added in v1.2.0

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

func (*WebhookClient) Run added in v1.2.0

func (ctx *WebhookClient) Run() error

func (*WebhookClient) Start added in v1.2.0

func (ctx *WebhookClient) Start() error

func (*WebhookClient) Stop added in v1.2.0

func (ctx *WebhookClient) Stop()

type WebhookConfig added in v1.2.0

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

func (*WebhookConfig) GetAddress added in v1.2.0

func (ctx *WebhookConfig) GetAddress() string

type Writer added in v1.3.0

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