telego

package module
v2.2.0 Latest Latest
Warning

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

Go to latest
Published: May 9, 2024 License: MIT Imports: 10 Imported by: 0

README

Telego

Go Reference example workflow Go Report Card Development status

A Go library for creating telegram bots.

telego logo inspired by Golang logo


Supporting Telego

If you like Telego and it has helped you to build your telegram bot easily 🫶🏼, then you can support it to get even better! You can support Telego by donating to the project or even giving it a star! Any kind of support is appreciated ❤️

If you want to donate to telego project and keep it running, click here


Upgrading to v2

Telego v2 is a ground breaking change in Telego. Many new features have been added and many methods declarations have been changed. Some methods have been completely deprecated. Please read the change log before upgrading to v2 and take extra caution while upgrading.


Features

  • Fast and reliable
  • Highly customizable
  • Webhook support
  • Full support for telegram bot api
  • Offers two different ways for managing the bot updates :
    1. Handlers.
    2. Special channels
  • Automatic poll management : You don't need to worry about poll updates. Telego takes care of that for you. Just create a poll, send it and sit back and monitor the poll update via a go channel.
  • You can create keyboards and inline keyboards easily.

Requirements

  • Go 1.18 or higher.
  • Small and basic knowledge about telegram bots.

Installation

Install the package into your $GOPATH with the go command from terminal :

$ go get -u github.com/SakoDroid/telego/v2@v2.1.0

Git needs to be installed on your computer.


Usage

Quick start

The following code creates a bot and starts receiving updates. If the update is a text message that contains "hi" the bot will respond "hi to you too!".

import (
   "fmt"

   bt "github.com/SakoDroid/telego/v2"
   cfg "github.com/SakoDroid/telego/v2/configs"
   objs "github.com/SakoDroid/telego/v2/objects"
)

func main() {

   bot, err := bt.NewBot(cfg.Default("your API key"))

   if err != nil {
   	panic(err)
   }

   // The general update channel.
   updateChannel := *(bot.GetUpdateChannel())

   // Adding a handler. Everytime the bot receives message "hi" in a private chat, it will respond "hi to you too".
   bot.AddHandler("hi", func(u *objs.Update) {
   	_, err := bot.SendMessage(u.Message.Chat.Id, "hi to you too", "", u.Message.MessageId, false, false)
   	if err != nil {
   		fmt.Println(err)
   	}
   }, "private")

   // Monitores any other update. (Updates that don't contain text message "hi" in a private chat)
   go func() {
   	for {
   		update := <-updateChannel
   		fmt.Println(update.Update_id)

   		//Some processing on the update
   	}
   }()

   bot.Run(true)
}

Step by step

Configuring the bot

First you need to import required libraries :

import (
   bt "github.com/SakoDroid/telego/v2"
   cfg "github.com/SakoDroid/telego/v2/configs"
   objs "github.com/SakoDroid/telego/v2/objects"
)

Then you need to create bot configs. You can use default configs by using Default(apiKey string) method of the configs package. This method generates a BotConfig that does not use webhook and queries the updates from the server every 300 mili seconds. You can create a BotConfig struct to access more options (including webhook).

BotConfigs struct is located in configs package and contains these fields :

/* This is the bot api server. If you dont have a local bot api server, use "configs.DefaultBotAPI" for this field. */

BotAPI string

/* The API key for your bot. You can get the api key (token) from botfather */

APIKey string

/* The settings related to getting updates from the api server. This field shoud only be populated when Webhook field is false, otherwise it is ignored. */

UpdateConfigs *UpdateConfigs

/* This field idicates if webhook should be used for receiving updates or not. */

Webhook bool

/* This field represents the configs related to webhook. */
WebHookConfigs *WebHookConfigs

/* All the logs related to bot will be written in this file. You can use configs.DefaultLogFile for default value. */

LogFileAddress string


// BlockedUsers is a list of blocked users.

BlockedUsers []BlockedUser `json:"blocked_users"`

/*Config name is the address of the config file. */
ConfigFile string `json:"config_name"`
Not using webhook

To create bot configs you need an UpdateConfigs to populate related field in BotConfigs. UpdateConfigs struct contains following fields :

/* Limits the number of updates to be retrieved. Values between 1-100 are accepted. Defaults to 100. */

 Limit int

 /*Timeout in seconds for long polling. Defaults to 0, i.e. usual short polling. Should be positive, short polling should be used for testing purposes only.*/

 Timeout int

 /* List of the update types you want your bot to receive. For example, specify [“message”, “edited_channel_post”, “callback_query”] to only receive updates of these types. See Update for a complete list of available update types. Specify an empty list to receive all update types except chat_member (default). If not specified, the previous setting will be used.
 Please note that this parameter doesn't affect updates created before the call to the getUpdates, so unwanted updates may be received for a short period of time.*/

 AllowedUpdates []string

 /*This field indicates the frequency to call getUpdates method. Default is one second*/

 UpdateFrequency time.Duration

You can use configs.DefaultUpdateConfigs() to create default update configs. Otherwise, you can create your own custom update configs. You can read

Using webhook

To use webhook you need a key file and a certificate file since webhook is based on HTTPS. Telegram bot API supports self-signed certificates. You can create a self-signed certificate using OpenSSL. Read this article to find out how.

To define the configs for webhook, WebHookConfigs struct should be used. It contains the following fields:

type WebHookConfigs struct {

	/*The web hook url.*/
	URL string

	/*The port that webhook server will run on. Telegram api only suppotrs 80,443,88,8443. 8443 is recommended. Pass 0 for default https port (443)*/
	Port int

	/*The address of the public key certificate file.*/
	KeyFile string

	/*The address of the certificate file.*/
	CertFile string

	/*The fixed IP address which will be used to send webhook requests instead of the IP address resolved through DNS*/
	IP string

	/*Maximum allowed number of simultaneous HTTPS connections to the webhook for update delivery, 1-100. Defaults to 40. Use lower values to limit the load on your bot's server, and higher values to increase your bot's throughput.*/
	MaxConnections int

	/*List of the update types you want your bot to receive. For example, specify [“message”, “edited_channel_post”, “callback_query”] to only receive updates of these types. See Update for a complete list of available update types. Specify an empty list to receive all update types except chat_member (default). If not specified, the previous setting will be used.
	Please note that this parameter doesnt affect updates created before the call to the getUpdates, so unwanted updates may be received for a short period of time.*/
	AllowedUpdates []string

	/*Pass True to drop all pending updates*/
	DropPendingUpdates bool
}

This struct is located in the configs package. To use webhook, first you need to create a WebHooKConfigs and populate it's fields. Then populate WebHookConfigs field of the BotConfigs with it. Thats all! We recommend using port 8443 for webhook, using 80 or 443 needs root permission which means your bot will have root permissions which is not safe. You can see an example code below :

Note : UpdateConfigs is no longer needed if you're using webhook. So leave this field empty.

import (
	bt "github.com/SakoDroid/telego/v2"
	cfg "github.com/SakoDroid/telego/v2/configs"
)

func main() {

	//WebHookConfigs. We are using 8443 port here.
	whcfg := &cfg.WebHookConfigs{
		URL:      "https://example.com:8443",
		IP:       "123.45.78.90",
		KeyFile:  "keyfile.key",
		CertFile: "certfile.crt",
		Port:     8443,
	}

	cf := cfg.BotConfigs{BotAPI: cfg.DefaultBotAPI, APIKey: "your api key", Webhook: true, WebHookConfigs: whcfg, LogFileAddress: cfg.DefaultLogFile}

	bot, err := bt.NewBot(&cf)
	if err != nil {
		panic(err)
	}

	bot.Run(true)
}
Loading and saving the configs

You can load the bot configs from config file or save it in the file using Load and Dump methods. Config file's name is config.json. These methods are located in configs package. In the example code below first we create a config, then save it and then load it again into a new config :

bc1 := configs.Default("API key")
_ := configs.Dump(bc1)

bc2, _ := configs.Load()

fmt.Println(reflect.DeepEqual(bc1, bc2)) //Prints true

Note: Since Telego 1.7.0 an option has been added which updates the bot configs every second. This option works while the bot is running and reads the configs from the configs.json file. This file is created automatically when the bot starts. With the help of this option you can change the bot configs even when the bot is up and running only by changing the config.json file, this means you don't need to stop the bot to change the configs or to remove a user from the block list.

Creating and starting the bot

After you have created BotConfigs you can create the bot by passing the BotConfigs struct you've created to NewBot method located in telego package. After bot is created call Run() method and your bot will start working and will receive updates from the api server:

Note : Webhook is not used in the example codes. Using webhook only changes the code related to creating the bot and receiving updates or sending data obviously won't be affected.

import (
   bt "github.com/SakoDroid/telego/v2"
   cfg "github.com/SakoDroid/telego/v2/configs"
   objs "github.com/SakoDroid/telego/v2/objects"
)

func main(){
   up := cfg.DefaultUpdateConfigs()
   
   cf := cfg.BotConfigs{BotAPI: cfg.DefaultBotAPI, APIKey: "your api key", UpdateConfigs: up, Webhook: false, LogFileAddress: cfg.DefaultLogFile}

   bot, err := bt.NewBot(&cf)
   if err != nil {
   	panic(err)
   }

   bot.Run(true)
}

Now that the bot is running it will receive updates from api server and passes them into UpdateChannel. So you can use this channel to know if an update is received from api server. You can get the channel via GetUpdateChannel() method of the bot :

import (
   bt "github.com/SakoDroid/telego/v2"
   cfg "github.com/SakoDroid/telego/v2/configs"
   objs "github.com/SakoDroid/telego/v2/objects"
)

func main(){
   up := cfg.DefaultUpdateConfigs()
   
   cf := cfg.BotConfigs{BotAPI: cfg.DefaultBotAPI, APIKey: "your api key", UpdateConfigs: up, Webhook: false, LogFileAddress: cfg.DefaultLogFile}

   bot, err := bt.NewBot(&cf)
   if err != nil {
   	panic(err)
   }

   updateChannel := *(bot.GetUpdateChannel())
   go func(){
       for {
           update := <- updateChannel
           //Do your own processing.
       }
   }()

   bot.Run(true)
}
Receiving updates
Handlers

You can use handlers for routing text messages. You specify a function and every time a text message is received which the handler's regex matches with the text, the specified function will be called. Function format should be like this exampleFunction(*objs.Update). To add a handler you simply call AddHandler(pattern string, handler func(*objs.Update), chatTypes ...string). Arguments :

  1. "Pattern" is the regex pattern which will be matched against the received text message.
  2. "chatType" : is a string array containing chat types which the handler will act on. It can be "private","group","supergroup","channel" and "all".
  3. "handler" : is the function that will be called.

Handlers are super easy to use; You can see an example in Quick start section.

Special channels

In Telego you can register special channels. Special channels are channels for a specific update type. Meaning this channels will be updated when the specified update type is received from api server, giving the developers a lot more flexibility. To use special channels you need to call RegisterChannel(chatId string, mediaType string) method of the advanced bot (so for using this method, first you should call AdvancedMode() method of the bot). This method is fully documented in the source code but we will describe it here too. This method takes two arguments :

  1. chatId : This is a string representing a certain chat which this channel will be dedicated to. This argument can be chat identification of a chat or username of a channel or supergroup. You can pass an empty string for this argument.
  2. mediaType : This argument specifies an update type which the channel will be dedicated to. For example if you pass "message", the returned channel will only be updated when an update containing message field [for a specified chat] is received. You can pass an empty string for this argument.

Note : Both arguments can be used together to create channels that will be updated only when a certain field (mediaType) is present in the received update for a specified chat (chatId).

Examples :

This method can be used in four ways :

  1. RegisterChannel("123456","message") : The returned channel will be updated when a message (text,photo,video ...) is received from a chat with "123456" as it's chat id.

  2. RegisterChannel("","message") : The returned channel will be updated every time a message is received from any chat.

  3. RegisterChannel("123456","") : The returned channel will be updated every time an update of any kind is received for the specified chat.

  4. RegisterChannel("","") : The returned is the global update channel which will be updated every time an update is received. You can get this channel by calling getUpdateChannel() method too.

Note : When a channel is registered it is not editable. Meaning that calling the RegisterChannel method with the same arguments won't create a new channel and the previously created channel will be returned.

Once a channel is created it cannot be edited, But it can be deleted. To delete a channel (unregister it) call UnRegisterChannel(chatId string,mediaType string) method of the AdvancedBot. If a channel has been registered for the given arguments it will be cleared.

Update receiving priority :

Since different types of channels and handlers may get involved it's important to know the priority of them. Meaning when an update is received which methods have higher priority to be executed and in case of channels which channels will be first considered to have the update passed into them. Basically this is how handlers and channels are prioritized :

  1. Handlers
  2. Chat channels :
    1. Update types
    2. General
  3. Global channels :
    1. Update types
    2. General channel

When an update is received, first it is compared against all the handlers. If a handler's regex matching is successful the handler will be executed. If not handler is successful then channels are checked. (Handlers don't have priority and every successful regex match is executed.)

After none of the handlers are executed, the update is checked to see if it contains chat information and if it does, channels registered for that chat are checked. If a channel is registered for the field that the update contains it will be passed into the channel. If no channel is registered for the field then it will be passed into the general channel for the chat.( For example lets assume you have called RegisterChannel("123456","message") method, in this case if an update for a chat that it's chat id is "123456" is received that contains message field, it will be passed into this channel. ) If this step fails (does not have chat information or no channel is registered for the chat) then the update type channels are checked and if the update contains a field that does have a channel registered for it the related field will be passed into the channel.(For example if the update contains message field and you have called RegisterChannel("","message") method, the update will be passed into the channel). If this step fails too then the update will be passed into general update channel.

To summarize :

Update is received -> Handlers
                          |
                          |
If no handler is executed |
                          |
                          |                                                / Specified update type channel
                     Chat channels (if update is relevant to a chat) ----- 
                             |                                             \ General chat channel
                             |
if chat channel check fails  |
                             |
                             |----------> General update type channels
                                                   |
                                                   |
                              if this check fails  |
                                                   |
                                                   |----------> General update channel
                              

Note :

Handlers and special channels can be used together. For example the below code add a handler for text message "hi". Every time the bot receives "hi" in a private chat it responds "hi to you too, send a location". Then it registers a channel for receiving messages in that chat and waits for the user to send a message. After message is received it sends the exact same location the user has sent back to the user :

import (
	"fmt"
	"strconv"

	bt "github.com/SakoDroid/telego/v2"
	cfg "github.com/SakoDroid/telego/v2/configs"
	objs "github.com/SakoDroid/telego/v2/objects"
)

func main() {
	up := cfg.DefaultUpdateConfigs()

	cf := cfg.BotConfigs{BotAPI: cfg.DefaultBotAPI, APIKey: "your api key", UpdateConfigs: up, Webhook: false, LogFileAddress: cfg.DefaultLogFile, ConfigFile: "configs.json"}

	bot, err := bt.NewBot(&cf)
	if err != nil {
		panic(err)
	}

	// The general update channel.
	updateChannel := *(bot.GetUpdateChannel())

	//Adding a handler. Everytime the bot receives message "hi" in a private chat, it will respond "hi to you too".

	bot.AddHandler("hi", func(u *objs.Update) {

		//Register channel for receiving messages from this chat.
		cc, _ := bot.AdvancedMode().RegisterChannel(strconv.Itoa(u.Message.Chat.Id), "message")

		//Sends back a message
		_, err := bot.SendMessage(u.Message.Chat.Id, "hi to you too, send me a location", "", u.Message.MessageId, false, false)
		if err != nil {
			fmt.Println(err)
		}

		//Waits for an update from this chat
		up := <-*cc

		//Sends back the received location
		_, err = bot.SendLocation(up.Message.Chat.Id, false, false, up.Message.Location.Latitude, up.Message.Location.Longitude, up.Message.Location.HorizontalAccuracy, up.Message.MessageId)

		if err != nil {
			fmt.Println(err)
		}
	}, "private")

	go func() {
		// Monitores any other update. (Updates that don't contain text message "hi" in a private chat)
		for {
			update := <-updateChannel

			//Some processing on the update
		}

	}()

	bot.Run(true)
}

Methods

To send back text or media (such as photo, video, gif, ...) you can use Send methods. There are several send methods such as SendMessage and SendPhoto. There is two ways to send back data to the client. First way is using unique chat ids (which are integers that are unique for each chat) to send data to private chats, groups and supergroups. Second way is using chat username which can be used to send back data to supergroups (with username) and channels. Methods that use username as chat id end with UN.

We will cover some methods below. All these methods are fully documented in the source code and will be described here briefly. In all methods you can ignore number arguments (int or float) by passing 0 and ignore string arguments by passing empty string ("").

  • Note : All bot methods are simplified to avoid unnecessary arguments. To access more options for each method you can call AdvancedMode() method of the bot that will return an advanced version of bot which will give you full access.
Text messages

To send back text you can use SendMessage (chat id) or SendMessageUN (username).

Formatting text messages

Telegram offers three ways for formatting a text. Formatting means adding style to the text, like bolding a text, adding a url, a link, mentioning a user and etc. These three ways are :

  1. HTML style formatting : You can write the text (can be a message or a caption) you want to send in HTML format and pass "HTML" as the parseMode or captionParseMode argument of the send method. See telegram documentation for HTML style formatting.

  2. Markdown style formatting : You can use markdown also to format your text or media caption. Write the text in markdown format and pass "MarkdownV2" or "Markdown" (according to the markdown syntax you've used) as the parseMode or captionParseMode arguements. See telegram documentation for Markdown style formatting.

  3. Message entities : Message entities can be used to format a text. Telego offers a tool for creating formatted texts called TextFormatter. Call GetTextFormatter() method. This method returns a TextFormatter that has a few methods for adding a styled text to the original text. TextFormatter assembles the text and returns it via GetText() method. You need to pass this text as the "text" or "caption" arguments and pass the returned value of GetEntities() method as the "entities" or "captionEntities" arguments of the ASend methods (located in advanced bot). The example below adds a normal text, a bold text, an italic text, a link, a mention and a spoiler to the text and sends it :

tf := bot.GetTextFormatter()
tf.AddNormal("normal text")
tf.AddMention("@someone_username")
tf.AddBold("bold text")
tf.AddItalic("italic text")
tf.AddSpoiler("spoiler text")
tf.AddTextLink("google", "https://google.com")
_, err := bot.AdvancedMode().ASendMessage(
        msg.Message.Chat.Id, tf.GetText(), "", msg.Message.MessageId,0, false, false, tf.GetEntities(),
        false, false, nil,
	)
Media messages

To send media types such as photo,video,gif,audio,voice,video note,mpeg4 gif,sticker and document you can use their specified method. In general there are three ways to send media :

  1. By file id : File id is a unique id for a file that already exists in telegram servers. Telegram bot api documentation recommends using file id.
  2. By URL : You can pass an HTTP url to send. The file will be downloaded in telegram servers, and then it will be sent to the specified chat.
  3. By file : You can send a file on your computer. The file will be uploaded to telegram servers, and then it will be sent to the specified chat.

Calling each media sending related method returns a MediaSender. MediaSender has all methods that are needed to send a media. For example lets send photo in our computer :

photoFile,err := os.Open("photo.jpg")

if err == nil{

   ms := bot.SendPhoto(chatId, messageId, "custom caption", "")

   _,err = ms.SendByFile(photoFile,false,false)

   if err != nil{
       fmt.Println(err)
   }

}
Media group messages

To send a group of medias (aka albums) first you need to create a MediaGroup by calling CreateAlbum(replyto int) method of the bot. MediaGroup has several methods for adding photo,video,audio and other media types to the album. Keep in mind that according to Telegram bot api documentation about media groups, documents and audio files can be only grouped in an album with messages of the same type. Also the media group must include 2-10 items. The code below shows how to create a media group, add some photo to it and send it :

mg := bot.CreateAlbum(messageId)

//Add a file on the computer.
fl,_ := os.Open("file.jpg")
pa1,_ := mg.AddPhoto("", "", nil)
err := pa1.AddByFile(fl)
if err != nil{
    fmt.Println(err)
}

//Add a photo by file id or url.
pa2,_ ;= mg.AddPhoto("","",nil)
err = pa2.AddByFileIdOrURL("fileId or HTTP url")
if err != nil{
    fmt.Println(err)
}

//Send the media group
_, err = mg.Send(chatId, false,false)

if err != nil {
   fmt.Println(err)
}
Polls

Telego library offers automatic poll management. When you create a poll and send the poll bot will receive updates about the poll. Whene you create a poll by CreatePoll method, it will return a Poll which has methods for managing the poll. You should keep the returned pointer (to Poll) somewhere because every time an update about a poll is received the bot will process the update and update the related poll and notifies user through a [bool]channel (which you can get by calling GetUpdateChannel method of the poll).

  • Note : If an update is received that contains update about a poll and the poll is not registered with the Polls map, the given update is passed into UpdateChannel of the bot. Otherwise, as described above, the related poll will be updated.

Let's see an example :

// A custom function that creates and sends a poll and listens to its updates.
func pollTest(chatId int) {

    // Creates the poll
	poll, _ := bot.CreatePoll(chatId, "How are you?", "regular")

    // Adds some options
	poll.AddOption("good")
	poll.AddOption("not bad")
	poll.AddOption("alright")
	poll.AddOption("bad")

    // Adds an explanation for the poll.
	poll.SetExplanation("This is just a test for telego framework", "", nil)

    // Sends the poll
	err := poll.Send(false,false, 0)

	if err != nil {
		fmt.Println(err)
	} else {

        //Starts waiting for updates and when poll is updated, the updated result of the bot is printed.
		ch := poll.GetUpdateChannel()
		for {
			<-*ch
			fmt.Println("poll updated.")
			for _, val := range poll.GetResult() {
				fmt.Println(val.Text, ":", val.VoterCount)
			}
		}
	}
}
Files

You can get information about a file that is stored in telegram servers and download it into your computer by calling GetFile method. If you want to download the file, pass true for download argument of the method. The below example downloads a received sticker from the user and saves it into the given file (read full documentation of the method for more information) :

//Receives upadate
update := <- updateChannel

//Get sticker file id
fi := update.Message.Sticker.FileId

//Open a file in the computer.
fl, _ := os.OpenFile("sticker.webp", os.O_CREATE|os.O_WRONLY, 0666)

//Gets the file info and downloads it.
_, err := bot.GetFile(fi, true, fl)
if err != nil {
    fmt.Println(err)
}
fl.Close()

Keyboards

In Telego you can create custom keyboards and inline keyboards easily with an amazing tool. Telegram has two types of keyboards :

  1. Custom keyboard : this type of keyboard will replace letter keyboard.
  2. Inline keyboard : this type of keyboard will be displayed below the message. (aka transparent keyboards)
Custom keyboards

You can create this type of keyboard by calling CreateKeyboard method of the bot. It has some arguments that are fully documented in the source code. Calling this method will return a keyboard which has several methods for adding buttons to it. After you have added the buttons you can pass the keyboard to a method that supports keyboards (for example : ASendMessage). Methods that support keyboards are located in the advanced bot. Example :

import (
	"fmt"

	bt "github.com/SakoDroid/telego/v2"
	cfg "github.com/SakoDroid/telego/v2/configs"
	objs "github.com/SakoDroid/telego/v2/objects"
)

func main() {
	up := cfg.DefaultUpdateConfigs()

	cf := cfg.BotConfigs{BotAPI: cfg.DefaultBotAPI, APIKey: "your api key", UpdateConfigs: up, Webhook: false, LogFileAddress: cfg.DefaultLogFile, ConfigFile: "configs.json"}

	bot, err := bt.NewBot(&cf)
	if err != nil {
		panic(err)
	}

	//The general update channel.
	updateChannel := *(bot.GetUpdateChannel())

	//Adding a handler. Everytime the bot receives message "hi" in a private chat, it will respond "hi to you too".
	bot.AddHandler("hi", func(u *objs.Update) {

		//Create the custom keyboard.
		kb := bot.CreateKeyboard(false, false, false, "type ...")

		//Add buttons to it. First argument is the button's text and the second one is the row number that the button will be added to it.
		kb.AddButton("button1", 1)
		kb.AddButton("button2", 1)
		kb.AddButton("button3", 2)

		//Sends the message along with the keyboard.
		_, err := bot.AdvancedMode().ASendMessage(u.Message.Chat.Id, "hi to you too", "", u.Message.MessageId,0, false, false, nil, false, false, kb)
		if err != nil {
			fmt.Println(err)
		}
	}, "private")

	go func() {
		//Monitores any other update. (Updates that don't contain text message "hi" in a private chat)
		for {
			update := <-updateChannel

			//Some processing on the update
		}
	}()

	bot.Run(true)
}

The result of the above code will be like this :

custom keyboards

Inline keyboards

Inline keyboards appear below the message they have been sent with. To create inline keyboards call CreateInlineKeyboard() method of the bot. Calling this method will return an inline keyboard which has several methods for adding buttons to it. After buttons have been added you can pass the inline keyboard to a method that supports keyboards (for example : ASendMessage). Methods that support keyboards are located in the advanced bot. A special button is callback button. When this button is pressed a callback query is sent to the bot that contains a data (callback data). The callback data is set when you add a callback button. Also you can define a handler for the button which will be executed every time this button is pressed. You can answer callback queries with AAsnwerCallbackQuery method of the advanced bot.

Example :

import (
	"fmt"

	bt "github.com/SakoDroid/telego/v2"
	cfg "github.com/SakoDroid/telego/v2/configs"
	objs "github.com/SakoDroid/telego/v2/objects"
)

func main() {
	up := cfg.DefaultUpdateConfigs()

	cf := cfg.BotConfigs{BotAPI: cfg.DefaultBotAPI, APIKey: "your api key", UpdateConfigs: up, Webhook: false, LogFileAddress: cfg.DefaultLogFile, ConfigFile: "configs.json"}

	bot, err := bt.NewBot(&cf)
	if err != nil {
		panic(err)
	}

	//The general update channel.
	updateChannel := *(bot.GetUpdateChannel())

	//Adding a handler. Everytime the bot receives message "hi" in a private chat, it will respond "hi to you too".
	bot.AddHandler("hi", func(u *objs.Update) {

		//Creates the inline keyboard
		kb := bot.CreateInlineKeyboard()

		//Adds a button that will open a url when pressed.
		kb.AddURLButton("url", "https://google.com", 1)

		//Adds a callback button with no handler
		kb.AddCallbackButton("call back without handler", "callback data 1", 2)

		//Adds a callback button with handler.
		kb.AddCallbackButtonHandler("callabck with handler", "callback data 2", 3, func(u *objs.Update) {
			_, err3 := bot.AdvancedMode().AAnswerCallbackQuery(u.CallbackQuery.Id, "callback received", true, "", 0)
			if err3 != nil {
				fmt.Println(err3)
			}
		})

		//Sends the message along with the keyboard.
		_, err := bot.AdvancedMode().ASendMessage(u.Message.Chat.Id, "hi to you too", "", u.Message.MessageId, 0, false, false, nil, false, false, kb)
		if err != nil {
			fmt.Println(err)
		}
	}, "private")

	go func() {
		//Monitores any other update. (Updates that don't contain text message "hi" in a private chat)
		for {
			update := <-updateChannel

			//Some processing on the update
		}
	}()

	bot.Run(true)
}

The result of the above code will be like this :

inline key boards

Inline queries

First, if you don't know what inline queries are, check here. For your bot to receive inline queries you should enable this feature via BotFather. To enable this option, send the /setinline command to BotFather and provide the placeholder text that the user will see in the input field after typing your bot’s name.

After you have enabled this option, you can register a channel for inline queries by calling RegisterChannel("","inline_query") method of the advanced bot. Any received inline query will be passed into this channel.

To respond to an inline query you need to use AAnswerInlineQuery method of the advanced bot. Calling this method will return an InlineQueryResponder which you can use to add up to 50 results and then send it. There are 20 different types of inline query results so there is 20 methods for adding a result. All this methods (except AddGame) have an argument called message which is the message that will be sent when user clicks the result you are adding. There are a few methods in InlineQueryResponder that create this message and they all start with Create (like CreateTextMessage). This methods will return an InputMessageContent that can be passed as message argument of the Add methods.

Let's see an example code. The code below registers a channel for inline queries and regardless of their query, adds an article result. If this result is pressed, a text message is sent which will say telego is a go library for creating telegram bots.

import (
	"fmt"

	bt "github.com/SakoDroid/telego/v2"
	cfg "github.com/SakoDroid/telego/v2/configs"
)

func main() {
	up := cfg.DefaultUpdateConfigs()

	cf := cfg.BotConfigs{BotAPI: cfg.DefaultBotAPI, APIKey: "your api key", UpdateConfigs: up, Webhook: false, LogFileAddress: cfg.DefaultLogFile, ConfigFile: "configs.json"}

	bot, err := bt.NewBot(&cf)
	if err != nil {
		panic(err)
	}

	//The general update channel.
	updateChannel := *(bot.GetUpdateChannel())

	//The inline query channel
	inlineQueryChannel, _ := bot.AdvancedMode().RegisterChannel("", "inline_query")

	go func() {
		for {
			select {

			case up := <-updateChannel:
				//Processing received updates other than inline queries.

			case in := <-*inlineQueryChannel:

				//Prints the query
				fmt.Println("inline query :", in.InlineQuery.Query)

				//Create an inline query responder
				iqs := bot.AdvancedMode().AAnswerInlineQuery(in.InlineQuery.Id, 0, false, "", "", "")

				//Create a text message
				message := iqs.CreateTextMessage(
					"telego is a go library for creating telegram bots",
					"",
					nil,
					false,
				)

				//Add an article
				iqs.AddArticle("12345", "telego library", "https://github.com/SakoDroid/telego/v2", "", "", 0, 0, false, message, nil)

				//Send the results
				_, err := iqs.Send()

				if err != nil {
					fmt.Println(err)
				}
			}
		}
	}()

	bot.Run(true)
}

This is how this code looks like in telegram ( "type test" that is seen in the input field can be set using BotFather ) :

inline query results

And when this result is clicked, the message in the photo below is sent :

Sent message

Stickers
Sticker Sets

To create stickers first you need to create an sticker set. An sticker set should have an owner, a name, a title and a sticker to begin with. According to telegram bot API,"name" is the short name of sticker set, to be used in t.me/addstickers/ URLs (e.g., animals). Can contain only English letters, digits and underscores. Must begin with a letter, can't contain consecutive underscores and must end in “_by_bot username”. <bot_username> is case insensitive. 1-64 characters. To create an sticker set, CreateNewStickerSet method should be called (old CreateStickerSet method has been deprecated). Pass the userId of the owner,name,title and the information of the first sticker of the set to this method to create the sticker set. Calling this method will return an sticker set which has two methods for adding new stickers to it and managing the pack AddNewSticker andAddNewStickerByFile. Example:

fl1, err := os.Open("Sticker1.png")
if err != nil {
    fmt.Println(err)
}

fl2, err := os.Open("Sticker2.png")
if err != nil {
    fmt.Println(err)
}

// Create the sticker set
st := bot.CreateStickerSet(123456789, "test_by_awesomebot", "test", "static", "regular", false)

// Add a new sticker to the set
ok, err := st.AddNewStickerByFile(fl1, 123456789, []string{"😀"}, []string{"happy"}, nil)
if !ok || err != nil {
	fmt.Println(err)
}
// Add a new sticker to the set
ok, err = st.AddNewStickerByFile(fl2, 123456789, []string{"😀"}, []string{"happy"}, nil)
if !ok || err != nil {
	fmt.Println(err)
}
//Create the new sticker set
ok, err = st.Create()
if !ok || err != nil {
	fmt.Println(err)
}

//Send a sticker
ms := bot.SendSticker(msg.Message.Chat.Id, msg.Message.MessageId, "")
_, err = ms.SendByFileIdOrUrl(st.GetStickers()[0].FileId, false, false)
if err != nil {
	fmt.Println(err)
}
Editing Stickers

As of Telego v2.0.0 a new sticker editor has been added to the bot. This tool offers some methods for editing an existing sticker. These methods can be used for editing emoji list, keywords, mask position or deleting the sticker. The sticker editor can be retrieved by GetStickerEditor method of the bot.

Blocking users

Telego gives you the ability to block a user. You can also implement a mechanism to block the user more customized or you can use builtin blocking option. To block a user you can simply call Block method of the bot and pass the User object to the method. When a user is blocked, received updates from the user will be ignored.

Middlewares

As of version 2.1.0 of Telego, middleware feature has been added. Middlewares allow you to add custom middlewares that can interact with the recceived update. Middlewares are chained, meaning that they will be executed in order. Notes about the middlewares :

  1. As said, middlewares are chained. They are executed in the same order that they have been added.
  2. Any change on the received update will stay with the update.
  3. Middlewares accept and argument called next. next is function that will invoke the next middleware in the chain. If next is not called, the execution of middleware will be stopped.

Middlewares can be added via AddMiddleware method of the AdvancedBot. Example code :

import (
	"fmt"

	bt "github.com/SakoDroid/telego/v2"
	cfg "github.com/SakoDroid/telego/v2/configs"
	"github.com/SakoDroid/telego/v2/objects"
)

func main() {
	bot, err := bt.NewBot(cfg.Default("Your API key"))
	if err != nil {
		panic(err)
	}

    //Adding a middleware that will check if the update contains chat shared object. If it contains the object
    //the next middleware is invoked.
	bot.AdvancedMode().AddMiddleware(func(update *objects.Update, next func()) {
		if update.Message != nil && update.Message.ChatShared != nil {
			fmt.Printf("Update %d is a chat shared update", update.Update_id)
			next()
		} else {
			fmt.Printf("Update %d is not a chat shared update", update.Update_id)
		}
	})

	bot.Run(true)
}

License

Telego is licensed under MIT lisence. Which means it can be used for commercial and private apps and can be modified.


Change logs

v2.1.0
  • Introduced middlewares. You can now add middlewares to the bot to be executed before the update hits the handlers and channels.
  • Added DeleteIn method to MessageEditor tool. This method can be used for deleting messages with a delay.
  • Fixing ISSUE #17 and #11. All tools are now exported so they can be returned in user defined methods.
  • Bug fixes.
v2.0.0

Improvements :

  • Added full support for Telegram bot API 6.2, 6.3, 6.4, 6.5, 6.6, 6.7, 6.8 .
  • Run method of the bot now has an auto pause option. If true is passed, the Run method will lock the go routine.
  • Many many classes have been upgraded to newest version and many fields have been added. (Naming all of them is not possible due to the huge amount of change)
  • Implemented a thread safe map in callback handlers to avoid race condition.
  • Golang version (in go.mod) has been upgraded to 1.18.
  • Bug fixes.

New features :

  • Added a new stickerEditor which has several methods for editing a sticker. Such as editing the emoji list, keywordas and etc. Accessible via GetStickerEditor method.
  • Added forumTopicManager and generalForumTopicManager for managing topics. They both provide a set of tools that can be leveraged for manaing topics.
  • Added spoiler support for media (photo,video,animation) messages.
  • Added two new keys to the keyboard. RequestUser and ReqestChat.
  • Added a set of new handlers used for handling messages triggered by RequestUser and ReqestChat buttons.
  • Added SetButton methods to inlineQueryResponder for setting a button that will be shown above inline query results.
  • Added AddSwitchInlineQueryChoseChatButton method to the inline keyboard to support the new SwitchInlineQueryChosenChat option in inline keyboards.
  • Introduced bot manager tool, a tool for managing bot's personal information such as name and description.
  • Removed row argument from AddPayButton of inline keybpard and prechecking invoice message keyboard. (Regarding ISSUE #15).
  • Methods ACreateInvoice and ACreateInvoiceUN now return error along side with the invoiceSender.

Deprecations :

  1. CreateNewStickerSet method of the bot. Use CreateStickerSet instead.
  2. AddSticker, AddPngSticker, AddPngStickerByFile, AddAnimatedSticker,AddVideoSticker methods of stickerSet. Use AddNewSticker and AddNewStickerByFile instead.
v1.8.0
  • Added full support for telegram bot API 6.0 and 6.1
  • Added support for web apps
  • Fixed some code errors
  • Fixed a bug in webhook
v1.7.0
  • Added config updating option while bot is running.
  • Added block option.
  • Added VerifyJoin method for checking if a user has joined a channel or supergroup or not.
  • Added file based configs.
  • Improved logging system.
  • Improved documentation
v1.6.7
  • Added support for telegram bot API 5.7
  • Improved sticker creation experience by adding new separate methods.
  • Correct syntax errors by @ityulkanov
  • Bug fixes
v1.5.7
  • Bug fixes
v1.5.5
  • Added webhook support
  • Improved handlers and regex bug fixed.
  • Some other bug fixes.
v1.4.5
  • Added TextFormatter tool for formatting texts.
  • Bug fixes
v1.3.5
  • Added support for telegram bot API 5.6 .
  • Improved documentation.
v1.3.4
  • Custom keyboard button handler
  • Major bug fixes
v1.3.3
  • Callback handlers
  • keyboard creation tool

telego logo inspired by Golang logo

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Polls = make(map[string]*Poll)

Polls contains the pointers to all of the created maps.

Functions

This section is empty.

Types

type AdvancedBot

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

AdvancedBot is an advanced type of bot which will give you alot more customization for the bot. Methods which are uniquely for advanced bot start with 'A' .

func (*AdvancedBot) AAnswerCallbackQuery

func (bot *AdvancedBot) AAnswerCallbackQuery(callbackQueryId, text string, showAlert bool, url string, cacheTime int) (*objs.Result[bool], error)

AAnswerCallbackQuery can be used to send answers to callback queries sent from inline keyboards. The answer will be displayed to the user as a notification at the top of the chat screen or as an alert. On success, True is returned.

Alternatively, the user can be redirected to the specified Game URL. For this option to work, you must first create a game for your bot via @Botfather and accept the terms. Otherwise, you may use links like t.me/your_bot?start=XXXX that open your bot with a parameter.

func (*AdvancedBot) AAnswerInlineQuery

func (bot *AdvancedBot) AAnswerInlineQuery(id string, cacheTime int, isPersonal bool, nextOffset, switchPmText, switchPmParameter string) *InlineQueryResponder

AAnswerInlineQuery returns an InlineQueryResponder which has several methods for answering an inline query.

--------------------------

Official telegram doc :

Use this method to send answers to an inline query. On success, True is returned. No more than 50 results per query are allowed.

func (*AdvancedBot) ACopyMessage

func (bot *AdvancedBot) ACopyMessage(messageId int, disableNotif bool, replyTo int, caption, parseMode string, captionEntites []objs.MessageEntity, allowSendingWithoutReply bool, keyboard MarkUps) *MessageCopier

ACopyMessage returns a MessageCopier which has several methods for copying a message

func (*AdvancedBot) ACreateAlbum

func (bot *AdvancedBot) ACreateAlbum(replyTo, messageThreadId int, allowSendingWihtoutReply bool, keyboard MarkUps) *MediaGroup

ACreateAlbum creates a MediaGroup for grouping media messages. To ignore replyTo argument, pass 0.

func (*AdvancedBot) ACreateInvoice

func (bot *AdvancedBot) ACreateInvoice(chatId int, title, description, payload, providerToken, currency string, prices []objs.LabeledPrice, maxTipAmount int, suggestedTipAmounts []int, startParameter, providerData, photoURL string, photoSize, photoWidth, photoHeight int, needName, needPhoneNumber, needEmail, needSippingAddress, sendPhoneNumberToProvider, sendEmailToProvider, isFlexible, bool, allowSendingWithoutReply bool, keyboard *InlineKeyboard) (*Invoice, error)

ACreateInvoice returns an InvoiceSender which has several methods for creating and sending an invoice.

This method is suitable for sending this invoice to a chat that has an id, to send the invoice to channels use "ACreateInvoiceUN" method.

func (*AdvancedBot) ACreateInvoiceUN

func (bot *AdvancedBot) ACreateInvoiceUN(chatId string, title, description, payload, providerToken, currency string, prices []objs.LabeledPrice, maxTipAmount int, suggestedTipAmounts []int, startParameter, providerData, photoURL string, photoSize, photoWidth, photoHeight int, needName, needPhoneNumber, needEmail, needSippingAddress, sendPhoneNumberToProvider, sendEmailToProvider, isFlexible, bool, allowSendingWithoutReply bool, keyboard *InlineKeyboard) (*Invoice, error)

ACreateInvoiceUN returns an InvoiceSender which has several methods for creating and sending an invoice.

func (*AdvancedBot) ACreateLiveLocation

func (bot *AdvancedBot) ACreateLiveLocation(latitude, longitude, accuracy float32, livePeriod, heading, proximtyAlertRadius, replyTo, messageThreadId int, allowSendingWihtoutReply bool, keyboard MarkUps) *LiveLocation

ACreateLiveLocation creates a live location which has several methods for managing it.

func (*AdvancedBot) ASendAnimation

func (bot *AdvancedBot) ASendAnimation(chatId int, replyTo, messageThreadId int, caption, parseMode string, captionEntities []objs.MessageEntity, width, height, duration int, allowSendingWihtoutReply, hasSpoiler bool, keyboard MarkUps) *MediaSender

ASendAnimation returns a MediaSender which has several methods for sending an animation. This method is only used for sending an animation to all types of chat except channels. To send a audio to a channel use "SendAnimationUN" method. To ignore int arguments pass 0 and to ignore string arguments pass empty string ("")

---------------------------------

Official telegram doc :

Use this method to send animation files (GIF or H.264/MPEG-4 AVC video without sound). On success, the sent Message is returned. Bots can currently send animation files of up to 50 MB in size, this limit may be changed in the future.

func (*AdvancedBot) ASendAnimationUN

func (bot *AdvancedBot) ASendAnimationUN(chatId string, replyTo, messageThreadId int, caption, parseMode string, captionEntities []objs.MessageEntity, width, height, duration int, allowSendingWihtoutReply, hasSpoiler bool, keyboard MarkUps) *MediaSender

ASendAnimationUN returns a MediaSender which has several methods for sending an animation. This method is only used for sending an animation to channels To ignore int arguments pass 0 and to ignore string arguments pass empty string ("")

---------------------------------

Official telegram doc :

Use this method to send animation files (GIF or H.264/MPEG-4 AVC video without sound). On success, the sent Message is returned. Bots can currently send animation files of up to 50 MB in size, this limit may be changed in the future.

func (*AdvancedBot) ASendAudio

func (bot *AdvancedBot) ASendAudio(chatId, replyTo, messageThreadId int, caption, parseMode string, captionEntities []objs.MessageEntity, duration int, performer, title string, allowSendingWithoutReply bool, keyboard MarkUps) *MediaSender

ASendAudio returns a MediaSender which has several methods for sending a audio. This method is only used for sending a audio to all types of chat except channels. To send a audio to a channel use "SendAudioUN" method. To ignore int arguments pass 0 and to ignore string arguments pass empty string ("")

---------------------------------

Official telegram doc :

Use this method to send audio files, if you want Telegram clients to display them in the music player. Your audio must be in the .MP3 or .M4A format. On success, the sent Message is returned. Bots can currently send audio files of up to 50 MB in size, this limit may be changed in the future.

For sending voice messages, use the sendVoice method instead.

func (*AdvancedBot) ASendAudioUN

func (bot *AdvancedBot) ASendAudioUN(chatId string, replyTo, messageThreadId int, caption, parseMode string, captionEntities []objs.MessageEntity, duration int, performer, title string, allowSendingWithoutReply bool, keyboard MarkUps) *MediaSender

ASendAudioUN returns a MediaSender which has several methods for sending a audio. This method is only used for sending a audio to a channels. To ignore int arguments pass 0 and to ignore string arguments pass empty string ("")

---------------------------------

Official telegram doc :

Use this method to send audio files, if you want Telegram clients to display them in the music player. Your audio must be in the .MP3 or .M4A format. On success, the sent Message is returned. Bots can currently send audio files of up to 50 MB in size, this limit may be changed in the future.

For sending voice messages, use the sendVoice method instead.

func (*AdvancedBot) ASendContact

func (bot *AdvancedBot) ASendContact(chatId, replyTo, messageThreadId int, phoneNumber, firstName, lastName, vCard string, silent, protectContent bool, allowSendingWihtoutReply bool, keyboard MarkUps) (*objs.Result[*objs.Message], error)

ASendContact sends a contact to all types of chat but channels. To send it to channels use "SendContactUN" method.

If "silent" argument is true, the message will be sent without notification.

If "protectContent" argument is true, the message can't be forwarded or saved.

---------------------------------

Official telegram doc :

Use this method to send phone contacts. On success, the sent Message is returned.

func (*AdvancedBot) ASendContactUN

func (bot *AdvancedBot) ASendContactUN(chatId string, replyTo, messageThreadId int, phoneNumber, firstName, lastName, vCard string, silent, protectContent bool, allowSendingWihtoutReply bool, keyboard MarkUps) (*objs.Result[*objs.Message], error)

ASendContactUN sends a contact to a channel.

If "silent" argument is true, the message will be sent without notification.

If "protectContent" argument is true, the message can't be forwarded or saved.

---------------------------------

Official telegram doc :

Use this method to send phone contacts. On success, the sent Message is returned.

func (*AdvancedBot) ASendDice

func (bot *AdvancedBot) ASendDice(chatId, replyTo, messageThreadId int, emoji string, silent, protectContent bool, allowSendingWihtoutReply bool, keyboard MarkUps) (*objs.Result[*objs.Message], error)

ASendDice sends a dice message to all types of chat but channels. To send it to channels use "SendDiceUN" method.

Available emojies : “🎲”, “🎯”, “🏀”, “⚽”, “🎳”, or “🎰”.

If "silent" argument is true, the message will be sent without notification.

If "protectContent" argument is true, the message can't be forwarded or saved.

---------------------------------

Official telegram doc :

Use this method to send an animated emoji that will display a random value. On success, the sent Message is returned

func (*AdvancedBot) ASendDiceUN

func (bot *AdvancedBot) ASendDiceUN(chatId string, replyTo, messageThreadId int, emoji string, silent, protectContent bool, allowSendingWihtoutReply bool, keyboard MarkUps) (*objs.Result[*objs.Message], error)

ASendDiceUN sends a dice message to a channel.

Available emojies : “🎲”, “🎯”, “🏀”, “⚽”, “🎳”, or “🎰”.

If "silent" argument is true, the message will be sent without notification.

If "protectContent" argument is true, the message can't be forwarded or saved.

---------------------------------

Official telegram doc :

Use this method to send an animated emoji that will display a random value. On success, the sent Message is returned

func (*AdvancedBot) ASendDocument

func (bot *AdvancedBot) ASendDocument(chatId, replyTo, messageThreadId int, caption, parseMode string, captionEntities []objs.MessageEntity, disableContentTypeDetection, allowSendingWithoutReply bool, keyboard MarkUps) *MediaSender

ASendDocument returns a MediaSender which has several methods for sending a document. This method is only used for sending a document to all types of chat except channels. To send a audio to a channel use "SendDocumentUN" method. To ignore int arguments pass 0 and to ignore string arguments pass empty string ("")

---------------------------------

Official telegram doc :

Use this method to send general files. On success, the sent Message is returned. Bots can currently send files of any type of up to 50 MB in size, this limit may be changed in the future.

func (*AdvancedBot) ASendDocumentUN

func (bot *AdvancedBot) ASendDocumentUN(chatId string, replyTo, messageThreadId int, caption, parseMode string, captionEntities []objs.MessageEntity, disableContentTypeDetection, allowSendingWithoutReply bool, keyboard MarkUps) *MediaSender

ASendDocumentUN returns a MediaSender which has several methods for sending a document. This method is only used for sending a document to a channels. To ignore int arguments pass 0 and to ignore string arguments pass empty string ("")

---------------------------------

Official telegram doc :

Use this method to send general files. On success, the sent Message is returned. Bots can currently send files of any type of up to 50 MB in size, this limit may be changed in the future.

func (*AdvancedBot) ASendGame

func (bot *AdvancedBot) ASendGame(chatId int, gameShortName string, silent bool, replyTo int, allowSendingWithoutReply bool, keyboard MarkUps) (*objs.Result[*objs.Message], error)

ASendGame sends a game to the chat.

-----------------------

Official telegram doc :

Use this method to send a game. On success, the sent Message is returned.

func (*AdvancedBot) ASendLocation

func (bot *AdvancedBot) ASendLocation(chatId int, silent, protectContent bool, latitude, longitude, accuracy float32, replyTo, messageThreadId int, allowSendingWihtoutReply bool, keyboard MarkUps) (*objs.Result[*objs.Message], error)

ASendLocation sends a location (not live) to all types of chats but channels. To send it to channel use "SendLocationUN" method.

You can not use this methods to send a live location. To send a live location use "ACreateLiveLocation" method.

If "silent" argument is true, the message will be sent without notification.

If "protectContent" argument is true, the message can't be forwarded or saved.

---------------------------------

Official telegram doc :

Use this method to send point on the map. On success, the sent Message is returned.

func (*AdvancedBot) ASendLocationUN

func (bot *AdvancedBot) ASendLocationUN(chatId string, silent, protectContent bool, latitude, longitude, accuracy float32, replyTo, messageThreadId int, allowSendingWihtoutReply bool, keyboard MarkUps) (*objs.Result[*objs.Message], error)

ASendLocationUN sends a location (not live) to a channel.

You can not use this methods to send a live location. To send a live location use "ACreateLiveLocation" method.

If "silent" argument is true, the message will be sent without notification.

If "protectContent" argument is true, the message can't be forwarded or saved.

---------------------------------

Official telegram doc :

Use this method to send point on the map. On success, the sent Message is returned.

func (*AdvancedBot) ASendMessage

func (bot *AdvancedBot) ASendMessage(chatId int, text, parseMode string, replyTo, messageThreadId int, silent, protectContent bool, entites []objs.MessageEntity, disabelWebPagePreview, allowSendingWithoutReply bool, keyboard MarkUps) (*objs.Result[*objs.Message], error)

ASendMessage sends a text message to a chat (not channel, use SendMessageUN method for sending messages to channles) and returns the sent message on success If you want to ignore "parseMode" pass empty string. To ignore replyTo pass 0.

If "silent" argument is true, the message will be sent without notification.

If "protectContent" argument is true, the message can't be forwarded or saved.

func (*AdvancedBot) ASendMesssageUN

func (bot *AdvancedBot) ASendMesssageUN(chatId, text, parseMode string, replyTo, messageThreadId int, silent, protectContent bool, entites []objs.MessageEntity, disabelWebPagePreview, allowSendingWithoutReply bool, keyboard MarkUps) (*objs.Result[*objs.Message], error)

ASendMesssageUN sends a text message to a channel and returns the sent message on success If you want to ignore "parseMode" pass empty string. To ignore replyTo pass 0.

If "silent" argument is true, the message will be sent without notification.

If "protectContent" argument is true, the message can't be forwarded or saved.

func (*AdvancedBot) ASendPhoto

func (bot *AdvancedBot) ASendPhoto(chatId, replyTo, messageThreadId int, caption, parseMode string, captionEntites []objs.MessageEntity, allowSendingWithoutReply, hasSpoiler bool, keyboard MarkUps) *MediaSender

ASendPhoto returns a MediaSender which has several methods for sending a photo. This method is only used for sending a photo to all types of chat except channels. To send a photo to a channel use "SendPhotoUN" method. To ignore int arguments pass 0 and to ignore string arguments pass empty string ("")

func (*AdvancedBot) ASendPhotoUN

func (bot *AdvancedBot) ASendPhotoUN(chatId string, replyTo, messageThreadId int, caption, parseMode string, captionEntites []objs.MessageEntity, allowSendingWithoutReply, hasSpoiler bool, keyboard MarkUps) *MediaSender

ASendPhotoUN returns a MediaSender which has several methods for sending a photo. This method is only used for sending a photo to a channels. To ignore int arguments pass 0 and to ignore string arguments pass empty string ("")

func (*AdvancedBot) ASendSticker

func (bot *AdvancedBot) ASendSticker(chatId, replyTo, messageThreadId int, emoji string, captionEntites []objs.MessageEntity, allowSendingWithoutReply, hasSpoiler bool, keyboard MarkUps) *MediaSender

ASendSticker returns a MediaSender which has several methods for sending a sticker. This method is only used for sending a sticker to all types of chat except channels. To send a sticker to a channel use "SendStickerUN" method. To ignore int arguments pass 0 and to ignore string arguments pass empty string ("")

func (*AdvancedBot) ASendStickerUN

func (bot *AdvancedBot) ASendStickerUN(chatId string, replyTo, messageThreadId int, emoji string, captionEntites []objs.MessageEntity, allowSendingWithoutReply, hasSpoiler bool, keyboard MarkUps) *MediaSender

ASendStickerUN returns a MediaSender which has several methods for sending a sticker. This method is only used for sending a sticker to a channels. To ignore int arguments pass 0 and to ignore string arguments pass empty string ("")

func (*AdvancedBot) ASendVenue

func (bot *AdvancedBot) ASendVenue(chatId, replyTo, messageThreadId int, latitude, longitude float32, title, address, foursquareId, foursquareType, googlePlaceId, googlePlaceType string, silent bool, allowSendingWihtoutReply, protectContent bool, keyboard MarkUps) (*objs.Result[*objs.Message], error)

ASendVenue sends a venue to all types of chat but channels. To send it to channels use "SendVenueUN" method.

If "silent" argument is true, the message will be sent without notification.

If "protectContent" argument is true, the message can't be forwarded or saved.

---------------------------------

Official telegram doc :

Use this method to send information about a venue. On success, the sent Message is returned.

func (*AdvancedBot) ASendVenueUN

func (bot *AdvancedBot) ASendVenueUN(chatId string, replyTo, messageThreadId int, latitude, longitude float32, title, address, foursquareId, foursquareType, googlePlaceId, googlePlaceType string, silent, protectContent bool, allowSendingWihtoutReply bool, keyboard MarkUps) (*objs.Result[*objs.Message], error)

ASendVenueUN sends a venue to a channel.

If "silent" argument is true, the message will be sent without notification.

If "protectContent" argument is true, the message can't be forwarded or saved.

---------------------------------

Official telegram doc :

Use this method to send information about a venue. On success, the sent Message is returned.

func (*AdvancedBot) ASendVideo

func (bot *AdvancedBot) ASendVideo(chatId int, replyTo, messageThreadId int, caption, parseMode string, captionEntites []objs.MessageEntity, duration int, supportsStreaming, allowSendingWithoutReply, hasSpoiler bool, keyboard MarkUps) *MediaSender

ASendVideo returns a MediaSender which has several methods for sending a video. This method is only used for sending a video to all types of chat except channels. To send a video to a channel use "SendVideoUN" method. To ignore int arguments pass 0 and to ignore string arguments pass empty string ("")

---------------------------------

Official telegram doc :

Use this method to send video files, Telegram clients support mp4 videos (other formats may be sent as Document). On success, the sent Message is returned. Bots can currently send video files of up to 50 MB in size, this limit may be changed in the future.

func (*AdvancedBot) ASendVideoNote

func (bot *AdvancedBot) ASendVideoNote(chatId int, replyTo, messageThreadId int, caption, parseMode string, captionEntities []objs.MessageEntity, length, duration int, allowSendingWihtoutReply bool, keyboard MarkUps) *MediaSender

ASendVideoNote returns a MediaSender which has several methods for sending a video note. This method is only used for sending a video note to all types of chat except channels. To send a video note to a channel use "SendVideoNoteUN" method. To ignore int arguments pass 0 and to ignore string arguments pass empty string ("")

---------------------------------

Official telegram doc :

As of v.4.0, Telegram clients support rounded square mp4 videos of up to 1 minute long. Use this method to send video messages. On success, the sent Message is returned.

func (*AdvancedBot) ASendVideoNoteUN

func (bot *AdvancedBot) ASendVideoNoteUN(chatId string, replyTo, messageThreadId int, caption, parseMode string, captionEntities []objs.MessageEntity, length, duration int, allowSendingWihtoutReply bool, keyboard MarkUps) *MediaSender

ASendVideoNoteUN returns an MediaSender which has several methods for sending a video note. This method is only used for sending a video note to channels. To ignore int arguments pass 0 and to ignore string arguments pass empty string ("")

---------------------------------

Official telegram doc :

As of v.4.0, Telegram clients support rounded square mp4 videos of up to 1 minute long. Use this method to send video messages. On success, the sent Message is returned.

func (*AdvancedBot) ASendVideoUN

func (bot *AdvancedBot) ASendVideoUN(chatId string, replyTo, messageThreadId int, caption, parseMode string, captionEntites []objs.MessageEntity, duration int, supportsStreaming, allowSendingWithoutReply, hasSpoiler bool, keyboard MarkUps) *MediaSender

ASendVideoUN returns a MediaSender which has several methods for sending a video. This method is only used for sending a video to a channels. To ignore int arguments pass 0 and to ignore string arguments pass empty string ("")

---------------------------------

Official telegram doc :

Use this method to send video files, Telegram clients support mp4 videos (other formats may be sent as Document). On success, the sent Message is returned. Bots can currently send video files of up to 50 MB in size, this limit may be changed in the future.

func (*AdvancedBot) ASendVoice

func (bot *AdvancedBot) ASendVoice(chatId int, replyTo, messageThreadId int, caption, parseMode string, captionEntities []objs.MessageEntity, duration int, allowSendingWihtoutReply bool, keyboard MarkUps) *MediaSender

ASendVoice returns a MediaSender which has several methods for sending a voice. This method is only used for sending a voice to all types of chat except channels. To send a voice to a channel use "SendVoiceUN" method. To ignore int arguments pass 0 and to ignore string arguments pass empty string ("")

---------------------------------

Official telegram doc :

Use this method to send audio files, if you want Telegram clients to display the file as a playable voice message. For this to work, your audio must be in an .OGG file encoded with OPUS (other formats may be sent as Audio or Document). On success, the sent Message is returned. Bots can currently send voice messages of up to 50 MB in size, this limit may be changed in the future.

func (*AdvancedBot) ASendVoiceUN

func (bot *AdvancedBot) ASendVoiceUN(chatId string, replyTo, messageThreadId int, caption, parseMode string, captionEntities []objs.MessageEntity, duration int, allowSendingWihtoutReply bool, keyboard MarkUps) *MediaSender

ASendVoiceUN returns a MediaSender which has several methods for sending a voice. This method is only used for sending a voice to channels. To ignore int arguments pass 0 and to ignore string arguments pass empty string ("")

---------------------------------

Official telegram doc :

Use this method to send audio files, if you want Telegram clients to display the file as a playable voice message. For this to work, your audio must be in an .OGG file encoded with OPUS (other formats may be sent as Audio or Document). On success, the sent Message is returned. Bots can currently send voice messages of up to 50 MB in size, this limit may be changed in the future.

func (*AdvancedBot) ASetGameScore

func (bot *AdvancedBot) ASetGameScore(userId, score, chatId, messageId int, force, disableEditMessage bool, inlineMessageId string) (*objs.Result[json.RawMessage], error)

ASetGameScore sets the score of the given user.

-----------------------

Official telegram doc :

Use this method to set the score of the specified user in a game message. On success, if the message is not an inline message, the Message is returned, otherwise True is returned. Returns an error, if the new score is not greater than the user's current score in the chat and force is False.

"score" is new score, must be non-negative.

"force" : Pass True, if the high score is allowed to decrease. This can be useful when fixing mistakes or banning cheaters.

"disableEditMessage" : Pass True, if the game message should not be automatically edited to include the current scoreboard.

"inlineMessageId" : Required if chat_id and message_id are not specified. Identifier of the inline message.

func (*AdvancedBot) AddMiddleware added in v2.1.0

func (bot *AdvancedBot) AddMiddleware(md func(update *objs.Update, next func()))

AddMiddleware adds a new middleware to middleware chain.

Arguemnts :

1. update : The received update

2. next : next is a function that invokes the next middleware in chain. If it is not called in you middleware function, then the middleare chain execution will stop.

func (*AdvancedBot) GetMyDefaultAdministratorRights

func (bot *AdvancedBot) GetMyDefaultAdministratorRights(forChannels bool) (*objs.Result[*objs.ChatAdministratorRights], error)

GetMyDefaultAdministratorRights as describe by telegram official doc : Use this method to get the current default administrator rights of the bot. Returns ChatAdministratorRights on success.

func (*AdvancedBot) RegisterChannel

func (bot *AdvancedBot) RegisterChannel(chatId, mediaType string) (*chan *objs.Update, error)

RegisterChannel can be used to register special channels. Sepcial channels can be used to get only certain types of updates through them. For example you can register a channel to only receive messages or register a channel to only receive edited messages in a certain chat.

"chatId" argument specifies a chat which this channel will be dedicated to. If an empty string is passed it means that no chat is specified and channel will work for all chats. chatIds that are integer should be converted to string.

"mediaType" argument specifies a media type that channel will be dedicated to. If an empty string is passed it means no media type is in mind and channel will work for all media types. mediaType can have the following values :

1. Empty string

2. message

3. edited_message

4. channel_post

5. edited_channel_post

6. inline_query

7. chosen_inline_query

8. callback_query

9. shipping_query

10. pre_checkout_query

11. poll_answer

12. my_chat_member

13. chat_member

14. chat_join_request

bot "chatId" and "mediaType" arguments can be used together to create a channel that will be updated only if a certain type of update is received for a ceratin chat.

Examples :

1. RegisterChannel("123456","message") : The returned channel will be updated when a message (text,photo,video ...) is received from a chat with "123456" as it's chat id.

2. RegiterChannel("","message") : The returned channel will be updated everytime a message is received from any chat.

3. RegisterChannel("123456","") : The returned channel will be updated everytime an update of anykind is received for the specified chat.

4. RegisterChannel("","") : The returned is the global update channel which will be updated everytime an update is received. You can get this channel by calling `getUpdateChannel()` method too.

func (*AdvancedBot) SetMyDefaultAdministratorRights

func (bot *AdvancedBot) SetMyDefaultAdministratorRights(forChannels, isAnonymous, canManageChat, canPostmessages, canEditMessages, canDeleteMessages, canManageVideoChats, canRestrictMembers, canPromoteMembers, canChangeInfo, canInviteUsers, canPinMessages bool) (*objs.Result[bool], error)

SetMyDefaultAdministratorRights as describe by telegram official doc : Use this method to change the default administrator rights requested by the bot when it's added as an administrator to groups or channels. These rights will be suggested to users, but they are are free to modify the list before adding the bot. Returns True on success.

func (*AdvancedBot) SetPassportDataErrors

func (bot *AdvancedBot) SetPassportDataErrors(userId int, errors []objs.PassportElementError) (*objs.Result[bool], error)

SetPassportDataErrors informs a user that some of the Telegram Passport elements they provided contains errors. The user will not be able to re-submit their Passport to you until the errors are fixed (the contents of the field for which you returned the error must change). Returns True on success.

Use this if the data submitted by the user doesn't satisfy the standards your service requires for any reason. For example, if a birthday date seems invalid, a submitted document is blurry, a scan shows evidence of tampering, etc. Supply some details in the error message to make sure the user knows how to correct the issues.

func (*AdvancedBot) UnRegisterChannel

func (bot *AdvancedBot) UnRegisterChannel(chatId, mediaType string)

UnRegisterChannel can be used to unregister a channel for the given arguments

type AnimationEditor

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

AnimationEditor is a tool for editing animations.

func (*AnimationEditor) EditByFile

func (ai *AnimationEditor) EditByFile(file *os.File) (*objs.Result[json.RawMessage], error)

EditByFile edits this animation by file in the device

func (*AnimationEditor) EditByFileIdOrURL

func (ai *AnimationEditor) EditByFileIdOrURL(fileIdOrUrl string) (*objs.Result[json.RawMessage], error)

EditByFileIdOrURL edits this animation file by file id or url

type AnimationInserter

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

AnimationInserter is a tool for inserting animations into the MediaGroup.

func (*AnimationInserter) AddByFile

func (ai *AnimationInserter) AddByFile(file *os.File) error

AddByFile adds an existing file in the device

func (*AnimationInserter) AddByFileIdOrURL

func (ai *AnimationInserter) AddByFileIdOrURL(fileIdOrUrl string)

AddByFileIdOrURL adds this file by file id or url

func (*AnimationInserter) EditThumbnail

func (ai *AnimationInserter) EditThumbnail(fileIdOrURL string)

EditThumbnail edits the tumbnail of the file. It takes a fileId or a url. If you want to send a file use "setThumbnailFile" instead.

func (*AnimationInserter) EditThumbnailFile

func (ai *AnimationInserter) EditThumbnailFile(file *os.File) error

EditThumbnailFile edits the thumbnail of the file. It takes a file existing on the device

func (*AnimationInserter) SetThumbnail

func (ai *AnimationInserter) SetThumbnail(fileIdOrURL string)

SetThumbnail sets the tumbnail of the file. It takes a fileId or a url. If you want to send a file use "setThumbnailFile" instead.

func (*AnimationInserter) SetThumbnailFile

func (ai *AnimationInserter) SetThumbnailFile(file *os.File) error

SetThumbnailFile sets the tumbnail of the file. It takes a file existing on the device

type AudioEditor

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

AudioEditor is a tool for editing audios.

func (*AudioEditor) EditByFile

func (ai *AudioEditor) EditByFile(file *os.File) (*objs.Result[json.RawMessage], error)

EditByFile edits this audio by file in the device

func (*AudioEditor) EditByFileIdOrURL

func (ai *AudioEditor) EditByFileIdOrURL(fileIdOrUrl string) (*objs.Result[json.RawMessage], error)

EditByFileIdOrURL edits this file by file id or url

func (*AudioEditor) EditThumbnail

func (ai *AudioEditor) EditThumbnail(fileIdOrURL string)

EditThumbnail edits the tumbnail of the file. It takes a fileId or a url. If you want to send a file use "setThumbnailFile" instead.

func (*AudioEditor) EditThumbnailFile

func (ai *AudioEditor) EditThumbnailFile(file *os.File) error

EditThumbnailFile edits the thumbnail of the file. It takes a file existing on the device

type AudioInserter

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

AudioInserter is a tool for inserting audios into the MediaGroup.

func (*AudioInserter) AddByFile

func (ai *AudioInserter) AddByFile(file *os.File) error

AddByFile adds an existing file in the device

func (*AudioInserter) AddByFileIdOrURL

func (ai *AudioInserter) AddByFileIdOrURL(fileIdOrUrl string)

AddByFileIdOrURL adds this file by file id or url

func (*AudioInserter) SetThumbnail

func (ai *AudioInserter) SetThumbnail(fileIdOrURL string)

SetThumbnail sets the tumbnail of the file. It takes a fileId or a url. If you want to send a file use "setThumbnailFile" instead.

func (*AudioInserter) SetThumbnailFile

func (ai *AudioInserter) SetThumbnailFile(file *os.File) error

SetThumbnailFile sets the tumbnail of the file. It takes a file existing on the device

type Bot

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

func NewBot

func NewBot(cfg *cfg.BotConfigs) (*Bot, error)

NewBot returns a new bot instance with the specified configs

func (*Bot) AddHandler

func (bot *Bot) AddHandler(pattern string, handler func(*objs.Update), chatTypes ...string) error

AddHandler adds a handler for a text message that matches the given regex pattern and chatType.

"pattern" is a regex pattern.

"chatType" must be "private","group","supergroup","channel" or "all". Any other value will cause the function to return an error.

func (*Bot) AdvancedMode

func (bot *Bot) AdvancedMode() *AdvancedBot

AdvancedMode returns and advanced version of the bot which gives more customized functions to iteract with the bot

func (*Bot) AnswerCallbackQuery

func (bot *Bot) AnswerCallbackQuery(callbackQueryId, text string, showAlert bool) (*objs.Result[bool], error)

AnswerCallbackQuery can be used to send answers to callback queries sent from inline keyboards. The answer will be displayed to the user as a notification at the top of the chat screen or as an alert. On success, True is returned.

Alternatively, the user can be redirected to the specified Game URL. For this option to work, you must first create a game for your bot via @Botfather and accept the terms. Otherwise, you may use links like t.me/your_bot?start=XXXX that open your bot with a parameter.

func (*Bot) AnswerInlineQuery

func (bot *Bot) AnswerInlineQuery(id string, cacheTime int) *InlineQueryResponder

AnswerInlineQuery returns an InlineQueryResponder which has several methods for answering an inline query or web app query. To access more options use "AAsnwerInlineQuery" method in advanced bot.

--------------------------

Official telegram doc :

Use this method to send answers to an inline query. On success, True is returned. No more than 50 results per query are allowed.

func (*Bot) AnswerPreCheckoutQuery

func (bot *Bot) AnswerPreCheckoutQuery(shippingQueryId string, ok bool, errorMessage string) (*objs.Result[bool], error)

AnswerPreCheckoutQuery answers a pre checkout query.

-----------------------

Official telegram doc :

Once the user has confirmed their payment and shipping details, the Bot API sends the final confirmation in the form of an Update with the field pre_checkout_query. Use this method to respond to such pre-checkout queries. On success, True is returned. Note: The Bot API must receive an answer within 10 seconds after the pre-checkout query was sent.

"ok" : Specify True if everything is alright (goods are available, etc.) and the bot is ready to proceed with the order. Use False if there are any problems.

"errorMessage" : Required if ok is False. Error message in human readable form that explains the reason for failure to proceed with the checkout (e.g. "Sorry, somebody just bought the last of our amazing black T-shirts while you were busy filling out your payment details. Please choose a different color or garment!"). Telegram will display this message to the user.

func (*Bot) AnswerShippingQuery

func (bot *Bot) AnswerShippingQuery(shippingQueryId string, ok bool, shippingOptions []objs.ShippingOption, errorMessage string) (*objs.Result[bool], error)

AnswerShippingQuery answers an incoming shipping query.

-----------------------

Official telegram doc :

If you sent an invoice requesting a shipping address and the parameter is_flexible was specified, the Bot API will send an Update with a shipping_query field to the bot. Use this method to reply to shipping queries. On success, True is returned.

"ok" : Specify True if delivery to the specified address is possible and False if there are any problems (for example, if delivery to the specified address is not possible).

"shippingOptions" : Required if ok is True. A JSON-serialized array of available shipping options.

"errorMessage" : Required if ok is False. Error message in human readable form that explains why it is impossible to complete the order (e.g. "Sorry, delivery to your desired address is unavailable'). Telegram will display this message to the user.

func (*Bot) AnswerWebAppQuery

func (bot *Bot) AnswerWebAppQuery(webAppQueryId string) *InlineQueryResponder

AnswerWebAppQuery returns an InlineQueryResponder which has several methods for answering an inline query or web app query.

--------------------------

Official telegram doc :

Use this method to set the result of an interaction with a Web App and send a corresponding message on behalf of the user to the chat from which the query originated. On success, a SentWebAppMessage object is returned.

func (*Bot) BanChatMember

func (bot *Bot) BanChatMember(chatIdInt int, chatIdString string, userId, untilDate int, revokeMessages bool) (*objs.Result[bool], error)

func (*Bot) BlockUser

func (bot *Bot) BlockUser(user *objs.User)

BlockUser blocks a user based on their ID and username.

func (*Bot) CopyMessage

func (bot *Bot) CopyMessage(messageId int, disableNotif, protectContent bool) *MessageCopier

CopyMessage returns a MessageCopier which has several methods for copying a message

If "protectContent" argument is true, the message can't be forwarded or saved.

func (*Bot) CreateAlbum

func (bot *Bot) CreateAlbum(replyTo int) *MediaGroup

CreateAlbum returns a MediaGroup for grouping media messages. To ignore replyTo argument, pass 0.

func (bot *Bot) CreateChatInviteLink(chatIdInt int, chatIdString, name string, expireDate, memberLimit int, createsJoinRequest bool) (*objs.Result[*objs.ChatInviteLink], error)

func (*Bot) CreateForumTopic

func (bot *Bot) CreateForumTopic(chatId int, name string, iconColor int, iconCustomEmojiId string) (*objs.Result[*objs.ForumTopic], error)

CreateForumTopic creates a forum topic. To create forum topic by username, use CreateForumTopicUN.

-------------------------

Official telegram doc :

Use this method to create a topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. Returns information about the created topic as a ForumTopic object.

Arguments (as described in telegram bot api):

1. chatId : Unique identifier for the target chat

2. name : Topic name, 1-128 characters

3. iconColor : Color of the topic icon in RGB format. Currently, must be one of 7322096 (0x6FB9F0), 16766590 (0xFFD67E), 13338331 (0xCB86DB), 9367192 (0x8EEE98), 16749490 (0xFF93B2), or 16478047 (0xFB6F5F)

4. iconCustomEmojiId : Unique identifier of the custom emoji shown as the topic icon. Use getForumTopicIconStickers to get all allowed custom emoji identifiers.

func (*Bot) CreateForumTopicUN

func (bot *Bot) CreateForumTopicUN(username, name string, iconColor int, iconCustomEmojiId string) (*objs.Result[*objs.ForumTopic], error)

CreateForumTopicUN creates a forum topic by username. username should start with @.

-------------------------

Official telegram doc :

Use this method to create a topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. Returns information about the created topic as a ForumTopic object.

Arguments (as described in telegram bot api):

1. username : username of the target supergroup (in the format @supergroupusername)

2. name : Topic name, 1-128 characters

3. iconColor : Color of the topic icon in RGB format. Currently, must be one of 7322096 (0x6FB9F0), 16766590 (0xFFD67E), 13338331 (0xCB86DB), 9367192 (0x8EEE98), 16749490 (0xFF93B2), or 16478047 (0xFB6F5F)

4. iconCustomEmojiId : Unique identifier of the custom emoji shown as the topic icon. Use getForumTopicIconStickers to get all allowed custom emoji identifiers.

func (*Bot) CreateInlineKeyboard

func (bot *Bot) CreateInlineKeyboard() *InlineKeyboard

CreateInlineKeyboard creates a keyboard an returns it. The created keyboard has some methods for adding buttons to it.

You can send the keyboard along with messages by passing the keyboard as the "keyboard" argument of a method. The methods that supoort keyboard are mostly located in the advanced mode.

func (*Bot) CreateInvoice

func (bot *Bot) CreateInvoice(chatId int, title, description, payload, providerToken, currency string) *Invoice

CreateInvoice returns an InvoiceSender which has several methods for creating and sending an invoice.

This method is suitable for sending this invoice to a chat that has an id, to send the invoice to channels use "CreateInvoiceUN" method.

To access more options, use "ACreateInvoice" method in advanced mode.

func (*Bot) CreateInvoiceUN

func (bot *Bot) CreateInvoiceUN(chatId, title, description, payload, providerToken, currency string) *Invoice

CreateInvoiceUN returns an InvoiceSender which has several methods for creating and sending an invoice.

To access more options, use "ACreateInvoiceUN" method in advanced mode.

func (*Bot) CreateKeyboard

func (bot *Bot) CreateKeyboard(resizeKeyboard, isPersistent, oneTimeKeyboard, selective bool, inputFieldPlaceholder string) *Keyboard

CreateKeyboard creates a keyboard an returns it. The created keyboard has some methods for adding buttons to it.

You can send the keyboard along with messages by passing the keyboard as the "keyboard" argument of the method. The methods that supoort keyboard are mostly located in the advanced mode.

Arguments (as described in telegram bot api):

1. resizeKeyboard : Requests clients to resize the keyboard vertically for optimal fit (e.g., make the keyboard smaller if there are just two rows of buttons). Defaults to false, in which case the custom keyboard is always of the same height as the app's standard keyboard.

2. oneTimeKeyboard : Requests clients to hide the keyboard as soon as it's been used. The keyboard will still be available, but clients will automatically display the usual letter-keyboard in the chat – the user can press a special button in the input field to see the custom keyboard again. Defaults to false

3. inputFieldPlaceholder : The placeholder to be shown in the input field when the keyboard is active; 1-64 characters.

4. selective : Use this parameter if you want to show the keyboard to specific users only. Targets: 1) users that are @mentioned in the text of the Message object; 2) if the bot's message is a reply (has reply_to_message_id), sender of the original message.

5. isPersistent : Requests clients to always show the keyboard when the regular keyboard is hidden. Defaults to false, in which case the custom keyboard can be hidden and opened with a keyboard icon.

Example: A user requests to change the bot's language, bot replies to the request with a keyboard to select the new language. Other users in the group don't see the keyboard.

func (*Bot) CreateNewStickerSet

func (bot *Bot) CreateNewStickerSet(userId int, name, title, pngStickerFileIdOrUrl string, pngStickerFile *os.File, tgsSticker *os.File, webmSticker *os.File, emojies string, containsMask bool, maskPosition *objs.MaskPosition) (*StickerSet, error)

Deprecated : This method has been completely deprecated. Use CreateStickerSet instead.

func (*Bot) CreatePoll

func (bot *Bot) CreatePoll(chatId int, question, pollType string) (*Poll, error)

CreatePoll creates a poll for all types of chat but channels. To create a poll for channels use "CreatePollForChannel" method.

The poll type can be "regular" or "quiz"

func (*Bot) CreatePollForChannel

func (bot *Bot) CreatePollForChannel(chatId, question, pollType string) (*Poll, error)

CreatePollForChannel creates a poll for a channel.

The poll type can be "regular" or "quiz"

func (*Bot) CreateStickerSet

func (bot *Bot) CreateStickerSet(userId int, name, title, stickerFormat, stickerType string, needsRepainting bool) *StickerSet

CreateStickerSet returns an sticker set which can be used for creation and managing sticker sets. In this case, sticker set is locked and can be only used for creating the sticker set.

Arguments :

1. userId : User identifier of created sticker set owner

2. name : Short name of sticker set, to be used in t.me/addstickers/ URLs (e.g., animals). Can contain only English letters, digits and underscores. Must begin with a letter, can't contain consecutive underscores and must end in "_by_<bot_username>". <bot_username> is case insensitive. 1-64 characters.

3. title : Sticker set title, 1-64 characters.

4. stickerFormat : Format of stickers in the set, must be one of “static”, “animated”, “video”

5. stickerType : Type of stickers in the set, pass “regular”, “mask”, or “custom_emoji”. By default, a regular sticker set is created.

6. needsRepainting : Pass True if stickers in the sticker set must be repainted to the color of text when used in messages, the accent color if used as emoji status, white on chat photos, or another appropriate color based on context; for custom emoji sticker sets only

func (*Bot) ForwardMessage

func (bot *Bot) ForwardMessage(messageId int, disableNotif, protectContent bool) *MessageForwarder

ForwardMessage returns a MessageForwarder which has several methods for forwarding a message

If "protectContent" argument is true, the message can't be forwarded or saved.

func (*Bot) GetBotManager

func (bot *Bot) GetBotManager() *BotManager

GetBotManager returns a bot manager, a tool for manging personal information of the bot such as name and description.

func (*Bot) GetChatManagerById

func (bot *Bot) GetChatManagerById(chatId int) *ChatManager

GetChatManagerById creates and returns a ChatManager for groups and other chats witch an integer id.

To manage supergroups and channels which have usernames use "GetChatManagerByUsername".

func (*Bot) GetChatManagerByUsrename

func (bot *Bot) GetChatManagerByUsrename(userName string) *ChatManager

GetChatManagerByUsrename creates and returns a ChatManager for supergroups and channels which have usernames

To manage groups and other chats witch an integer id use "GetChatManagerById".

func (*Bot) GetChatMember

func (bot *Bot) GetChatMember(chatIdInt int, chatIdString string, userId int) (*objs.Result[json.RawMessage], error)

func (*Bot) GetChatMenuButton

func (bot *Bot) GetChatMenuButton(chatId int64) (*objs.Result[*objs.MenuButton], error)

GetChatMenuButton gets the current menu button of given chat.

-------------------------

Official telegram doc :

Use this method to get the current value of the bot's menu button in a private chat, or the default menu button. Returns MenuButton on success.

func (*Bot) GetCommandManager

func (bot *Bot) GetCommandManager() *CommandsManager

GetCommandManager returns a command manager which has several method for manaing bot commands.

func (*Bot) GetCustomEmojiStickers

func (bot *Bot) GetCustomEmojiStickers(IDs []string) (*objs.Result[[]*objs.Sticker], error)

GetCustomEmojiStickers returns info about custom stickers.

-------------------------

Official telegram doc :

Use this method to get information about custom emoji stickers by their identifiers. Returns an Array of Sticker objects.

func (*Bot) GetFile

func (bot *Bot) GetFile(fileId string, download bool, file *os.File) (*objs.File, error)

GetFile gets a file from telegram server. If it is successful the File object is returned.

If "download option is true, the file will be saved into the given file and if the given file is nil file will be saved in the same name as it has been saved in telegram servers.

func (*Bot) GetForumTopicIconStickers

func (bot *Bot) GetForumTopicIconStickers() (*objs.Result[[]*objs.Sticker], error)

GetForumTopicIconStickers returns a list of stickers to be used in forum topics.

-------------------------

Official telegram doc :

Use this method to get custom emoji stickers, which can be used as a forum topic icon by any user. Requires no parameters. Returns an Array of Sticker objects.

func (*Bot) GetForumTopicManager

func (bot *Bot) GetForumTopicManager(chatId, messageThreadId int) *ForumTopicManager

GetForumTopicManager returns a forum topic manager which can be used for managing forum topics.

func (*Bot) GetForumTopicManagerUN

func (bot *Bot) GetForumTopicManagerUN(username string, messageThreadId int) *ForumTopicManager

GetForumTopicManager returns a forum topic manager which can be used for managing forum topics.

func (*Bot) GetGameHighScores

func (bot *Bot) GetGameHighScores(userId, chatId, messageId int, inlineMessageId string) (*objs.Result[[]*objs.GameHighScore], error)

GetGameHighScores returns the high scores of the user.

-------------------------

Official telegram doc :

Use this method to get data for high score tables. Will return the score of the specified user and several of their neighbors in a game. On success, returns an Array of GameHighScore objects.

This method will currently return scores for the target user, plus two of their closest neighbors on each side. Will also return the top three users if the user and his neighbors are not among them. Please note that this behavior is subject to change.

"chatId" : Required if inline_message_id is not specified. Unique identifier for the target chat.

"messageId" : Required if inline_message_id is not specified. Identifier of the sent message.

"inlineMessageId" : Required if chat_id and message_id are not specified. Identifier of the inline message.

func (*Bot) GetGeneralForumTopicManager

func (bot *Bot) GetGeneralForumTopicManager(chatId, messageThreadId int) *GeneralForumTopicManager

GetGeneralForumTopicManager returns a general forum topic manager which can be used for managing general forum topics.

func (*Bot) GetGeneralForumTopicManagerUN

func (bot *Bot) GetGeneralForumTopicManagerUN(username string, messageThreadId int) *GeneralForumTopicManager

GetGeneralForumTopicManagerUN returns a general forum topic manager which can be used for managing general forum topics.

func (*Bot) GetMe

func (bot *Bot) GetMe() (*objs.Result[*objs.User], error)

GetMe returns the received informations about the bot from api server.

---------------------

Official telegarm doc :

A simple method for testing your bot's authentication token. Requires no parameters. Returns basic information about the bot in form of a User object.

func (*Bot) GetMsgEditor

func (bot *Bot) GetMsgEditor(chatId int) *MessageEditor

GetMsgEditor returns a MessageEditor for a chat with id which has several methods for editing messages.

To edit messages in a channel or a chat with username, use "GetMsgEditorWithUN"

func (*Bot) GetMsgEditorWithUN

func (bot *Bot) GetMsgEditorWithUN(chatId string) *MessageEditor

GetMsgEditorWithUN returns a MessageEditor for a chat with username which has several methods for editing messages.

func (*Bot) GetStickerEditor

func (bot *Bot) GetStickerEditor(stickerFileId string) *StickerEditor

GetStickerEditor returns a special object for editing stickers. Setting emoji list, keywords,mask postion and deleting the sticker.

stickerFileId : File identifier of the sticker

func (*Bot) GetStickerSet

func (bot *Bot) GetStickerSet(name string) (*StickerSet, error)

GetStickerSet returns an sticker set with the given name

func (*Bot) GetTextFormatter

func (bot *Bot) GetTextFormatter() *TextFormatter

GetTextFormatter returns a MessageFormatter that can be used for formatting a text message. You can add bold,italic,underline,spoiler,mention,url,link and some other texts with this tool.

func (*Bot) GetUpdateChannel

func (bot *Bot) GetUpdateChannel() *chan *objs.Update

GetUpdateChannel returns the channel which new updates received from api server are pushed into.

func (*Bot) GetUserProfilePhotos

func (bot *Bot) GetUserProfilePhotos(userId, offset, limit int) (*objs.Result[*objs.UserProfilePhotos], error)

GetUserProfilePhotos gets the given user profile photos.

"userId" argument is required. Other arguments are optinoal and to ignore them pass 0.

---------------------------------

Official telegram doc :

Use this method to get a list of profile pictures for a user. Returns a UserProfilePhotos object.

func (*Bot) PinChatMessage

func (bot *Bot) PinChatMessage(chatIdInt int, chatIdString string, messageId int, disableNotification bool) (*objs.Result[bool], error)

func (*Bot) Run

func (bot *Bot) Run(autoPause bool) error

Run starts the bot. If the bot has already been started it returns an error.

func (*Bot) SendAnimation

func (bot *Bot) SendAnimation(chatId int, replyTo int, caption, parseMode string, hasSpoiler bool) *MediaSender

SendAnimation returns a MediaSender which has several methods for sending an animation. This method is only used for sending an animation to all types of chat except channels. To send a audio to a channel use "SendAnimationUN" method. To ignore int arguments pass 0 and to ignore string arguments pass empty string ("")

---------------------------------

Official telegram doc :

Use this method to send animation files (GIF or H.264/MPEG-4 AVC video without sound). On success, the sent Message is returned. Bots can currently send animation files of up to 50 MB in size, this limit may be changed in the future.

func (*Bot) SendAnimationUN

func (bot *Bot) SendAnimationUN(chatId string, replyTo int, caption, parseMode string, hasSpoiler bool) *MediaSender

SendAnimationUN returns a MediaSender which has several methods for sending an animation. This method is only used for sending an animation to channels To ignore int arguments pass 0 and to ignore string arguments pass empty string ("")

---------------------------------

Official telegram doc :

Use this method to send animation files (GIF or H.264/MPEG-4 AVC video without sound). On success, the sent Message is returned. Bots can currently send animation files of up to 50 MB in size, this limit may be changed in the future.

func (*Bot) SendAudio

func (bot *Bot) SendAudio(chatId, replyTo int, caption, parseMode string) *MediaSender

SendAudio returns a MediaSender which has several methods for sending a audio. This method is only used for sending a audio to all types of chat except channels. To send a audio to a channel use "SendAudioUN" method. To ignore int arguments pass 0 and to ignore string arguments pass empty string ("")

---------------------------------

Official telegram doc :

Use this method to send audio files, if you want Telegram clients to display them in the music player. Your audio must be in the .MP3 or .M4A format. On success, the sent Message is returned. Bots can currently send audio files of up to 50 MB in size, this limit may be changed in the future.

For sending voice messages, use the sendVoice method instead.

func (*Bot) SendAudioUN

func (bot *Bot) SendAudioUN(chatId string, replyTo int, caption, parseMode string) *MediaSender

SendAudioUN returns a MediaSender which has several methods for sending a audio. This method is only used for sending a audio to a channels. To ignore int arguments pass 0 and to ignore string arguments pass empty string ("")

---------------------------------

Official telegram doc :

Use this method to send audio files, if you want Telegram clients to display them in the music player. Your audio must be in the .MP3 or .M4A format. On success, the sent Message is returned. Bots can currently send audio files of up to 50 MB in size, this limit may be changed in the future.

For sending voice messages, use the sendVoice method instead.

func (*Bot) SendChatAction

func (bot *Bot) SendChatAction(chatId, messageThreadId int, action string) (*objs.Result[*objs.Message], error)

SendChatAction sends a chat action message to all types of chat but channels. To send it to channels use "SendChatActionUN" method. Note : messageThreadId is unique identifier for the target message thread (supergroups only) which can be used for sending chat actions to a specific message thread or a forum topic.

---------------------------------

Official telegram doc :

Use this method when you need to tell the user that something is happening on the bot's side. The status is set for 5 seconds or less (when a message arrives from your bot, Telegram clients clear its typing status). Returns True on success.

Example: The ImageBot needs some time to process a request and upload the image. Instead of sending a text message along the lines of “Retrieving image, please wait…”, the bot may use sendChatAction with action = upload_photo. The user will see a “sending photo” status for the bot.

We only recommend using this method when a response from the bot will take a noticeable amount of time to arrive.

action is the type of action to broadcast. Choose one, depending on what the user is about to receive: typing for text messages, upload_photo for photos, record_video or upload_video for videos, record_voice or upload_voice for voice notes, upload_document for general files, choose_sticker for stickers, find_location for location data, record_video_note or upload_video_note for video notes.

func (*Bot) SendChatActionUN

func (bot *Bot) SendChatActionUN(chatId, action string, messageThreadId int) (*objs.Result[*objs.Message], error)

SendChatActionUN sends a chat action message to a channel. Note : messageThreadId is unique identifier for the target message thread (supergroups only) which can be used for sending chat actions to a specific message thread or a forum topic.

---------------------------------

Official telegram doc :

Use this method when you need to tell the user that something is happening on the bot's side. The status is set for 5 seconds or less (when a message arrives from your bot, Telegram clients clear its typing status). Returns True on success.

Example: The ImageBot needs some time to process a request and upload the image. Instead of sending a text message along the lines of “Retrieving image, please wait…”, the bot may use sendChatAction with action = upload_photo. The user will see a “sending photo” status for the bot.

We only recommend using this method when a response from the bot will take a noticeable amount of time to arrive.

action is the type of action to broadcast. Choose one, depending on what the user is about to receive: typing for text messages, upload_photo for photos, record_video or upload_video for videos, record_voice or upload_voice for voice notes, upload_document for general files, choose_sticker for stickers, find_location for location data, record_video_note or upload_video_note for video notes.

func (*Bot) SendContact

func (bot *Bot) SendContact(chatId, replyTo int, phoneNumber, firstName, lastName string, silent, protectContent bool) (*objs.Result[*objs.Message], error)

SendContact sends a contact to all types of chat but channels. To send it to channels use "SendContactUN" method.

---------------------------------

Official telegram doc :

Use this method to send phone contacts. On success, the sent Message is returned.

If "silent" argument is true, the message will be sent without notification.

If "protectContent" argument is true, the message can't be forwarded or saved.

func (*Bot) SendContactUN

func (bot *Bot) SendContactUN(chatId string, replyTo int, phoneNumber, firstName, lastName string, silent, protectContent bool) (*objs.Result[*objs.Message], error)

SendContactUN sends a contact to a channel.

---------------------------------

Official telegram doc :

Use this method to send phone contacts. On success, the sent Message is returned.

If "silent" argument is true, the message will be sent without notification.

If "protectContent" argument is true, the message can't be forwarded or saved.

func (*Bot) SendDice

func (bot *Bot) SendDice(chatId, replyTo int, emoji string, silent, protectContent bool) (*objs.Result[*objs.Message], error)

SendDice sends a dice message to all types of chat but channels. To send it to channels use "SendDiceUN" method.

Available emojies : “🎲”, “🎯”, “🏀”, “⚽”, “🎳”, or “🎰”.

---------------------------------

Official telegram doc :

Use this method to send an animated emoji that will display a random value. On success, the sent Message is returned.

If "silent" argument is true, the message will be sent without notification.

If "protectContent" argument is true, the message can't be forwarded or saved.

func (*Bot) SendDiceUN

func (bot *Bot) SendDiceUN(chatId string, replyTo int, emoji string, silent, protectContent bool) (*objs.Result[*objs.Message], error)

SendDiceUN sends a dice message to a channel.

Available emojies : “🎲”, “🎯”, “🏀”, “⚽”, “🎳”, or “🎰”.

---------------------------------

Official telegram doc :

Use this method to send an animated emoji that will display a random value. On success, the sent Message is returned.

If "silent" argument is true, the message will be sent without notification.

If "protectContent" argument is true, the message can't be forwarded or saved.

func (*Bot) SendDocument

func (bot *Bot) SendDocument(chatId, replyTo int, caption, parseMode string) *MediaSender

SendDocument returns a MediaSender which has several methods for sending a document. This method is only used for sending a document to all types of chat except channels. To send a audio to a channel use "SendDocumentUN" method. To ignore int arguments pass 0 and to ignore string arguments pass empty string ("")

---------------------------------

Official telegram doc :

Use this method to send general files. On success, the sent Message is returned. Bots can currently send files of any type of up to 50 MB in size, this limit may be changed in the future.

func (*Bot) SendDocumentUN

func (bot *Bot) SendDocumentUN(chatId string, replyTo int, caption, parseMode string) *MediaSender

SendDocumentUN returns a MediaSender which has several methods for sending a document. This method is only used for sending a document to a channels. To ignore int arguments pass 0 and to ignore string arguments pass empty string ("")

---------------------------------

Official telegram doc :

Use this method to send general files. On success, the sent Message is returned. Bots can currently send files of any type of up to 50 MB in size, this limit may be changed in the future.

func (*Bot) SendGame

func (bot *Bot) SendGame(chatId int, gameShortName string, silent bool, replyTo int) (*objs.Result[*objs.Message], error)

SendGame sends a game to the chat.

**To access more options use "ASendGame" method in advanced mode.

-----------------------

Official telegram doc :

Use this method to send a game. On success, the sent Message is returned.

func (*Bot) SendLocation

func (bot *Bot) SendLocation(chatId int, silent, protectContent bool, latitude, longitude, accuracy float32, replyTo int) (*objs.Result[*objs.Message], error)

SendLocation sends a location (not live) to all types of chats but channels. To send it to channel use "SendLocationUN" method.

You can not use this methods to send a live location. To send a live location use AdvancedBot.

---------------------------------

Official telegram doc :

Use this method to send point on the map. On success, the sent Message is returned.

If "silent" argument is true, the message will be sent without notification.

If "protectContent" argument is true, the message can't be forwarded or saved.

func (*Bot) SendLocationUN

func (bot *Bot) SendLocationUN(chatId string, silent, protectContent bool, latitude, longitude, accuracy float32, replyTo int) (*objs.Result[*objs.Message], error)

SendLocationUN sends a location (not live) to a channel.

You can not use this methods to send a live location. To send a live location use AdvancedBot.

---------------------------------

Official telegram doc :

Use this method to send point on the map. On success, the sent Message is returned.

If "silent" argument is true, the message will be sent without notification.

If "protectContent" argument is true, the message can't be forwarded or saved.

func (*Bot) SendMessage

func (bot *Bot) SendMessage(chatId int, text, parseMode string, replyTo int, silent, protectContent bool) (*objs.Result[*objs.Message], error)

SendMessage sens a text message to a chat (not channel, use SendMessageUN method for sending messages to channles) and returns the sent message on success If you want to ignore "parseMode" pass empty string. To ignore replyTo pass 0.

If "silent" argument is true, the message will be sent without notification.

If "protectContent" argument is true, the message can't be forwarded or saved.

func (*Bot) SendMessageUN

func (bot *Bot) SendMessageUN(chatId, text, parseMode string, replyTo int, silent, protectContent bool) (*objs.Result[*objs.Message], error)

SendMesssageUN sens a text message to a channel and returns the sent message on success If you want to ignore "parseMode" pass empty string. To ignore replyTo pass 0.

If "silent" argument is true, the message will be sent without notification.

If "protectContent" argument is true, the message can't be forwarded or saved.

func (*Bot) SendPhoto

func (bot *Bot) SendPhoto(chatId, replyTo int, caption, parseMode string, hasSpoiler bool) *MediaSender

SendPhoto returns a MediaSender which has several methods for sending a photo. This method is only used for sending a photo to all types of chat except channels. To send a photo to a channel use "SendPhotoUN" method. To ignore int arguments pass 0 and to ignore string arguments pass empty string ("")

func (*Bot) SendPhotoUN

func (bot *Bot) SendPhotoUN(chatId string, replyTo int, caption, parseMode string, hasSpoiler bool) *MediaSender

SendPhotoUN returns a MediaSender which has several methods for sending a photo. This method is only used for sending a photo to a channels. To ignore int arguments pass 0 and to ignore string arguments pass empty string ("")

func (*Bot) SendSticker

func (bot *Bot) SendSticker(chatId, replyTo int, eomji string) *MediaSender

SendSticker returns a MediaSender which has several methods for sending an sticker to all types of chats but channels. To send it to a channel use "SendStickerWithUN".

--------------------

Official telegram doc :

Use this method to send static .WEBP or animated .TGS stickers. On success, the sent Message is returned

func (*Bot) SendStickerWithUn

func (bot *Bot) SendStickerWithUn(chatId string, replyTo int, eomji string) *MediaSender

SendStickerWithUn returns a MediaSender which has several methods for sending an sticker to channels.

--------------------

Official telegram doc :

Use this method to send static .WEBP or animated .TGS stickers. On success, the sent Message is returned

func (*Bot) SendVenue

func (bot *Bot) SendVenue(chatId, replyTo int, latitude, longitude float32, title, address string, silent, protectContent bool) (*objs.Result[*objs.Message], error)

SendVenue sends a venue to all types of chat but channels. To send it to channels use "SendVenueUN" method.

---------------------------------

Official telegram doc :

Use this method to send information about a venue. On success, the sent Message is returned.

If "silent" argument is true, the message will be sent without notification.

If "protectContent" argument is true, the message can't be forwarded or saved.

func (*Bot) SendVenueUN

func (bot *Bot) SendVenueUN(chatId string, replyTo int, latitude, longitude float32, title, address string, silent, protectContent bool) (*objs.Result[*objs.Message], error)

SendVenueUN sends a venue to a channel.

---------------------------------

Official telegram doc :

Use this method to send information about a venue. On success, the sent Message is returned.

If "silent" argument is true, the message will be sent without notification.

If "protectContent" argument is true, the message can't be forwarded or saved.

func (*Bot) SendVideo

func (bot *Bot) SendVideo(chatId int, replyTo int, caption, parseMode string, hasSpoiler bool) *MediaSender

SendVideo returns a MediaSender which has several methods for sending a video. This method is only used for sending a video to all types of chat except channels. To send a video to a channel use "SendVideoUN" method. To ignore int arguments pass 0 and to ignore string arguments pass empty string ("")

---------------------------------

Official telegram doc :

Use this method to send video files, Telegram clients support mp4 videos (other formats may be sent as Document). On success, the sent Message is returned. Bots can currently send video files of up to 50 MB in size, this limit may be changed in the future.

func (*Bot) SendVideoNote

func (bot *Bot) SendVideoNote(chatId int, replyTo int, caption, parseMode string) *MediaSender

SendVideoNote returns a MediaSender which has several methods for sending a video note. This method is only used for sending a video note to all types of chat except channels. To send a video note to a channel use "SendVideoNoteUN" method. To ignore int arguments pass 0 and to ignore string arguments pass empty string ("")

---------------------------------

Official telegram doc :

As of v.4.0, Telegram clients support rounded square mp4 videos of up to 1 minute long. Use this method to send video messages. On success, the sent Message is returned.

func (*Bot) SendVideoNoteUN

func (bot *Bot) SendVideoNoteUN(chatId string, replyTo int, caption, parseMode string) *MediaSender

SendVideoNoteUN returns an MediaSender which has several methods for sending a video note. This method is only used for sending a video note to channels. To ignore int arguments pass 0 and to ignore string arguments pass empty string ("")

---------------------------------

Official telegram doc :

As of v.4.0, Telegram clients support rounded square mp4 videos of up to 1 minute long. Use this method to send video messages. On success, the sent Message is returned.

func (*Bot) SendVideoUN

func (bot *Bot) SendVideoUN(chatId string, replyTo int, caption, parseMode string, hasSpoiler bool) *MediaSender

SendVideoUN returns a MediaSender which has several methods for sending a video. This method is only used for sending a video to a channels. To ignore int arguments pass 0 and to ignore string arguments pass empty string ("")

---------------------------------

Official telegram doc :

Use this method to send video files, Telegram clients support mp4 videos (other formats may be sent as Document). On success, the sent Message is returned. Bots can currently send video files of up to 50 MB in size, this limit may be changed in the future.

func (*Bot) SendVoice

func (bot *Bot) SendVoice(chatId int, replyTo int, caption, parseMode string) *MediaSender

SendVoice returns a MediaSender which has several methods for sending a voice. This method is only used for sending a voice to all types of chat except channels. To send a voice to a channel use "SendVoiceUN" method. To ignore int arguments pass 0 and to ignore string arguments pass empty string ("")

---------------------------------

Official telegram doc :

Use this method to send audio files, if you want Telegram clients to display the file as a playable voice message. For this to work, your audio must be in an .OGG file encoded with OPUS (other formats may be sent as Audio or Document). On success, the sent Message is returned. Bots can currently send voice messages of up to 50 MB in size, this limit may be changed in the future.

func (*Bot) SendVoiceUN

func (bot *Bot) SendVoiceUN(chatId string, replyTo int, caption, parseMode string) *MediaSender

SendVoiceUN returns an MediaSender which has several methods for sending a voice. This method is only used for sending a voice to channels. To ignore int arguments pass 0 and to ignore string arguments pass empty string ("")

---------------------------------

Official telegram doc :

Use this method to send audio files, if you want Telegram clients to display the file as a playable voice message. For this to work, your audio must be in an .OGG file encoded with OPUS (other formats may be sent as Audio or Document). On success, the sent Message is returned. Bots can currently send voice messages of up to 50 MB in size, this limit may be changed in the future.

func (*Bot) SetCommandChatMenuButton

func (bot *Bot) SetCommandChatMenuButton(chatId int64) (*objs.Result[bool], error)

SetCommandChatMenuButton sets the current menu button of given chat to command meaning that it opens the bot's list of commands.

-------------------------

Official telegram doc :

Use this method to change the bot's menu button in a private chat, or the default menu button. Returns True on success.

func (*Bot) SetDefaultChatMenuButton

func (bot *Bot) SetDefaultChatMenuButton(chatId int64) (*objs.Result[bool], error)

SetDefaultChatMenuButton sets the current menu button of given chat to command meaning that it describes that no specific value for the menu button was set.

-------------------------

Official telegram doc :

Use this method to change the bot's menu button in a private chat, or the default menu button. Returns True on success.

func (*Bot) SetGameScore

func (bot *Bot) SetGameScore(userId, score, chatId, messageId int) (*objs.Result[json.RawMessage], error)

SetGameScore sets the score of the given user.

**To access more option use "ASetGameScoe" in advanced mode. -----------------------

Official telegram doc :

Use this method to set the score of the specified user in a game message. On success, if the message is not an inline message, the Message is returned, otherwise True is returned. Returns an error, if the new score is not greater than the user's current score in the chat and force is False.

"score" is new score, must be non-negative.

func (*Bot) SetMyCommands

func (bot *Bot) SetMyCommands(commands []objs.BotCommand, scope objs.BotCommandScope, languageCode string) (*objs.Result[bool], error)

func (*Bot) SetWebAppChatMenuButton

func (bot *Bot) SetWebAppChatMenuButton(chatId int64, text, url string) (*objs.Result[bool], error)

SetWebAppChatMenuButton sets the current menu button of given chat to web_app meaning that it launches a Web App.

-------------------------

Official telegram doc :

Use this method to change the bot's menu button in a private chat, or the default menu button. Returns True on success.

func (*Bot) Stop

func (bot *Bot) Stop()

Stop stops the bot

func (*Bot) UnbanChatMember

func (bot *Bot) UnbanChatMember(chatIdInt int, chatIdString string, userId int, onlyIfBanned bool) (*objs.Result[bool], error)

func (*Bot) UnpinAllChatMessages

func (bot *Bot) UnpinAllChatMessages(chatIdInt int, chatIdString string) (*objs.Result[bool], error)

func (*Bot) UnpinChatMessage

func (bot *Bot) UnpinChatMessage(chatIdInt int, chatIdString string, messageId int) (*objs.Result[bool], error)

func (*Bot) UploadStickerFile

func (bot *Bot) UploadStickerFile(userId int, stickerFormat string, eomjis, keywords []string, stickerFile *os.File) (*objs.Result[*objs.File], error)

UploadStickerFile can be used to upload a .PNG file with a sticker for later use in CreateNewStickerSet and AddStickerToSet methods (can be used multiple times). Returns the uploaded File on success.

func (*Bot) VerifyJoin

func (bot *Bot) VerifyJoin(userID int, UserName string) bool

VerifyJoin verifies if the user has joined the given channel or supergroup. Returns true if the user is present in the given chat, returns false if not or an error has occured.

type BotManager added in v2.1.0

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

BotManager is a tool for manaing personal info of the bot.

func (*BotManager) GetDescription added in v2.1.0

func (bm *BotManager) GetDescription(languageCode string) (*objs.Result[*objs.BotDescription], error)

GetDescription returns description of the bot based on the specified language.

func (*BotManager) GetMe added in v2.1.0

func (bm *BotManager) GetMe() (*objs.Result[*objs.User], error)

GetMe returns the received informations about the bot from api server.

---------------------

Official telegarm doc :

A simple method for testing your bot's authentication token. Requires no parameters. Returns basic information about the bot in form of a User object.

func (*BotManager) GetName added in v2.1.0

func (bm *BotManager) GetName(languageCode string) (*objs.Result[*objs.BotName], error)

GetName returns the bot's name according to the language code

func (*BotManager) GetShortDescription added in v2.1.0

func (bm *BotManager) GetShortDescription(languageCode string) (*objs.Result[*objs.BotDescription], error)

GetShortDescription returns short description of the bot based on the specified language.

func (*BotManager) SetDescription added in v2.1.0

func (bm *BotManager) SetDescription(description, languageCode string) (*objs.Result[bool], error)

SetDescription sets the description of the bot for the specified langauge. Description is shown in the chat with the bot if the chat is empty.

Arguments :

1. description : New bot description; 0-512 characters. Pass an empty string to remove the dedicated description for the given language.

2. languageCode : A two-letter ISO 639-1 language code. If empty, the description will be applied to all users for whose language there is no dedicated description.

func (*BotManager) SetName added in v2.1.0

func (bm *BotManager) SetName(name, languageCode string) (*objs.Result[bool], error)

SetName sets bot's name in the specified language

Arguments :

1. name : bot's new name

2. languageCode : A two-letter ISO 639-1 language code. If empty, the name will be shown to all users for whose language there is no dedicated name.

func (*BotManager) SetShortDescription added in v2.1.0

func (bm *BotManager) SetShortDescription(shortDescription, languageCode string) (*objs.Result[bool], error)

SetShortDescription sets the short description of the bot for the specified langauge. Short description is shown on the bot's profile page and is sent together with the link when users share the bot.

Arguments :

1. shortDescription : New short description for the bot; 0-120 characters. Pass an empty string to remove the dedicated short description for the given language.

2. languageCode : A two-letter ISO 639-1 language code. If empty, the description will be applied to all users for whose language there is no dedicated description.

type ChatManager

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

ChatManager is a tool for managing chats via the bot.

func (*ChatManager) ApproveJoinRequest

func (cm *ChatManager) ApproveJoinRequest(userId int) (*objs.Result[bool], error)

ApproveJoinRequest approves a chat join request. The bot must be an administrator in the chat for this to work and must have the can_invite_users administrator right. Returns True on success.

func (*ChatManager) BanChatSender

func (cm *ChatManager) BanChatSender(senderChatId int) (*objs.Result[bool], error)

BanChatSender bans a channel chat in a supergroup or a channel. Until the chat is unbanned, the owner of the banned chat won't be able to send messages on behalf of any of their channels. The bot must be an administrator in the supergroup or channel for this to work and must have the appropriate administrator rights. Returns True on success.

func (*ChatManager) BanMember

func (cm *ChatManager) BanMember(userId, untilDate int, revokeMessages bool) (*objs.Result[bool], error)

BanMember bans a user in a group, a supergroup or a channel. In the case of supergroups and channels, the user will not be able to return to the chat on their own using invite links, etc., unless unbanned first. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns True on success.

func (cm *ChatManager) CreateInviteLink(name string, expireDate, memberLimit int, createsJoinRequest bool) (*objs.Result[*objs.ChatInviteLink], error)

CreateInviteLink creates an additional invite link for a chat. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. The link can be revoked using the method RevokeInviteLink. Returns the new invite link as ChatInviteLink object.

func (*ChatManager) DeclineJoinRequest

func (cm *ChatManager) DeclineJoinRequest(userId int) (*objs.Result[bool], error)

DeclineJoinRequest can be used to decline a chat join request. The bot must be an administrator in the chat for this to work and must have the can_invite_users administrator right. Returns True on success.

func (*ChatManager) DeletePhoto

func (cm *ChatManager) DeletePhoto() (*objs.Result[bool], error)

DeletePhoto can be used to delete a chat photo. Photos can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns True on success.

func (*ChatManager) DeleteStickerSet

func (cm *ChatManager) DeleteStickerSet() (*objs.Result[bool], error)

DeleteStickerSet deletes a group sticker set from a supergroup. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Use the field can_set_sticker_set optionally returned in "GetChatInfo" to check if the bot can use this method. Returns True on success.

func (cm *ChatManager) EditInviteLink(inviteLink, name string, expireDate, memberLimit int, createsJoinRequest bool) (*objs.Result[*objs.ChatInviteLink], error)

EditInviteLink edits a non-primary invite link created by the bot. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns the edited invite link as a ChatInviteLink object.

func (cm *ChatManager) ExportInviteLink() (*objs.Result[string], error)

ExportInviteLink generates a new primary invite link for a chat; any previously generated primary link is revoked. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns the new invite link as String on success.

Note: Each administrator in a chat generates their own invite links. Bots can't use invite links generated by other administrators. If you want your bot to work with invite links, it will need to generate its own link using this method or by calling the getChat method. If your bot needs to generate a new primary invite link replacing its previous one, use this method again.

func (*ChatManager) GetAdmins

func (cm *ChatManager) GetAdmins() (*objs.Result[[]objs.ChatMemberOwner], error)

GetAdmins gets a list of administrators in a chat. On success, returns an Array of ChatMember objects that contains information about all chat administrators except other bots. If the chat is a group or a supergroup and no administrators were appointed, only the creator will be returned.

func (*ChatManager) GetChatInfo

func (cm *ChatManager) GetChatInfo() (*objs.Result[*objs.Chat], error)

GetChatInfo gets up to date information about the chat (current name of the user for one-on-one conversations, current username of a user, group or channel, etc.). Returns a Chat object on success.

func (*ChatManager) GetMember

func (cm *ChatManager) GetMember(userid int) (string, error)

GetMember gets information about a member of a chat. Returns a json serialized object of the member in string form on success.

func (*ChatManager) GetMembersCount

func (cm *ChatManager) GetMembersCount() (*objs.Result[int], error)

GetMembersCount gets the number of members in a chat. Returns Int on success.

func (*ChatManager) Leave

func (cm *ChatManager) Leave() (*objs.Result[bool], error)

Leave can be used for your bot to leave a group, supergroup or channel. Returns True on success.

func (*ChatManager) PinMessage

func (cm *ChatManager) PinMessage(messageId int, disableNotif bool) (*objs.Result[bool], error)

PinMessage adds a message to the list of pinned messages in a chat. If the chat is not a private chat, the bot must be an administrator in the chat for this to work and must have the 'can_pin_messages' administrator right in a supergroup or 'can_edit_messages' administrator right in a channel. Returns True on success.

func (*ChatManager) PromoteChatMember

func (cm *ChatManager) PromoteChatMember(userId int, isAnonymous, canManageChat, canPostmessages, canEditMessages, canDeleteMessages, canPostStories, canEditStories, canDeleteStoreis, canManageVideoChats, canRestrictMembers, canPromoteMembers, canChangeInfo, canInviteUsers, canPinMessages, canManageTopics bool) (*objs.Result[bool], error)

PromoteChatMember promotes or demote a user in a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Pass False for all boolean parameters to demote a user. Returns True on success.

func (*ChatManager) RestrictMember

func (cm *ChatManager) RestrictMember(userId int, untilDate int, useIndependentChatPermissions bool, canSendMessages, canSendMediaMessages, canSendPolls, canSendOtherMessages, canAddWebPagePreviews, canChangeInfo, canInviteUsers, canPinMessages bool) (*objs.Result[bool], error)

Use this method to restrict a user in a supergroup. The bot must be an administrator in the supergroup for this to work and must have the appropriate administrator rights. Pass True for all permissions to lift restrictions from a user. Returns True on success.

useIndependentChatPermissions : Pass True if chat permissions are set independently. Otherwise, the can_send_other_messages and can_add_web_page_previews permissions will imply the can_send_messages, can_send_audios, can_send_documents, can_send_photos, can_send_videos, can_send_video_notes, and can_send_voice_notes permissions; the can_send_polls permission will imply the can_send_messages permission.

func (cm *ChatManager) RevokeInviteLink(inviteLink string) (*objs.Result[*objs.ChatInviteLink], error)

RevokeInviteLink revokes an invite link created by the bot. If the primary link is revoked, a new link is automatically generated. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns the revoked invite link as ChatInviteLink object.

func (*ChatManager) SetCustomTitle

func (cm *ChatManager) SetCustomTitle(userId int, customTitle string) (*objs.Result[bool], error)

SetCustomTitle sets a custom title for an administrator in a supergroup promoted by the bot. Returns True on success.

func (*ChatManager) SetDescription

func (cm *ChatManager) SetDescription(description string) (*objs.Result[bool], error)

SetDescription changes the description of a group, a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns True on success.

func (*ChatManager) SetGeneralPermissions

func (cm *ChatManager) SetGeneralPermissions(useIndependentChatPermissions, canSendMessages, canSendMediaMessages, canSendPolls, canSendOtherMessages, canAddWebPagePreviews, canChangeInfo, canInviteUsers, canPinMessages bool) (*objs.Result[bool], error)

SetGeneralPermissions sets default chat permissions for all members. The bot must be an administrator in the group or a supergroup for this to work and must have the can_restrict_members administrator rights. Returns True on success.

useIndependentChatPermissions : Pass True if chat permissions are set independently. Otherwise, the can_send_other_messages and can_add_web_page_previews permissions will imply the can_send_messages, can_send_audios, can_send_documents, can_send_photos, can_send_videos, can_send_video_notes, and can_send_voice_notes permissions; the can_send_polls permission will imply the can_send_messages permission.

func (*ChatManager) SetPhoto

func (cm *ChatManager) SetPhoto(photoFile *os.File) (*objs.Result[bool], error)

SetPhoto can be used to set a new profile photo for the chat. Photos can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns True on success.

func (*ChatManager) SetStickerSet

func (cm *ChatManager) SetStickerSet(stickerSetName string) (*objs.Result[bool], error)

SetStickerSet sets a new group sticker set for a supergroup. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Use the field can_set_sticker_set optionally returned in "GetChatInfo" to check if the bot can use this method. Returns True on success.

func (*ChatManager) SetTitle

func (cm *ChatManager) SetTitle(title string) (*objs.Result[bool], error)

SetTitle changes the title of a chat. Titles can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns True on success.

func (*ChatManager) UnbanChatSender

func (cm *ChatManager) UnbanChatSender(senderChatId int) (*objs.Result[bool], error)

UnbanChatSender unbans a previously banned channel chat in a supergroup or channel. The bot must be an administrator for this to work and must have the appropriate administrator rights. Returns True on success.

func (*ChatManager) UnbanMember

func (cm *ChatManager) UnbanMember(userId int, onlyIfBanned bool) (*objs.Result[bool], error)

UnbanMember ubans a previously banned user in a supergroup or channel. The user will not return to the group or channel automatically, but will be able to join via link, etc. The bot must be an administrator for this to work. By default, this method guarantees that after the call the user is not a member of the chat, but will be able to join it. So if the user is a member of the chat they will also be removed from the chat. If you don't want this, use the parameter only_if_banned. Returns True on success.

func (*ChatManager) UnpinAllMessages

func (cm *ChatManager) UnpinAllMessages() (*objs.Result[bool], error)

UnpinAllMessages clears the list of pinned messages in a chat. If the chat is not a private chat, the bot must be an administrator in the chat for this to work and must have the 'can_pin_messages' administrator right in a supergroup or 'can_edit_messages' administrator right in a channel. Returns True on success.

func (*ChatManager) UnpinMessage

func (cm *ChatManager) UnpinMessage(messageId int) (*objs.Result[bool], error)

UnpinMessage removes a message from the list of pinned messages in a chat. If the chat is not a private chat, the bot must be an administrator in the chat for this to work and must have the 'can_pin_messages' administrator right in a supergroup or 'can_edit_messages' administrator right in a channel. Returns True on success.

type CommandsManager

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

CommandsManager is a tool for managing bot commands

func (*CommandsManager) AddCommand

func (cm *CommandsManager) AddCommand(command, description string) error

AddCommand adds a new command to the commands list.

At most 100 commands can be added.

func (*CommandsManager) DeleteCommands

func (cm *CommandsManager) DeleteCommands(languageCode string) (*objs.Result[bool], error)

DeleteCommands can be used to delete the list of the bot's commands for the given scope and user language. After deletion, higher level commands will be shown to affected users. Returns True on success.

func (*CommandsManager) GetCommands

func (cm *CommandsManager) GetCommands(languageCode string) ([]objs.BotCommand, error)

GetCommands returns the commands of this bot.

func (*CommandsManager) SetCommands

func (cm *CommandsManager) SetCommands(languageCode string) (*objs.Result[bool], error)

SetCommands calls the realted method on the api server and sets the added commansd with their specified scopes.

"languageCode" is a two-letter ISO 639-1 language code. If empty, commands will be applied to all users from the given scope, for whose language there are no dedicated commands

-------------------------

Official telegram doc :

Use this method to change the list of the bot's commands. See https://core.telegram.org/bots#commands for more details about bot commands. Returns True on success.

func (*CommandsManager) SetScope

func (cm *CommandsManager) SetScope(scope string, chatId []byte, userId int) error

SetScope sets the scope of this command manager.

Scope can have these values : "defaut","all_group_chats","all_private_chats","all_chat_administrators","chat","chat_administrator","chat_member". If scope is not valid error is returned.

type DocumentEditor

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

DocumentEditor is a tool for editing documents.

func (*DocumentEditor) EditByFile

func (di *DocumentEditor) EditByFile(file *os.File) (*objs.Result[json.RawMessage], error)

EditByFile edits this document by file in the device

func (*DocumentEditor) EditByFileIdOrURL

func (di *DocumentEditor) EditByFileIdOrURL(fileIdOrUrl string) (*objs.Result[json.RawMessage], error)

EditByFileIdOrURL edits this file by file id or url

func (*DocumentEditor) EditThumbnail

func (di *DocumentEditor) EditThumbnail(fileIdOrURL string)

EditThumbnail edits the tumbnail of the file. It takes a fileId or a url. If you want to send a file use "setThumbnailFile" instead.

func (*DocumentEditor) EditThumbnailFile

func (di *DocumentEditor) EditThumbnailFile(file *os.File) error

EditThumbnailFile edits the thumbnail of the file. It takes a file existing on the device

type DocumentInserter

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

DocumentInserter is a tool for inserting documents into the MediaGroup.

func (*DocumentInserter) AddByFile

func (di *DocumentInserter) AddByFile(file *os.File) error

AddByFile adds an existing file in the device

func (*DocumentInserter) AddByFileIdOrURL

func (di *DocumentInserter) AddByFileIdOrURL(fileIdOrUrl string)

AddByFileIdOrURL adds this file by file id or url

func (*DocumentInserter) SetThumbnail

func (di *DocumentInserter) SetThumbnail(fileIdOrURL string)

SetThumbnail sets the tumbnail of the file. It takes a fileId or a url. If you want to send a file use "setThumbnailFile" instead.

func (*DocumentInserter) SetThumbnailFile

func (di *DocumentInserter) SetThumbnailFile(file *os.File) error

SetThumbnailFile sets the tumbnail of the file. It takes a file existing on the device

type ForumTopicManager added in v2.1.0

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

ForumTopicManager is a special object for managing forum topics

func (*ForumTopicManager) Close added in v2.1.0

func (f *ForumTopicManager) Close() (*objs.Result[bool], error)

Close closes an open topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights, unless it is the creator of the topic. Returns True on success.

func (*ForumTopicManager) Delete added in v2.1.0

func (f *ForumTopicManager) Delete() (*objs.Result[bool], error)

Delete deletes a forum topic along with all its messages in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_delete_messages administrator rights. Returns True on success.

func (*ForumTopicManager) Edit added in v2.1.0

func (f *ForumTopicManager) Edit(name, iconCustomEmojiId string) (*objs.Result[bool], error)

Edit edits name and icon of a topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have can_manage_topics administrator rights, unless it is the creator of the topic. Returns True on success.

func (*ForumTopicManager) Reopen added in v2.1.0

func (f *ForumTopicManager) Reopen() (*objs.Result[bool], error)

Reopen reopens a closed topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights, unless it is the creator of the topic. Returns True on success.

func (*ForumTopicManager) UnpinAllMesages added in v2.1.0

func (f *ForumTopicManager) UnpinAllMesages() (*objs.Result[bool], error)

UnpinAllMesages clears the list of pinned messages in a forum topic. The bot must be an administrator in the chat for this to work and must have the can_pin_messages administrator right in the supergroup. Returns True on success.

type GeneralForumTopicManager added in v2.1.0

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

GeneralForumTopicManager is a special object for managing genreal forum topics

func (*GeneralForumTopicManager) Close added in v2.1.0

func (f *GeneralForumTopicManager) Close() (*objs.Result[bool], error)

Close closes an open 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. Returns True on success.

func (*GeneralForumTopicManager) Edit added in v2.1.0

func (f *GeneralForumTopicManager) Edit(name string) (*objs.Result[bool], error)

Edit edit the name of the 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have can_manage_topics administrator rights. Returns True on success.

func (*GeneralForumTopicManager) Hide added in v2.1.0

Hide hides the 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. The topic will be automatically closed if it was open. Returns True on success.

func (*GeneralForumTopicManager) Reopen added in v2.1.0

func (f *GeneralForumTopicManager) Reopen() (*objs.Result[bool], error)

Reopen reopens a closed 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. The topic will be automatically unhidden if it was hidden. Returns True on success.

func (*GeneralForumTopicManager) Unhide added in v2.1.0

func (f *GeneralForumTopicManager) Unhide() (*objs.Result[bool], error)

Unhide unhides the 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. Returns True on success.

func (*GeneralForumTopicManager) UnpinAllMesages added in v2.1.0

func (f *GeneralForumTopicManager) UnpinAllMesages() (*objs.Result[bool], error)

UnpinAllMesages clears the list of pinned messages in a General forum topic. The bot must be an administrator in the chat for this to work and must have the can_pin_messages administrator right in the supergroup. Returns True on success.

type InlineKeyboard added in v2.1.0

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

func (*InlineKeyboard) AddCallbackButton added in v2.1.0

func (in *InlineKeyboard) AddCallbackButton(text, callbackData string, row int)

AddCallbackButton adds a button that when its pressed, a call back query with the given data is sen to the bot

Note : row number starts from 1. (it's not zero based). If any number lower than 1 is passed, no button will be added.

func (*InlineKeyboard) AddCallbackButtonHandler added in v2.1.0

func (in *InlineKeyboard) AddCallbackButtonHandler(text, callbackData string, row int, handler func(*objs.Update))

AddCallbackButtonHandler adds a button that when its pressed, a call back query with the given data is sen to the bot. A handler is also added which will be called everytime a call back query is received for this button.

Note : row number starts from 1. (it's not zero based). If any number lower than 1 is passed, no button will be added.

func (*InlineKeyboard) AddGameButton added in v2.1.0

func (in *InlineKeyboard) AddGameButton(text string, row int)

AddGameButton adds a game button. Everytime a user presses this button a game will be launched. Use botfather to set up a game. NOTE: This type of button must always be the first button in the first row.

func (*InlineKeyboard) AddLoginURLButton added in v2.1.0

func (in *InlineKeyboard) AddLoginURLButton(text, url, forwardText, botUsername string, requestWriteAccess bool, row int)

AddLoginURLButton adds a button that will be used for automatic authorization. According to telegram bot api, login url is an HTTP URL used to automatically authorize the user. Can be used as a replacement for the Telegram Login Widget.

Note : row number starts from 1. (it's not zero based). If any number lower than 1 is passed, no button will be added.

Arguments :

1. url : An HTTP URL to be opened with user authorization data added to the query string when the button is pressed. If the user refuses to provide authorization data, the original URL without information about the user will be opened. The data added is the same as described in Receiving authorization data. NOTE: You must always check the hash of the received data to verify the authentication and the integrity of the data as described in Checking authorization.

2. forwardText : New text of the button in forwarded messages.

3. botUsername : Username of a bot, which will be used for user authorization. See Setting up a bot for more details. If not specified, the current bot's username will be assumed. The url's domain must be the same as the domain linked with the bot. See Linking your domain to the bot for more details.

4. requestWriteAccess : Pass True to request the permission for your bot to send messages to the user.

func (*InlineKeyboard) AddPayButton added in v2.1.0

func (in *InlineKeyboard) AddPayButton(text string)

AddPayButton adds a pay button.

NOTE: This type of button must always be the first button in the first row and can only be used in invoice messages.

Note : This method does not accept row number. This button is automatically added to row 1.

func (*InlineKeyboard) AddSwitchInlineQueryButton added in v2.1.0

func (in *InlineKeyboard) AddSwitchInlineQueryButton(text, inlineQuery string, row int, currenChat bool)

AddSwitchInlineQueryButton adds a switch inline query button. According to tlegram bot api, pressing the button will prompt the user to select one of their chats, open that chat and insert the bot's username and the specified inline query in the input field. Can be empty, in which case just the bot's username will be inserted. Note: This offers an easy way for users to start using your bot in inline mode when they are currently in a private chat with it. Especially useful when combined with switch_pm… actions – in this case the user will be automatically returned to the chat they switched from, skipping the chat selection screen.

Note : If "currentChat" option is true, the inline query will be inserted in the current chat's input field.

Note : row number starts from 1. (it's not zero based). If any number lower than 1 is passed, no button will be added.

func (*InlineKeyboard) AddSwitchInlineQueryChoseChatButton added in v2.1.0

func (in *InlineKeyboard) AddSwitchInlineQueryChoseChatButton(text, inlineQuery string, allowUserChats, allowBotChats, allowGroupChats, allowChannelChats bool, row int)

AddSwitchInlineQueryChoseChatButton adds a switch inline query button. According to tlegram bot api, pressing the button will prompt the user to select one of their chats of the specified type, open that chat and insert the bot's username and the specified inline query in the input field

Note : row number starts from 1. (it's not zero based). If any number lower than 1 is passed, no button will be added.

Arguemtns :

allowUserChats : True, if private chats with users can be chosen

allowBotChats : True, if private chats with bots can be chosen

allowGroupChats : True, if group and supergroup chats can be chosen

allowChannelChats : True, if channel chats can be chosen

func (*InlineKeyboard) AddURLButton added in v2.1.0

func (in *InlineKeyboard) AddURLButton(text, url string, row int)

AddURLButton adds a button that will open an url when pressed.

Note : row number starts from 1. (it's not zero based). If any number lower than 1 is passed, no button will be added

func (*InlineKeyboard) AddWebAppButton added in v2.1.0

func (in *InlineKeyboard) AddWebAppButton(text string, row int, url string)

AddWebAppButton adds a button which opens a web app when it's pressed.

Note : row number starts from 1. (it's not zero based). If any number lower than 1 is passed, no button will be added.

type InlineQueryResponder

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

func (*InlineQueryResponder) AddArticle

func (iqs *InlineQueryResponder) AddArticle(id, title, url, description, thumbUrl string, thumbWidth, thumbHeight int, hideUrl bool, message objs.InputMessageContent, keyboard *InlineKeyboard) error

Adds an article to the result. No more than 50 results are allowed. Also only one result is allowed for web app response.

"message" argument is the message that will be sent if this result is pressed. It is necessary and if it's not passed the API server will return "400 bad request, message_text is missing".You can use "Create***Message" method to create this messages.

func (*InlineQueryResponder) AddAudio

func (iqs *InlineQueryResponder) AddAudio(id, title, audioURL, caption, parseMode, performer string, audioDuration int, message objs.InputMessageContent, keyboard *InlineKeyboard, captionEntities []objs.MessageEntity) error

Adds an audio to the result. No more than 50 results are allowed. Also only one result is allowed for web app response.

Represents a link to an MP3 audio file. By default, this audio file will be sent by the user. Alternatively, you can use message field to send a message with the specified content instead of the audio.

"message" argument is the message that will be sent if this result is pressed. It is necessary and if it's not passed the API server will return "400 bad request, message_text is missing".You can use "Create***Message" method to create this messages.

func (*InlineQueryResponder) AddCachedAudio

func (iqs *InlineQueryResponder) AddCachedAudio(id, title, audioFileId, caption, parseMode string, message objs.InputMessageContent, keyboard *InlineKeyboard, captionEntities []objs.MessageEntity) error

Adds an audio to the result. No more than 50 results are allowed. Also only one result is allowed for web app response.

Represents a link to an MP3 audio file stored on the Telegram servers. By default, this audio file will be sent by the user. Alternatively, you can use message field to send a message with the specified content instead of the audio.

"message" argument is the message that will be sent if this result is pressed. It is necessary and if it's not passed the API server will return "400 bad request, message_text is missing". You can use "Create***Message" method to create this messages.

func (*InlineQueryResponder) AddCachedDocument

func (iqs *InlineQueryResponder) AddCachedDocument(id, title, documentFileId, description, caption, parseMode string, messsage objs.InputMessageContent, keyboard *InlineKeyboard, captionEntities []objs.MessageEntity) error

Adds a cached document to the result. No more than 50 results are allowed. Also only one result is allowed for web app response.

Represents a link to a file stored on the Telegram servers. By default, this file will be sent by the user with an optional caption. Alternatively, you can use message field to send a message with the specified content instead of the file.

"message" argument is the message that will be sent if this result is pressed. It is necessary and if it's not passed the API server will return "400 bad request, message_text is missing". You can use "Create***Message" method to create this messages.

func (*InlineQueryResponder) AddCachedGif

func (iqs *InlineQueryResponder) AddCachedGif(id, title, gifFileId, caption, parseMode string, message objs.InputMessageContent, keyboard *InlineKeyboard, captionEntities []objs.MessageEntity) error

Adds a cached gif to the result. No more than 50 results are allowed. Also only one result is allowed for web app response.

Represents a link to an animated GIF file stored on the Telegram servers. By default, this animated GIF file will be sent by the user with an optional caption. Alternatively, you can use message field to send a message with specified content instead of the animation.

"message" argument is the message that will be sent if this result is pressed. It is necessary and if it's not passed the API server will return "400 bad request, message_text is missing". You can use "Create***Message" method to create this messages.

func (*InlineQueryResponder) AddCachedMpeg4Gif

func (iqs *InlineQueryResponder) AddCachedMpeg4Gif(id, title, mpeg4FileId, caption, parseMode string, message objs.InputMessageContent, keyboard *InlineKeyboard, captionEntities []objs.MessageEntity) error

Adds a cached mpeg4 to the result. No more than 50 results are allowed. Also only one result is allowed for web app response.

Represents a link to a video animation (H.264/MPEG-4 AVC video without sound) stored on the Telegram servers. By default, this animated MPEG-4 file will be sent by the user with an optional caption. Alternatively, you can use message field to send a message with the specified content instead of the animation.

"message" argument is the message that will be sent if this result is pressed. It is necessary and if it's not passed the API server will return "400 bad request, message_text is missing". You can use "Create***Message" method to create this messages.

func (*InlineQueryResponder) AddCachedPhoto

func (iqs *InlineQueryResponder) AddCachedPhoto(id, title, photoFileId, description, caption, parseMode string, message objs.InputMessageContent, keyboard *InlineKeyboard, captionEntities []objs.MessageEntity) error

Adds a cached photo to the result. No more than 50 results are allowed. Also only one result is allowed for web app response.

Represents a link to a photo stored on the Telegram servers. By default, this photo will be sent by the user with an optional caption. Alternatively, you can use message field to send a message with the specified content instead of the photo.

"message" argument is the message that will be sent if this result is pressed. It is necessary and if it's not passed the API server will return "400 bad request, message_text is missing". You can use "Create***Message" method to create this messages.

func (*InlineQueryResponder) AddCachedSticker

func (iqs *InlineQueryResponder) AddCachedSticker(id, stickerFileId string, message objs.InputMessageContent, keyboard *InlineKeyboard) error

Adds a cached mpeg4 to the result. No more than 50 results are allowed. Also only one result is allowed for web app response.

Represents a link to a sticker stored on the Telegram servers. By default, this sticker will be sent by the user. Alternatively, you can use message field to send a message with the specified content instead of the sticker.

"message" argument is the message that will be sent if this result is pressed. It is necessary and if it's not passed the API server will return "400 bad request, message_text is missing". You can use "Create***Message" method to create this messages.

func (*InlineQueryResponder) AddCachedVideo

func (iqs *InlineQueryResponder) AddCachedVideo(id, title, videoFileId, caption, description, parseMode string, message objs.InputMessageContent, keyboard *InlineKeyboard, captionEntities []objs.MessageEntity) error

Adds a cached video to the result. No more than 50 results are allowed. Also only one result is allowed for web app response.

Represents a link to a video file stored on the Telegram servers. By default, this video file will be sent by the user with an optional caption. Alternatively, you can use message field to send a message with the specified content instead of the video.

"message" argument is the message that will be sent if this result is pressed. It is necessary and if it's not passed the API server will return "400 bad request, message_text is missing". You can use "Create***Message" method to create this messages.

func (*InlineQueryResponder) AddCachedVoice

func (iqs *InlineQueryResponder) AddCachedVoice(id, title, voiceFileId, caption, parseMode string, message objs.InputMessageContent, keyboard *InlineKeyboard, captionEntities []objs.MessageEntity) error

Adds a voice to the result. No more than 50 results are allowed. Also only one result is allowed for web app response.

Represents a link to a voice message stored on the Telegram servers. By default, this voice message will be sent by the user. Alternatively, you can use message field to send a message with the specified content instead of the voice message.

"message" argument is the message that will be sent if this result is pressed. It is necessary and if it's not passed the API server will return "400 bad request, message_text is missing". You can use "Create***Message" method to create this messages.

func (*InlineQueryResponder) AddContact

func (iqs *InlineQueryResponder) AddContact(id, title, thumbUrl, phoneNumber, firstName, lastName, vCard string, thumbWidth, thumbHeight int, message objs.InputMessageContent, keyboard *InlineKeyboard) error

Adds a contact to the result. No more than 50 results are allowed. Also only one result is allowed for web app response.

Represents a contact with a phone number. By default, this contact will be sent by the user. Alternatively, you can use message field to send a message with the specified content instead of the contact.

"message" argument is the message that will be sent if this result is pressed. It is necessary and if it's not passed the API server will return "400 bad request, message_text is missing". You can use "Create***Message" method to create this messages.

func (*InlineQueryResponder) AddDocument

func (iqs *InlineQueryResponder) AddDocument(id, title, documentURL, mimeType, description, thumbUrl, caption, parseMode string, thumbWidth, thumbHeight int, message objs.InputMessageContent, keyboard *InlineKeyboard, captionEntities []objs.MessageEntity) error

Adds a document to the result. No more than 50 results are allowed. Also only one result is allowed for web app response.

Represents a link to a file. By default, this file will be sent by the user with an optional caption. Alternatively, you can use message field to send a message with the specified content instead of the file. Currently, only .PDF and .ZIP files can be sent using this method.

"message" argument is the message that will be sent if this result is pressed. It is necessary and if it's not passed the API server will return "400 bad request, message_text is missing". You can use "Create***Message" method to create this messages.

func (*InlineQueryResponder) AddGame

func (iqs *InlineQueryResponder) AddGame(id, gameShortName string, keyboard *InlineKeyboard) error

Adds a game to the result. No more than 50 results are allowed. Also only one result is allowed for web app response.

Represents a game

func (*InlineQueryResponder) AddGif

func (iqs *InlineQueryResponder) AddGif(id, title, gifURL, caption, parseMode, thumbUrl, thumbMIMEType string, gifWidth, gifHeight, gifDuration int, message objs.InputMessageContent, keyboard *InlineKeyboard, captionEntities []objs.MessageEntity) error

Adds a gif to the result. No more than 50 results are allowed. Also only one result is allowed for web app response.

Represents a link to an animated GIF file. By default, this animated GIF file will be sent by the user with optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the animation.

"message" argument is the message that will be sent if this result is pressed. It is necessary and if it's not passed the API server will return "400 bad request, message_text is missing".You can use "Create***Message" method to create this messages.

func (*InlineQueryResponder) AddLocation

func (iqs *InlineQueryResponder) AddLocation(id, title, thumbUrl string, latitude, longitude, horizontalAccuracy float32, livePeriod, heading, proximityAlertRadius, thumbWidth, thumbHeight int, message objs.InputMessageContent, keyboard *InlineKeyboard) error

Adds a location to the result. No more than 50 results are allowed. Also only one result is allowed for web app response.

Represents a location on a map. By default, the location will be sent by the user. Alternatively, you can use message field to send a message with the specified content instead of the location.

"message" argument is the message that will be sent if this result is pressed. It is necessary and if it's not passed the API server will return "400 bad request, message_text is missing". You can use "Create***Message" method to create this messages.

func (*InlineQueryResponder) AddMpeg4Gif

func (iqs *InlineQueryResponder) AddMpeg4Gif(id, title, mpeg4URL, caption, parseMode, thumbUrl, thumbMIMEType string, mpeg4Width, mpeg4Height, mpeg4Duration int, message objs.InputMessageContent, keyboard *InlineKeyboard, captionEntities []objs.MessageEntity) error

Adds a mpeg4 to the result. No more than 50 results are allowed. Also only one result is allowed for web app response.

Represents a link to a video animation (H.264/MPEG-4 AVC video without sound). By default, this animated MPEG-4 file will be sent by the user with optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the animation.

"message" argument is the message that will be sent if this result is pressed. It is necessary and if it's not passed the API server will return "400 bad request, message_text is missing".You can use "Create***Message" method to create this messages.

func (*InlineQueryResponder) AddPhoto

func (iqs *InlineQueryResponder) AddPhoto(id, title, photoURL, description, caption, parseMode, thumbUrl string, photoWidth, photoHeight int, message objs.InputMessageContent, keyboard *InlineKeyboard, captionEntities []objs.MessageEntity) error

Adds a photo to the result. No more than 50 results are allowed. Also only one result is allowed for web app response.

Represents a link to a photo. By default, this photo will be sent by the user with optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the photo.

"message" argument is the message that will be sent if this result is pressed. It is necessary and if it's not passed the API server will return "400 bad request, message_text is missing".You can use "Create***Message" method to create this messages.

func (*InlineQueryResponder) AddVenue

func (iqs *InlineQueryResponder) AddVenue(id, title, thumbUrl string, latitude, longitude float32, address, foursquareId, foursquareType, googlePlaceId, googlePlaceType string, thumbWidth, thumbHeight int, message objs.InputMessageContent, keyboard *InlineKeyboard) error

Adds a venue to the result. No more than 50 results are allowed. Also only one result is allowed for web app response.

Represents a venue. By default, the venue will be sent by the user. Alternatively, you can use message field to send a message with the specified content instead of the venue.

"message" argument is the message that will be sent if this result is pressed. It is necessary and if it's not passed the API server will return "400 bad request, message_text is missing". You can use "Create***Message" method to create this messages.

func (*InlineQueryResponder) AddVideo

func (iqs *InlineQueryResponder) AddVideo(id, title, videoURL, mimeType, caption, description, parseMode, thumbUrl string, videoWidth, videoHeight, videoDuration int, message objs.InputMessageContent, keyboard *InlineKeyboard, captionEntities []objs.MessageEntity) error

Adds a video to the result. No more than 50 results are allowed. Also only one result is allowed for web app response.

Represents a link to a page containing an embedded video player or a video file. By default, this video file will be sent by the user with an optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the video.

If an InlineQueryResultVideo message contains an embedded video (e.g., YouTube), you must replace its content using message field.

"message" argument is the message that will be sent if this result is pressed. It is necessary and if it's not passed the API server will return "400 bad request, message_text is missing".You can use "Create***Message" method to create this messages.

func (*InlineQueryResponder) AddVoice

func (iqs *InlineQueryResponder) AddVoice(id, title, voiceURL, caption, parseMode string, voiceDuration int, message objs.InputMessageContent, keyboard *InlineKeyboard, captionEntities []objs.MessageEntity) error

Adds a voice to the result. No more than 50 results are allowed. Also only one result is allowed for web app response.

Represents a link to a voice recording in an .OGG container encoded with OPUS. By default, this voice recording will be sent by the user. Alternatively, you can use message field to send a message with the specified content instead of the the voice message.

"message" argument is the message that will be sent if this result is pressed. It is necessary and if it's not passed the API server will return "400 bad request, message_text is missing".You can use "Create***Message" method to create this messages.

func (*InlineQueryResponder) CreateContactMessage

func (iqs *InlineQueryResponder) CreateContactMessage(phoneNumber, firstName, lastName, vCard string) objs.InputMessageContent

Use this function to create a contact message to be passed as "message" argument in "Add" methods.

func (*InlineQueryResponder) CreateInvoiceMessage

func (iqs *InlineQueryResponder) CreateInvoiceMessage(invoice *Invoice) objs.InputMessageContent

Use this function to create an invoice message to be passed as "message" argument in "Add" methods.

func (*InlineQueryResponder) CreateLocationMessage

func (iqs *InlineQueryResponder) CreateLocationMessage(latitude, longitude, accuracy float32, liveperiod, heading, proximityAlertRadius int) objs.InputMessageContent

Use this function to create a location message to be passed as "message" argument in "Add" methods.

func (*InlineQueryResponder) CreateTextMessage

func (iqs *InlineQueryResponder) CreateTextMessage(text, parseMode string, entities []objs.MessageEntity, disabelWebPagePreview bool) objs.InputMessageContent

Use this function to create a text message to be passed as "message" argument in "Add" methods.

func (*InlineQueryResponder) CreateVenueMessage

func (iqs *InlineQueryResponder) CreateVenueMessage(latitude, longitude float32, title, address, foursquareId, foursquareType, googlePlaceId, googlePlaceType string) objs.InputMessageContent

Use this function to create a venue message to be passed as "message" argument in "Add" methods.

func (*InlineQueryResponder) Send

func (iqs *InlineQueryResponder) Send() (interface{}, error)

Sends this answer to the user. The returned result can have two types : Result[bool] or SentWebAppMessage.

func (*InlineQueryResponder) SetButton

func (iqs *InlineQueryResponder) SetButton(text, startParameter, webAppURL string)

SetButton adds a button that will be shown above inline query results.

Arguments :

1. text : Label text on the button

2. webAppURL : Description of the Web App that will be launched when the user presses the button. The Web App will be able to switch back to the inline mode using the method switchInlineQuery inside the Web App.

3. startParameter : Deep-linking parameter for the /start message sent to the bot when a user presses the button. 1-64 characters, only A-Z, a-z, 0-9, _ and - are allowed. Example: An inline bot that sends YouTube videos can ask the user to connect the bot to their YouTube account to adapt search results accordingly. To do this, it displays a 'Connect your YouTube account' button above the results, or even before showing any. The user presses the button, switches to a private chat with the bot and, in doing so, passes a start parameter that instructs the bot to return an OAuth link. Once done, the bot can offer a switch_inline button so that the user can easily return to the chat where they wanted to use the bot's inline capabilities.

type Invoice

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

Invoice is an invoice that can be modified and sent to the user.

func (*Invoice) AddPrice

func (is *Invoice) AddPrice(label string, amount int)

AddPrice adds a new price label to this invoice.

"amount" is the price of the product in the smallest units of the currency (integer, not float/double). For example, for a price of US$ 1.45 pass amount = 145.

func (is *Invoice) CreateLink() (*objs.Result[string], error)

CreateLink creates a link for the invoice and returnes the link.

-------------------------------

Official telegram doc :

Use this method to create a link for an invoice. Returns the created invoice link as String on success.

func (*Invoice) Send

func (is *Invoice) Send(replyTo, messageThreadId int, silent bool) (*objs.Result[*objs.Message], error)

Send sends this invoice.

-------------------------------

Official telegram doc :

Use this method to send invoices. On success, the sent Message is returned.

type Keyboard added in v2.1.0

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

Keyboard is a normal Keyboard.

func (*Keyboard) AddButton added in v2.1.0

func (kb *Keyboard) AddButton(text string, row int)

AddButton adds a new button holding the given text to the specified row. According to telegram bot api if this button is pressed the text inside the button will be sent to the bot as a message.

Note : row number starts from 1. (it's not zero based). If any number lower than 1 is passed, no button will be added

func (*Keyboard) AddButtonHandler added in v2.1.0

func (kb *Keyboard) AddButtonHandler(text string, row int, handler func(*objs.Update), chatTypes ...string)

AddButtonHandler adds a new button holding the given text to the specified row. This method also adds a handler for that button so everytime this button is pressed the handler will be called. You can read the documentation of "AddHandler" for better understanding on handlers.

Note : row number starts from 1. (it's not zero based). If any number lower than 1 is passed, no button will be added

func (*Keyboard) AddContactButton added in v2.1.0

func (kb *Keyboard) AddContactButton(text string, row int)

AddContactButton adds a new contact button. According to telegram bot api when this button is pressed,the user's phone number will be sent as a contact. Available in private chats only.

Note: ContactButtons and LocationButtons will only work in Telegram versions released after 9 April, 2016. Older clients will display unsupported message.

Note : row number starts from 1. (it's not zero based). If any number lower than 1 is passed, no button will be added

func (*Keyboard) AddLocationButton added in v2.1.0

func (kb *Keyboard) AddLocationButton(text string, row int)

AddLocationButton adds a new location button. According to telegram bot api when this button is pressed,the user's location will be sent. Available in private chats only.

Note: ContactButtons and LocationButtons will only work in Telegram versions released after 9 April, 2016. Older clients will display unsupported message.

Note : row number starts from 1. (it's not zero based). If any number lower than 1 is passed, no button will be added

func (*Keyboard) AddPollButton added in v2.1.0

func (kb *Keyboard) AddPollButton(text string, row int, pollType string)

AddPollButton adds a new poll button. According to telegram bot api, the user will be asked to create a poll and send it to the bot when this button is pressed. Available in private chats only.

Note: PollButton will only work in Telegram versions released after 23 January, 2020. Older clients will display unsupported message.

Note : row number starts from 1. (it's not zero based). If any number lower than 1 is passed, no button will be added.

Note : poll type can be "regular" or "quiz". Any other value will cause the button not to be added.

func (*Keyboard) AddRequestChatButton added in v2.1.0

func (kb *Keyboard) AddRequestChatButton(text string, row, requestId int, chatIsChannel, chatIsForum, chatHasUsername, chatIsCreated, botIsMember bool, userAdminRights, botAdminRights *objs.ChatAdministratorRights, handler func(*objs.Update))

AddRequestChatButton adds a button that asks for a chat to be selected when its pressed.

The identifier of the selected chat will be shared with the bot in the ChatShared object of Message object when the corresponding button is pressed.

Arguments :

1. requestId : Signed 32-bit identifier of the request, which will be received back in the ChatShared object. Must be unique within the message.

2. chatIsChannel : Pass True to request a channel chat, pass False to request a group or a supergroup chat.

3. chatIsForum : Pass True to request a forum supergroup, pass False to request a non-forum chat. If not specified, no additional restrictions are applied.

4. chatHasUsername : Pass True to request a supergroup or a channel with a username, pass False to request a chat without a username. If not specified, no additional restrictions are applied.

5. chatIsCreated : Pass True to request a chat owned by the user. Otherwise, no additional restrictions are applied.

6. botIsMemeber : Pass True to request a chat with the bot as a member. Otherwise, no additional restrictions are applied.

7. userAdminRights : A ChatAdministratorRights object listing the required administrator rights of the user in the chat. The rights must be a superset of bot_administrator_rights. If not specified, no additional restrictions are applied.

8. botAdminRights : A ChatAdministratorRights object listing the required administrator rights of the bot in the chat. The rights must be a subset of user_administrator_rights. If not specified, no additional restrictions are applied.

9. handler : A handler that will be executed when the user presses this button. If handler is not nil, bot automatically parses the incoming updates on this request id. Pass nil if you don't want any handler.

func (*Keyboard) AddRequestUserButton added in v2.1.0

func (kb *Keyboard) AddRequestUserButton(text string, row, requestId int, userIsBot, userIsPremium bool, handler func(*objs.Update))

AddRequestUserButton adds a buuton which asks for a users chat when its pressed.

The identifier of the selected user will be shared with the bot in the UserShared object of Message object when the corresponding button is pressed.

Arguments :

1. requestId : Signed 32-bit identifier of the request, which will be received back in the UserShared object. Must be unique within the message.

2. userIsBot : Pass True to request a bot, pass False to request a regular user. If not specified, no additional restrictions are applied.

3. userIsPremimum : True to request a premium user, pass False to request a non-premium user. If not specified, no additional restrictions are applied.

4. handler : A handler that will be executed when the user presses this button. If handler is not nil, bot automatically parses the incoming updates on this request id. Pass nil if you don't want any handler.

func (*Keyboard) AddWebAppButton added in v2.1.0

func (kb *Keyboard) AddWebAppButton(text string, row int, url string)

AddWebAppButton adds a button which opens a web app when it's pressed.

Note : row number starts from 1. (it's not zero based). If any number lower than 1 is passed, no button will be added.

type LiveLocation

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

LiveLocation is a live location that can be sent to a user.

func (*LiveLocation) Edit

func (ll *LiveLocation) Edit(latitude, langitude, horizontalAccuracy float32, heading, proximtyAlertRadius int, replyMarkUp *objs.InlineKeyboardMarkup) (*objs.Result[json.RawMessage], error)

Edit edits the live location.

------------------------

Official telegram doc :

Use this method to edit live location messages. A location can be edited until its live_period expires or editing is explicitly disabled by a call to stopMessageLiveLocation. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned.

func (*LiveLocation) Send

func (ll *LiveLocation) Send(chatId int, silent, protectContent bool) (*objs.Result[*objs.Message], error)

Send sends this live location to all types of chats but channels. To send it to a channel use "SendToChannelMethod".

If "silent" argument is true, the message will be sent without notification.

If "protectContent" argument is true, the message can't be forwarded or saved.

------------------------

Official telegram doc :

Use this method to send point on the map. On success, the sent Message is returned.

func (*LiveLocation) SendToChannel

func (ll *LiveLocation) SendToChannel(chatId string, silent, protectContent bool) (*objs.Result[*objs.Message], error)

SendToChannel sends this live location to a channel. Chat id should be the username of the channel.

If "silent" argument is true, the message will be sent without notification.

If "protectContent" argument is true, the message can't be forwarded or saved.

------------------------

Official telegram doc :

Use this method to send point on the map. On success, the sent Message is returned.

func (*LiveLocation) Stop

func (ll *LiveLocation) Stop(replyMarkrup objs.InlineKeyboardMarkup) (*objs.Result[json.RawMessage], error)

Stop stops the live location.

------------------------

Official telegram doc :

Use this method to stop updating a live location message before live_period expires. On success, if the message is not an inline message, the edited Message is returned, otherwise True is returned.

type MarkUps

type MarkUps interface {
	// contains filtered or unexported methods
}

MarkUps is the interface used for creating normal keyboards and inline keyboards.

type MediaGroup

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

MediaGroup is a media group that can be sent

func (*MediaGroup) AddAnimation

func (mg *MediaGroup) AddAnimation(caption, parseMode string, width, height, duration int, hasSpoiler bool, captionEntitie []objs.MessageEntity) (*AnimationInserter, error)

AddAnimation returns an AnimationInserter to add an animation to the album

func (*MediaGroup) AddAudio

func (mg *MediaGroup) AddAudio(caption, parseMode, performer, title string, duration int, captionEntitie []objs.MessageEntity) (*AudioInserter, error)

AddAudio returns an AudioInserter to add an audio to the album

func (*MediaGroup) AddDocument

func (mg *MediaGroup) AddDocument(caption, parseMode string, disableContentTypeDetection bool, captionEntitie []objs.MessageEntity) (*DocumentInserter, error)

AddDocument returns a DocumentInserter to add a document to the album

func (*MediaGroup) AddPhoto

func (mg *MediaGroup) AddPhoto(caption, parseMode string, hasSpoiler bool, captionEntitie []objs.MessageEntity) (*PhotoInserter, error)

AddPhoto returns a PhotoInserter to add a photo to the album

func (*MediaGroup) AddVideo

func (mg *MediaGroup) AddVideo(caption, parseMode string, width, height, duration int, supportsStreaming, hasSpoiler bool, captionEntitie []objs.MessageEntity) (*VideoInserter, error)

AddVideo returns a VideoInserter to add a video to the album

func (*MediaGroup) Send

func (mg *MediaGroup) Send(chatId int, silent, protectContent bool) (*objs.Result[[]objs.Message], error)

Send sends this album (to all types of chat but channels, to send to channels use "SendToChannel" method)

--------------------

Official telegram doc :

Use this method to send a group of photos, videos, documents or audios as an album. Documents and audio files can be only grouped in an album with messages of the same type. On success, an array of Messages that were sent is returned.

If "silent" argument is true, the message will be sent without notification.

If "protectContent" argument is true, the message can't be forwarded or saved.

func (*MediaGroup) SendToChannel

func (mg *MediaGroup) SendToChannel(chatId string, silent, protectContent bool) (*objs.Result[[]objs.Message], error)

Send sends this album to a channel.

--------------------

Official telegram doc :

Use this method to send a group of photos, videos, documents or audios as an album. Documents and audio files can be only grouped in an album with messages of the same type. On success, an array of Messages that were sent is returned.

If "silent" argument is true, the message will be sent without notification.

If "protectContent" argument is true, the message can't be forwarded or saved.

type MediaSender

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

MediaSender is a tool for sending media messages.

func (*MediaSender) SendByFile

func (ms *MediaSender) SendByFile(file *os.File, silent, protectContent bool) (*objs.Result[*objs.Message], error)

SendByFile sends a file that is located in this device.

func (*MediaSender) SendByFileIdOrUrl

func (ms *MediaSender) SendByFileIdOrUrl(fileIdOrUrl string, silent, protectContent bool) (*objs.Result[*objs.Message], error)

SendByFileIdOrUrl sends a file that already exists on telegram servers (file id) or a url on the web.

func (*MediaSender) SetThumbnail

func (ms *MediaSender) SetThumbnail(fileIdOrURL string)

SetThumbnail sets the tumbnail of the file. It takes a file id or a url. If you want to send a file use "setThumbnailFile" instead. If this media does not support thumbnail, the thumbnail will be ignored.

func (*MediaSender) SetThumbnailFile

func (ms *MediaSender) SetThumbnailFile(file *os.File) error

SetThumbnailFile sets the thumbnail of the file. It takes a file existing on the device. If this media does not support thumbnail, the thumbnail will be ignored.

type MediaType

type MediaType int
const (
	PHOTO     MediaType = 1
	VIDEO     MediaType = 2
	AUDIO     MediaType = 3
	ANIMATION MediaType = 4
	DOCUMENT  MediaType = 5
	VIDEONOTE MediaType = 6
	VOICE     MediaType = 7
	STICKER   MediaType = 8
)

type MessageCopier

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

MessageCopier is tool for copying messages.

func (*MessageCopier) CopyFromChannelToChannel

func (mf *MessageCopier) CopyFromChannelToChannel(chatId, fromChatId string) (*objs.Result[*objs.Message], error)

CopyFromChannelToChannel copies the given message from a channel to another channel. chatId is the channel that message is being copied to and fromChatId is the channel that message is being copied to.

func (*MessageCopier) CopyFromChannelToUser

func (mf *MessageCopier) CopyFromChannelToUser(chatId int, fromChatId string) (*objs.Result[*objs.Message], error)

CopyFromChannelToUser copies the given message from a channel to a user. chatId is the user that message is being copied to and fromChatId is the channel that message is being copied to.

func (*MessageCopier) CopyFromUserToChannel

func (mf *MessageCopier) CopyFromUserToChannel(chatId string, fromChatId int) (*objs.Result[*objs.Message], error)

CopyFromUserToChannel copies the given message from a user to a channel. chatId is the channel that message is being copied to and fromChatId is the user that message is being copied to.

func (*MessageCopier) CopyFromUserToUser

func (mf *MessageCopier) CopyFromUserToUser(chatId, fromChatId int) (*objs.Result[*objs.Message], error)

CopyFromUserToUser copies the given message from a user to another user. chatId is the user that message is being copied to and fromChatId is the user that message is being copied to.

type MessageEditor

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

MessageEditor is a tool for editing messsages.

func (*MessageEditor) DeletIn added in v2.1.0

func (me *MessageEditor) DeletIn(messageId int, delay time.Duration)

DeletIn deletes the message with a delay. Delay should be in time.Duration format. Once this method is called it cannot be canceled. All the rules of DeleteMessage method apply to this method too.

func (*MessageEditor) DeleteMessage

func (me *MessageEditor) DeleteMessage(messageId int) (*objs.Result[bool], error)

DeleteMessage can be used to delete a message, including service messages, with the following limitations:

- A message can only be deleted if it was sent less than 48 hours ago.

- A dice message in a private chat can only be deleted if it was sent more than 24 hours ago.

- Bots can delete outgoing messages in private chats, groups, and supergroups.

- Bots can delete incoming messages in private chats.

- Bots granted can_post_messages permissions can delete outgoing messages in channels.

- If the bot is an administrator of a group, it can delete any message there.

- If the bot has can_delete_messages permission in a supergroup or a channel, it can delete any message there.

- Note that service messages about forum topic creation can't be deleted with the deleteMessage method.

Returns True on success.

func (*MessageEditor) EditCaption

func (me *MessageEditor) EditCaption(messageId int, caption, inlineMessageId, parseMode string, captionEntities []objs.MessageEntity, keyboard *InlineKeyboard) (*objs.Result[json.RawMessage], error)

EditCaption can be used to edit captions of messages. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned.

func (*MessageEditor) EditMediaAnimation

func (mg *MessageEditor) EditMediaAnimation(messageId int, caption, parseMode string, width, height, duration int, captionEntitie []objs.MessageEntity, keyboard *InlineKeyboard) *AnimationEditor

EditMediaAnimation returns an AnimationEditor to edit an animation

func (*MessageEditor) EditMediaAudio

func (mg *MessageEditor) EditMediaAudio(messageId int, caption, parseMode, performer, title string, duration int, captionEntitie []objs.MessageEntity, keyboard *InlineKeyboard) *AudioEditor

EditMediaAudio returns an AudioEditor to edit an audio

func (*MessageEditor) EditMediaDocument

func (mg *MessageEditor) EditMediaDocument(messageId int, caption, parseMode string, disableContentTypeDetection bool, captionEntitie []objs.MessageEntity, keyboard *InlineKeyboard) *DocumentEditor

EditMediaDocument returns a DocumentEditor to edit a document

func (*MessageEditor) EditMediaPhoto

func (mg *MessageEditor) EditMediaPhoto(messageId int, caption, parseMode string, captionEntitie []objs.MessageEntity, keyboard *InlineKeyboard) *PhotoEditor

EditMediaPhoto returns a PhotoEditor to edit a photo

func (*MessageEditor) EditMediaVideo

func (mg *MessageEditor) EditMediaVideo(messageId int, caption, parseMode string, width, height, duration int, supportsStreaming bool, captionEntitie []objs.MessageEntity, keyboard *InlineKeyboard) *VideoEditor

EditMediaVideo returns a VideoEditor to edit a video

func (*MessageEditor) EditReplyMarkup

func (me *MessageEditor) EditReplyMarkup(messageId int, inlineMessageId string, keyboard *InlineKeyboard) (*objs.Result[json.RawMessage], error)

EditReplyMarkup can be used to edit only the reply markup of messages. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned.

func (*MessageEditor) EditText

func (me *MessageEditor) EditText(messageId int, text, inlineMessageId, parseMode string, entities []objs.MessageEntity, disableWebPagePreview bool, keyboard *InlineKeyboard) (*objs.Result[json.RawMessage], error)

EditText can be used to edit text and game messages. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned.

type MessageForwarder

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

MessageForwarder is a tool for forwarding messages.

func (*MessageForwarder) ForwardFromChannelToChannel

func (mf *MessageForwarder) ForwardFromChannelToChannel(chatId, fromChatId string) (*objs.Result[*objs.Message], error)

ForwardFromChannelToChannel forwards the given message from a channel to another channel. chatId is the channel that message is being forwarded to and fromChatId is the channel that message is being forwarded to.

func (*MessageForwarder) ForwardFromChannelToUser

func (mf *MessageForwarder) ForwardFromChannelToUser(chatId int, fromChatId string) (*objs.Result[*objs.Message], error)

ForwardFromChannelToUser forwards the given message from a channel to a user. chatId is the user that message is being forwarded to and fromChatId is the channel that message is being forwarded to.

func (*MessageForwarder) ForwardFromUserToChannel

func (mf *MessageForwarder) ForwardFromUserToChannel(chatId string, fromChatId int) (*objs.Result[*objs.Message], error)

ForwardFromUserToChannel forwards the given message from a user to a channel. chatId is the channel that message is being forwarded to and fromChatId is the user that message is being forwarded to.

func (*MessageForwarder) ForwardFromUserToUser

func (mf *MessageForwarder) ForwardFromUserToUser(chatId, fromChatId int) (*objs.Result[*objs.Message], error)

ForwardFromUserToUser forwards the given message from a user to another user. chatId is the user that message is being forwarded to and fromChatId is the user that message is being forwarded to.

type PhotoEditor

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

PhotoEditor is a tool for editing photos.

func (*PhotoEditor) EditByFile

func (pi *PhotoEditor) EditByFile(file *os.File) (*objs.Result[json.RawMessage], error)

EditByFile edits this photo with an existing file in the device

func (*PhotoEditor) EditByFileIdOrURL

func (pi *PhotoEditor) EditByFileIdOrURL(fileIdOrUrl string) (*objs.Result[json.RawMessage], error)

EditByFileIdOrURL edits this photo by file id or url

type PhotoInserter

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

PhotoInserter is a tool for inserting photos into the MediaGroup.

func (*PhotoInserter) AddByFile

func (pi *PhotoInserter) AddByFile(file *os.File) error

AddByFile adds an existing file in the device

func (*PhotoInserter) AddByFileIdOrURL

func (pi *PhotoInserter) AddByFileIdOrURL(fileIdOrUrl string)

AddByFileIdOrURL adds this file by file id or url

type Poll

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

Poll is an automatic poll.

func (*Poll) AddOption

func (p *Poll) AddOption(option string)

AddOption adds an option to poll.

-If the poll has been sent this method will do nothing.

func (*Poll) GetCorrectOption

func (p *Poll) GetCorrectOption() int

GetCorrectOption returns the correct option id. returnes 0 if type of the poll is "regular"

func (*Poll) GetExplanation

func (p *Poll) GetExplanation() string

GetExplanation returns the explanation of this poll

func (*Poll) GetId

func (p *Poll) GetId() string

GetId returns the id of this poll

func (*Poll) GetOptions

func (p *Poll) GetOptions() []string

GetOptions returns the options of this poll

func (*Poll) GetQuestion

func (p *Poll) GetQuestion() string

GetQuestion returns the question of this poll

func (*Poll) GetResult

func (p *Poll) GetResult() []objs.PollOption

GetResult returns the up to date result of the poll

func (*Poll) GetTotalVoters

func (p *Poll) GetTotalVoters() int

GetTotalVoters returns the up to date total number of voters for this poll

func (*Poll) GetType

func (p *Poll) GetType() string

GetType returns the poll type. Its either "regular" or "quiz".

func (*Poll) GetUpdateChannel

func (p *Poll) GetUpdateChannel() *chan bool

GetUpdateChannel returns the update channel for this poll. Everytime an update is received which contains update for this poll, true is passed into the channel.

func (*Poll) Send

func (p *Poll) Send(silent, protectContent bool, replyTo int) error

Send sends the poll. If you want more options foe sending the bot, use "SendAdvanced" method.

If "silent" argument is true, the message will be sent without notification.

If "protectContent" argument is true, the message can't be forwarded or saved.

func (*Poll) SendAdvanced

func (p *Poll) SendAdvanced(replyTo, messageThreadId int, silent, allowSendingWithOutReply, protectContent bool, replyMarkup objs.ReplyMarkup) error

SendAdvanced sends the poll. This method has more options than "Send" method.

If "silent" argument is true, the message will be sent without notification.

If "protectContent" argument is true, the message can't be forwarded or saved.

func (*Poll) SetCloseDate

func (p *Poll) SetCloseDate(cd int)

SetCloseDate sets the close date of this poll.

-If open period has been specified, this method wont set close date for the poll.

-If the poll has been sent this method will do nothing.

func (*Poll) SetCorrectOption

func (p *Poll) SetCorrectOption(co int)

SetCorrectOption sets the correct option id for the poll. The correct option is the index of the the true option in the options array.(0 based)

-If the type of this bot is "regular" this method will do nothing.

-If the poll has been sent this method will do nothing.

func (*Poll) SetExplanation

func (p *Poll) SetExplanation(explanation, explanationParseMode string, explanationEntities []objs.MessageEntity)

SetExplanation sets explanation if this poll.

If the poll has been sent this method will do nothing.

func (*Poll) SetFlags

func (p *Poll) SetFlags(isClosed, isAnonymous, allowMA bool)

SetFlags sets the flags of this poll. Flags are "isClosed","isAnonymous" and "allowMultipleAnswers".

-If the poll has been sent this method will do nothing.

func (*Poll) SetOpenPeriod

func (p *Poll) SetOpenPeriod(op int)

SetOpenPeriod sets open period of this poll. According to official telegram doc, open period is amount of time in seconds the poll will be active after creation, 5-600. Can't be used together with close_date.

-If close date has been specified, this method wont set open period.

-If the poll has been sent this method will do nothing.

func (*Poll) Stop

func (p *Poll) Stop() error

Stop stops the poll

func (*Poll) Update

func (p *Poll) Update(poll *objs.Poll) error

Update takes an poll object and extracts the poll update from it.

May return error if the update does not contain any poll or the poll in the update is not this poll

type StickerEditor added in v2.1.0

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

func (*StickerEditor) Delete added in v2.1.0

func (se *StickerEditor) Delete() (*objs.Result[bool], error)

Delete deletes this sticker from the set it belongs to.

func (*StickerEditor) SetEmojiList added in v2.1.0

func (se *StickerEditor) SetEmojiList(emojiList []string) (*objs.Result[bool], error)

SetEmojiList sets a new emoji list for this sticker.

func (*StickerEditor) SetKeywords added in v2.1.0

func (se *StickerEditor) SetKeywords(keywords []string) (*objs.Result[bool], error)

SetKeyword sets a new keyword list for this sticker. Maximum length is 20.

func (*StickerEditor) SetMaskPosition added in v2.1.0

func (se *StickerEditor) SetMaskPosition(maskPosition *objs.MaskPosition) (*objs.Result[bool], error)

SetMaskPosition sets a new mask position for this sticker.

type StickerSet

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

StickerSet is a set of stickers.

func (*StickerSet) AddAnimatedSticker deprecated

func (ss *StickerSet) AddAnimatedSticker(tgsFile *os.File, emojies string, maskPosition *objs.MaskPosition) (*objs.Result[bool], error)

Deprecated: This function should no longer be used for adding stickers to a sticker set. Use "AddNewSticker" method instead.

func (*StickerSet) AddNewSticker

func (ss *StickerSet) AddNewSticker(fileIdOrURL string, userId int, emojiList, keywords []string, maskPosition *objs.MaskPosition) (bool, error)

AddNewSticker adds a new sticker to this set. If the set has been created before then the sticker will be added to sticker set on telegram servers.

If not created yet, then the sticker is added to an internal array. The "Create" function should be called after all stickers have been added.

userId is the user id of the owner.

func (*StickerSet) AddNewStickerByFile

func (ss *StickerSet) AddNewStickerByFile(file *os.File, userId int, emojiList, keywords []string, maskPosition *objs.MaskPosition) (bool, error)

AddNewStickerByFile adds a new sticker to this set. If the set has been created before then the sticker will be added to sticker set on telegram servers.

If not created yet, then the sticker is added to an internal array. The "Create" function should be called after all stickers have been added.

userId is the user id of the owner.

func (*StickerSet) AddPngSticker deprecated

func (ss *StickerSet) AddPngSticker(pngPicFileIdOrUrl, emojies string, maskPosition *objs.MaskPosition) (*objs.Result[bool], error)

Deprecated: This function should no longer be used for adding stickers to a sticker set. Use "AddNewSticker" method instead.

func (*StickerSet) AddPngStickerByFile deprecated

func (ss *StickerSet) AddPngStickerByFile(pngPicFile *os.File, emojies string, maskPosition *objs.MaskPosition) (*objs.Result[bool], error)

Deprecated: This function should no longer be used for adding stickers to a sticker set. Use "AddNewSticker" method instead.

func (*StickerSet) AddSticker deprecated

func (ss *StickerSet) AddSticker(pngStickerFileIdOrUrl string, pngStickerFile *os.File, tgsSticker *os.File, emojies string, maskPosition *objs.MaskPosition) (*objs.Result[bool], error)

Deprecated: This function should no longer be used for adding stickers to a sticker set. Use "AddNewSticker" method instead.

func (*StickerSet) AddVideoSticker deprecated

func (ss *StickerSet) AddVideoSticker(webmFile *os.File, emojies string, maskPosition *objs.MaskPosition) (*objs.Result[bool], error)

Deprecated: This function should no longer be used for adding stickers to a sticker set. Use "AddNewSticker" method instead.

func (*StickerSet) Create

func (ss *StickerSet) Create() (bool, error)

Create is used for creating this sticker set if it has not been created before.

func (*StickerSet) Delete

func (ss *StickerSet) Delete() (*objs.Result[bool], error)

Delete deletes a sticker set that was created by this bot.

func (*StickerSet) DeleteStickerFromSet

func (ss *StickerSet) DeleteStickerFromSet(sticker string) (*objs.Result[bool], error)

DeleteStickerFromSet can be used to delete a sticker from a set created by the bot. Returns True on success.

"sticker" is file identifier of the sticker.

func (*StickerSet) GetName

func (ss *StickerSet) GetName() string

GetName returnes the name of this sticker set

func (*StickerSet) GetStickers

func (ss *StickerSet) GetStickers() []objs.Sticker

GetStickers returns the sticker in this sticker set.

func (*StickerSet) GetThumb

func (ss *StickerSet) GetThumb() *objs.PhotoSize

GetThumb returns the thumbnail of this sticker set

func (*StickerSet) GetTitle

func (ss *StickerSet) GetTitle() string

GetTitle returns the title of this sticker set

func (*StickerSet) SetStickerPosition

func (ss *StickerSet) SetStickerPosition(sticker string, position int) (*objs.Result[bool], error)

SetStickerPosition can be used to move a sticker in a set created by the bot to a specific position. Returns True on success.

"sticker" is file identifier of the sticker and "position" is new sticker position in the set, zero-based

func (*StickerSet) SetThumb

func (ss *StickerSet) SetThumb(userId int, thumb string) (*objs.Result[bool], error)

SetThumb can be used to set the thumbnail of a sticker set using url or file id. Animated thumbnails can be set for animated sticker sets only. Returns True on success.

func (*StickerSet) SetThumbByFile

func (ss *StickerSet) SetThumbByFile(userId int, thumb *os.File) (*objs.Result[bool], error)

SetThumbByFile can be used to set the thumbnail of a sticker set using a file on the computer. Animated thumbnails can be set for animated sticker sets only. Returns True on success.

func (*StickerSet) SetTitle

func (ss *StickerSet) SetTitle(title string) (*objs.Result[bool], error)

SetTitle changes this sticker set's title.

type TextFormatter

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

TextFormatter is tool for creating formatted texts.

func (*TextFormatter) AddBold

func (mf *TextFormatter) AddBold(text string)

AddBold adds a bold text to the original text.

func (*TextFormatter) AddBotCommand

func (mf *TextFormatter) AddBotCommand(text string)

AddBotCommand adds a bot command to the original text. example : /start@jobs_bot

func (*TextFormatter) AddCashtag

func (mf *TextFormatter) AddCashtag(text string)

AddCashtag adds a cashtag to the original text. exzmple : $USD

func (*TextFormatter) AddCode

func (mf *TextFormatter) AddCode(text, language string)

AddCode adds a piece of code (programming code) to the original text.

func (*TextFormatter) AddEmail

func (mf *TextFormatter) AddEmail(text string)

AddEmail adds an email to the original text. example : do-not-reply@telegram.org

func (*TextFormatter) AddHashtag

func (mf *TextFormatter) AddHashtag(text string)

AddHashtag adds a hashtag to the original text. example : #hashtag

func (*TextFormatter) AddItalic

func (mf *TextFormatter) AddItalic(text string)

AddItalic adds an italic text to the original text.

func (*TextFormatter) AddMention

func (mf *TextFormatter) AddMention(text string)

AddMention adds a mention to the original text. example : @username

func (*TextFormatter) AddNormal

func (mf *TextFormatter) AddNormal(text string)

AddNormal adds a normal text to the original text

func (*TextFormatter) AddPhoneNumber

func (mf *TextFormatter) AddPhoneNumber(text string)

AddPhoneNumber adds a phone number to the original text. example : +1-212-555-0123

func (*TextFormatter) AddSpoiler

func (mf *TextFormatter) AddSpoiler(text string)

AddSpoiler adds a spoiler text to the original text. This text is hidden until user clicks on it.

func (*TextFormatter) AddStrike

func (mf *TextFormatter) AddStrike(text string)

AddStrike adds a strikethrough text to the original text.

func (mf *TextFormatter) AddTextLink(text, url string)

AddTextLink adds a text link (clickable text which opens a URL) to the original text.

func (*TextFormatter) AddTextMention

func (mf *TextFormatter) AddTextMention(text string, user *objs.User)

AddTextMention adds a mention (for users without username) to the original text.

func (*TextFormatter) AddURL

func (mf *TextFormatter) AddURL(text string)

AddURL adds a url (not a clickable text url) to the original text. example : https://telegram.org

func (*TextFormatter) AddUnderline

func (mf *TextFormatter) AddUnderline(text string)

AddUnderline adds an underlined text to the original text.

func (*TextFormatter) GetEntities

func (mf *TextFormatter) GetEntities() []objs.MessageEntity

GetEntities returnss the entities array

func (*TextFormatter) GetText

func (mf *TextFormatter) GetText() string

GetText returns the original text

type VideoEditor

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

VideoEditor is a tool for editing videos.

func (*VideoEditor) EditByFile

func (vi *VideoEditor) EditByFile(file *os.File) (*objs.Result[json.RawMessage], error)

EditByFile edits this video by file in the device

func (*VideoEditor) EditByFileIdOrURL

func (vi *VideoEditor) EditByFileIdOrURL(fileIdOrUrl string) (*objs.Result[json.RawMessage], error)

EditByFileIdOrURL edits this video by file id or url

func (*VideoEditor) EditThumbnail

func (vi *VideoEditor) EditThumbnail(fileIdOrURL string)

EditThumbnail edits the tumbnail of the file. It takes a fileId or a url. If you want to send a file use "setThumbnailFile" instead.

func (*VideoEditor) EditThumbnailFile

func (vi *VideoEditor) EditThumbnailFile(file *os.File) error

EditThumbnailFile edits the thumbnail of the file. It takes a file existing on the device

type VideoInserter

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

VideoInserter is a tool for inserting videos into the MediaGroup.

func (*VideoInserter) AddByFile

func (vi *VideoInserter) AddByFile(file *os.File) error

AddByFile adds an existing file in the device

func (*VideoInserter) AddByFileIdOrURL

func (vi *VideoInserter) AddByFileIdOrURL(fileIdOrUrl string)

AddByFileIdOrURL adds this file by file id or url

func (*VideoInserter) SetThumbnail

func (vi *VideoInserter) SetThumbnail(fileIdOrURL string)

SetThumbnail sets the tumbnail of the file. It takes a fileId or a url. If you want to send a file use "setThumbnailFile" instead.

func (*VideoInserter) SetThumbnailFile

func (vi *VideoInserter) SetThumbnailFile(file *os.File) error

SetThumbnailFile sets the tumbnail of the file. It takes a file existing on the device

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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