telegram

package module
v0.0.0-...-b7abf87 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2017 License: MIT Imports: 13 Imported by: 5

README

Telegram Bot Api GoDoc Build Status Coverage Status Go Report Card

Supported go version: 1.5, 1.6, tip

Implementation of the telegram bot API, inspired by github.com/go-telegram-bot-api/telegram-bot-api.

The main difference between telegram-bot-api and this version is supporting net/context. Also, this library handles errors more correctly at this time (telegram-bot-api v4).

Package contains:

  1. Client for telegram bot api.
  2. Bot with:
    1. Middleware support
      1. Command middleware to handle commands.
      2. Recover middleware to recover on panics.
    2. Webhook support

Get started

Get last telegram api:

go get github.com/bot-api/telegram

If you want to use telegram bot api directly:

go run ./examples/api/main.go -debug -token BOT_TOKEN

package main

import (
	"log"
	"flag"

	"github.com/bot-api/telegram"
	"golang.org/x/net/context"
)


func main() {
	token := flag.String("token", "", "telegram bot token")
	debug := flag.Bool("debug", false, "show debug information")
	flag.Parse()

	if *token == "" {
		log.Fatal("token flag required")
	}

	api := telegram.New(*token)
	api.Debug(*debug)

	ctx, cancel := context.WithCancel(context.Background())
	defer cancel()

	if user, err := api.GetMe(ctx); err != nil {
		log.Panic(err)
	} else {
		log.Printf("bot info: %#v", user)
	}

	updatesCh := make(chan telegram.Update)

	go telegram.GetUpdates(ctx, api, telegram.UpdateCfg{
		Timeout: 10, 	// Timeout in seconds for long polling.
		Offset: 0, 	// Start with the oldest update
	}, updatesCh)

	for update := range updatesCh {
		log.Printf("got update from %s", update.Message.From.Username)
		if update.Message == nil {
			continue
		}
		msg := telegram.CloneMessage(update.Message, nil)
		// echo with the same message
		if _, err := api.Send(ctx, msg); err != nil {
			log.Printf("send error: %v", err)
		}
	}
}

If you want to use bot

go run ./examples/echo/main.go -debug -token BOT_TOKEN

package main
// Simple echo bot, that responses with the same message

import (
	"flag"
	"log"

	"github.com/bot-api/telegram"
	"github.com/bot-api/telegram/telebot"
	"golang.org/x/net/context"
)

func main() {
	token := flag.String("token", "", "telegram bot token")
	debug := flag.Bool("debug", false, "show debug information")
	flag.Parse()

	if *token == "" {
		log.Fatal("token flag is required")
	}

	api := telegram.New(*token)
	api.Debug(*debug)
	bot := telebot.NewWithAPI(api)
	bot.Use(telebot.Recover()) // recover if handler panic

	netCtx, cancel := context.WithCancel(context.Background())
	defer cancel()

	bot.HandleFunc(func(ctx context.Context) error {
		update := telebot.GetUpdate(ctx) // take update from context
		if update.Message == nil {
			return nil
		}
		api := telebot.GetAPI(ctx) // take api from context
		msg := telegram.CloneMessage(update.Message, nil)
		_, err := api.Send(ctx, msg)
		return err

	})

	// Use command middleware, that helps to work with commands
	bot.Use(telebot.Commands(map[string]telebot.Commander{
		"start": telebot.CommandFunc(
			func(ctx context.Context, arg string) error {

				api := telebot.GetAPI(ctx)
				update := telebot.GetUpdate(ctx)
				_, err := api.SendMessage(ctx,
					telegram.NewMessagef(update.Chat().ID,
						"received start with arg %s", arg,
					))
				return err
			}),
	}))


	err := bot.Serve(netCtx)
	if err != nil {
		log.Fatal(err)
	}
}

Use callback query and edit bot's message

go run ./examples/callback/main.go -debug -token BOT_TOKEN


bot.HandleFunc(func(ctx context.Context) error {
    update := telebot.GetUpdate(ctx) // take update from context
    api := telebot.GetAPI(ctx) // take api from context

    if update.CallbackQuery != nil {
        data := update.CallbackQuery.Data
        if strings.HasPrefix(data, "sex:") {
            cfg := telegram.NewEditMessageText(
                update.Chat().ID,
                update.CallbackQuery.Message.MessageID,
                fmt.Sprintf("You sex: %s", data[4:]),
            )
            api.AnswerCallbackQuery(
                ctx,
                telegram.NewAnswerCallback(
                    update.CallbackQuery.ID,
                    "Your configs changed",
                ),
            )
            _, err := api.EditMessageText(ctx, cfg)
            return err
        }
    }

    msg := telegram.NewMessage(update.Chat().ID,
        "Your sex:")
    msg.ReplyMarkup = telegram.InlineKeyboardMarkup{
        InlineKeyboard: telegram.NewVInlineKeyboard(
            "sex:",
            []string{"Female", "Male",},
            []string{"female", "male",},
        ),
    }
    _, err := api.SendMessage(ctx, msg)
    return err

})


Take a look at ./examples/ to know more how to use bot and telegram api.

TODO:

  • Handlers

  • Middleware

  • Command middleware

  • Session middleware

  • Log middleware

  • Menu middleware

  • Examples

    • Command
    • CallbackAnswer
    • Inline
    • Proxy
    • Menu
  • Add travis-ci integration

  • Add coverage badge

  • Add integration tests

  • Add gopkg version

  • Improve documentation

  • Benchmark ffjson and easyjson.

  • Add GAE example.

Supported API methods:

  • getMe
  • sendMessage
  • forwardMessage
  • sendPhoto
  • sendAudio
  • sendDocument
  • sendSticker
  • sendVideo
  • sendVoice
  • sendLocation
  • sendChatAction
  • getUserProfilePhotos
  • getUpdates
  • setWebhook
  • getFile
  • answerInlineQuery inline bots

Supported API v2 methods:

  • sendVenue
  • sendContact
  • editMessageText
  • editMessageCaption
  • editMessageReplyMarkup
  • kickChatMember
  • unbanChatMember
  • answerCallbackQuery
  • getChat
  • getChatMember
  • getChatMembersCount
  • getChatAdministrators
  • leaveChat

Supported Inline modes

  • InlineQueryResultArticle
  • InlineQueryResultAudio
  • InlineQueryResultContact
  • InlineQueryResultDocument
  • InlineQueryResultGif
  • InlineQueryResultLocation
  • InlineQueryResultMpeg4Gif
  • InlineQueryResultPhoto
  • InlineQueryResultVenue
  • InlineQueryResultVideo
  • InlineQueryResultVoice
  • InlineQueryResultCachedAudio
  • InlineQueryResultCachedDocument
  • InlineQueryResultCachedGif
  • InlineQueryResultCachedMpeg4Gif
  • InlineQueryResultCachedPhoto
  • InlineQueryResultCachedSticker
  • InlineQueryResultCachedVideo
  • InlineQueryResultCachedVoice
  • InputTextMessageContent
  • InputLocationMessageContent

Other bots: I like this handler system https://bitbucket.org/master_groosha/telegram-proxy-bot/src/07a6b57372603acae7bdb78f771be132d063b899/proxy_bot.py?fileviewer=file-view-default

Documentation

Index

Constants

View Source
const (
	// APIEndpoint is the endpoint for all API methods,
	// with formatting for Sprintf.
	APIEndpoint = "https://api.telegram.org/bot%s/%s"
	// FileEndpoint is the endpoint for downloading a file from Telegram.
	FileEndpoint = "https://api.telegram.org/file/bot%s/%s"
)
View Source
const (
	PrivateChatType    = "private"
	GroupChatType      = "group"
	SuperGroupChatType = "supergroup"
	ChannelChatType    = "channel"
)

Type of chat

View Source
const (
	ActionTyping         = "typing"
	ActionUploadPhoto    = "upload_photo"
	ActionRecordVideo    = "record_video"
	ActionUploadVideo    = "upload_video"
	ActionRecordAudio    = "record_audio"
	ActionUploadAudio    = "upload_audio"
	ActionUploadDocument = "upload_document"
	ActionFindLocation   = "find_location"
)

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_audio or upload_audio for audio files
upload_document for general files
find_location for location data
View Source
const (
	MarkdownMode = "Markdown"
	HTMLMode     = "HTML"
)

Constant values for ParseMode in MessageCfg.

View Source
const (
	// @username
	MentionEntityType     = "mention"
	HashTagEntityType     = "hashtag"
	BotCommandEntityType  = "bot_command"
	URLEntityType         = "url"
	EmailEntityType       = "email"
	BoldEntityType        = "bold"         // bold text
	ItalicEntityType      = "italic"       // italic text
	CodeEntityType        = "code"         // monowidth string
	PreEntityType         = "pre"          // monowidth block
	TextLinkEntityType    = "text_link"    // for clickable text URLs
	TextMentionEntityType = "text_mention" // for users without usernames
)

EntityType constants helps to set type of entity in MessageEntity object

View Source
const (
	MemberStatus              = "member"
	CreatorMemberStatus       = "creator"
	AdministratorMemberStatus = "administrator"
	LeftMemberStatus          = "left"
	KickedMemberStatus        = "kicked"
)

ChatMember possible statuses

Variables

View Source
var DefaultDebugFunc = func(msg string, fields map[string]interface{}) {
	log.Printf("%s %v", msg, fields)
}

DefaultDebugFunc prints debug message to default logger

Functions

func GetUpdates

func GetUpdates(
	ctx context.Context,
	api *API,
	cfg UpdateCfg,
	out chan<- Update) error

GetUpdates runs loop and requests updates from telegram. It breaks loop, close out channel and returns error if something happened during update cycle.

func IsAPIError

func IsAPIError(err error) bool

IsAPIError checks if error is ApiError

func IsForbiddenError

func IsForbiddenError(err error) bool

IsForbiddenError checks if error is forbidden

func IsRequiredError

func IsRequiredError(err error) bool

IsRequiredError checks if error is RequiredError

func IsUnauthorizedError

func IsUnauthorizedError(err error) bool

IsUnauthorizedError checks if error is unauthorized

func IsValidToken

func IsValidToken(token string) bool

IsValidToken returns true if token is a valid telegram bot token

Token format is like: 110201543:AAHdqTcvCH1vGWJxfSeofSAs0K5PALDsawq

func IsValidationError

func IsValidationError(err error) bool

IsValidationError checks if error is ValidationError

func NewHInlineKeyboard

func NewHInlineKeyboard(prefix string, text []string, data []string) [][]InlineKeyboardButton

NewHInlineKeyboard creates inline keyboard with horizontal buttons only. [ first ] [ second ] [ third ]

func NewHKeyboard

func NewHKeyboard(buttons ...string) [][]KeyboardButton

NewHKeyboard creates keyboard with horizontal buttons only. [ first ] [ second ] [ third ]

func NewKeyboard

func NewKeyboard(buttons [][]string) [][]KeyboardButton

NewKeyboard creates keyboard by matrix i*j.

func NewVInlineKeyboard

func NewVInlineKeyboard(prefix string, text []string, data []string) [][]InlineKeyboardButton

NewVInlineKeyboard creates inline keyboard with vertical buttons only [ first ] [ second ] [ third ]

func NewVKeyboard

func NewVKeyboard(buttons ...string) [][]KeyboardButton

NewVKeyboard creates keyboard with vertical buttons only [ first ] [ second ] [ third ]

Types

type API

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

API implements Telegram bot API described on https://core.telegram.org/bots/api

func New

func New(token string) *API

New returns API instance with default http client

func NewWithClient

func NewWithClient(token string, client HTTPDoer) *API

NewWithClient returns API instance with custom http client

func (*API) AnswerCallbackQuery

func (c *API) AnswerCallbackQuery(
	ctx context.Context,
	cfg AnswerCallbackCfg) (bool, error)

AnswerCallbackQuery sends a response to an inline query callback.

func (*API) AnswerInlineQuery

func (c *API) AnswerInlineQuery(ctx context.Context, cfg AnswerInlineQueryCfg) (bool, error)

AnswerInlineQuery sends answers to an inline query. On success, True is returned. No more than 50 results per query are allowed.

func (*API) Debug

func (c *API) Debug(val bool)

Debug enables sending debug messages to default log

func (*API) DebugFunc

func (c *API) DebugFunc(f DebugFunc)

DebugFunc replaces default debug function

func (*API) DownloadFile

func (c *API) DownloadFile(ctx context.Context, cfg FileCfg, w io.Writer) error

DownloadFile downloads file from telegram servers to w

Requires FileID

func (*API) Edit

func (c *API) Edit(ctx context.Context, cfg Method) (*EditResult, error)

Edit method allows you to change an existing message in the message history instead of sending a new one with a result of an action. This is most useful for messages with inline keyboards using callback queries, but can also help reduce clutter in conversations with regular chat bots. Please note, that it is currently only possible to edit messages without reply_markup or with inline keyboards.

You can use this method directly or one of: EditMessageText, EditMessageCaption, EditMessageReplyMarkup,

func (*API) EditMessageCaption

func (c *API) EditMessageCaption(
	ctx context.Context,
	cfg EditMessageCaptionCfg) (*EditResult, error)

EditMessageCaption modifies the caption of message. Use this method to edit only the caption of messages sent by the bot or via the bot (for inline bots). On success, if edited message is sent by the bot, the edited Message is returned, otherwise True is returned.

func (*API) EditMessageReplyMarkup

func (c *API) EditMessageReplyMarkup(
	ctx context.Context,
	cfg EditMessageReplyMarkupCfg) (*EditResult, error)

EditMessageReplyMarkup modifies the reply markup of message. Use this method to edit only the reply markup of messages sent by the bot or via the bot (for inline bots). On success, if edited message is sent by the bot, the edited Message is returned, otherwise True is returned.

func (*API) EditMessageText

func (c *API) EditMessageText(
	ctx context.Context,
	cfg EditMessageTextCfg) (*EditResult, error)

EditMessageText modifies the text of message. Use this method to edit only the text of messages sent by the bot or via the bot (for inline bots). On success, if edited message is sent by the bot, the edited Message is returned, otherwise True is returned.

func (*API) ForwardMessage

func (c *API) ForwardMessage(
	ctx context.Context,
	cfg ForwardMessageCfg) (*Message, error)

ForwardMessage forwards messages of any kind.

func (*API) GetChat

func (c *API) GetChat(ctx context.Context, cfg GetChatCfg) (*Chat, error)

GetChat returns 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 (*API) GetChatAdministrators

func (c *API) GetChatAdministrators(
	ctx context.Context,
	cfg GetChatAdministratorsCfg) ([]ChatMember, error)

GetChatAdministrators returns 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 (*API) GetChatMember

func (c *API) GetChatMember(
	ctx context.Context,
	cfg GetChatMemberCfg) (*ChatMember, error)

GetChatMember returns information about a member of a chat.

func (*API) GetChatMembersCount

func (c *API) GetChatMembersCount(
	ctx context.Context,
	cfg GetChatMembersCountCfg) (int, error)

GetChatMembersCount returns the number of members in a chat.

func (*API) GetFile

func (c *API) GetFile(ctx context.Context, cfg FileCfg) (*File, error)

GetFile returns a File which can download a file from Telegram.

Requires FileID.

func (*API) GetMe

func (c *API) GetMe(ctx context.Context) (*User, error)

GetMe returns basic information about the bot in form of a User object

func (*API) GetUpdates

func (c *API) GetUpdates(
	ctx context.Context,
	cfg UpdateCfg) ([]Update, error)

GetUpdates requests incoming updates using long polling. This method will not work if an outgoing webhook is set up. In order to avoid getting duplicate updates, recalculate offset after each server response.

func (*API) GetUserProfilePhotos

func (c *API) GetUserProfilePhotos(
	ctx context.Context,
	cfg UserProfilePhotosCfg) (*UserProfilePhotos, error)

GetUserProfilePhotos requests a list of profile pictures for a user.

func (*API) Invoke

func (c *API) Invoke(ctx context.Context, m Method, dst interface{}) error

Invoke is a generic method that helps to make request to Telegram Api. Use particular methods instead (e.x. GetMe, GetUpdates etc). The only case when this method seems useful is when Telegram Api has method that still doesn't exist in this implementation.

func (*API) KickChatMember

func (c *API) KickChatMember(
	ctx context.Context,
	cfg KickChatMemberCfg) (bool, error)

KickChatMember kicks a user from a group or a supergroup. In the case of supergroups, the user will not be able to return to the group on their own using invite links, etc., unless unbanned first. The bot must be an administrator in the group for this to work. Returns True on success.

func (*API) LeaveChat

func (c *API) LeaveChat(
	ctx context.Context,
	cfg LeaveChatCfg) (bool, error)

LeaveChat method helps your bot to leave a group, supergroup or channel. Returns True on success.

func (*API) Send

func (c *API) Send(ctx context.Context, cfg Messenger) (*Message, error)

Send method sends message.

TODO m0sth8: rewrite this doc

func (*API) SendAudio

func (c *API) SendAudio(
	ctx context.Context,
	cfg AudioCfg) (*Message, error)

SendAudio sends Audio.

func (*API) SendChatAction

func (c *API) SendChatAction(ctx context.Context, cfg ChatActionCfg) error

SendChatAction tells 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).

func (*API) SendContact

func (c *API) SendContact(
	ctx context.Context,
	cfg ContactCfg) (*Message, error)

SendContact sends phone contact message.

func (*API) SendDocument

func (c *API) SendDocument(
	ctx context.Context,
	cfg DocumentCfg) (*Message, error)

SendDocument sends Document.

func (*API) SendMessage

func (c *API) SendMessage(
	ctx context.Context,
	cfg MessageCfg) (*Message, error)

SendMessage sends text message.

func (*API) SendPhoto

func (c *API) SendPhoto(
	ctx context.Context,
	cfg PhotoCfg) (*Message, error)

SendPhoto sends photo.

func (*API) SendSticker

func (c *API) SendSticker(
	ctx context.Context,
	cfg StickerCfg) (*Message, error)

SendSticker sends message with sticker.

func (*API) SendVenue

func (c *API) SendVenue(
	ctx context.Context,
	cfg VenueCfg) (*Message, error)

SendVenue sends venue message.

func (*API) SendVideo

func (c *API) SendVideo(
	ctx context.Context,
	cfg VideoCfg) (*Message, error)

SendVideo sends Video.

func (*API) SendVoice

func (c *API) SendVoice(
	ctx context.Context,
	cfg VoiceCfg) (*Message, error)

SendVoice sends Voice.

func (*API) SetWebhook

func (c *API) SetWebhook(ctx context.Context, cfg WebhookCfg) error

SetWebhook sets a webhook. Use this method to specify a url and receive incoming updates via an outgoing webhook. Whenever there is an update for the bot, we will send an HTTPS POST request to the specified url, containing a JSON‐serialized Update. In case of an unsuccessful request, we will give up after a reasonable amount of attempts.

If this is set, GetUpdates will not get any data!

If you do not have a legitimate TLS certificate, you need to include your self signed certificate with the config.

func (*API) UnbanChatMember

func (c *API) UnbanChatMember(
	ctx context.Context,
	cfg UnbanChatMemberCfg) (bool, error)

UnbanChatMember unbans a previously kicked user in a supergroup. The user will not return to the group automatically, but will be able to join via link, etc. The bot must be an administrator in the group for this to work. Returns True on success.

type APIError

type APIError struct {
	Description string `json:"description"`
	// ErrorCode contents are subject to change in the future.
	ErrorCode int `json:"error_code"`
}

APIError contains error information from response

func (*APIError) Error

func (e *APIError) Error() string

Error returns string representation for ApiError

type APIResponse

type APIResponse struct {
	Ok          bool             `json:"ok"`
	Result      *json.RawMessage `json:"result"`
	ErrorCode   int              `json:"error_code,omitempty"`
	Description string           `json:"description,omitempty"`
}

APIResponse is a response from the Telegram API with the result stored raw.

type AnswerCallbackCfg

type AnswerCallbackCfg struct {
	CallbackQueryID string `json:"callback_query_id"`
	Text            string `json:"text"`
	ShowAlert       bool   `json:"show_alert"`
}

AnswerCallbackCfg contains information on making a anserCallbackQuery response.

func NewAnswerCallback

func NewAnswerCallback(id, text string) AnswerCallbackCfg

NewAnswerCallback creates a new callback message.

func NewAnswerCallbackWithAlert

func NewAnswerCallbackWithAlert(id, text string) AnswerCallbackCfg

NewAnswerCallbackWithAlert creates a new callback message that alerts the user.

func (AnswerCallbackCfg) Name

func (cfg AnswerCallbackCfg) Name() string

Name returns method name

func (AnswerCallbackCfg) Values

func (cfg AnswerCallbackCfg) Values() (url.Values, error)

Values returns a url.Values representation of AnswerCallbackCfg. Returns a RequiredError if Action is empty.

type AnswerInlineQueryCfg

type AnswerInlineQueryCfg struct {
	// Unique identifier for the answered query
	InlineQueryID string              `json:"inline_query_id"`
	Results       []InlineQueryResult `json:"results"`
	// The maximum amount of time in seconds
	// that the result of the inline query may be cached on the server.
	// Defaults to 300.
	CacheTime int `json:"cache_time,omitempty"`
	// Pass True, if results may be cached on the server side
	// only for the user that sent the query.
	// By default, results may be returned to any user
	// who sends the same query
	IsPersonal bool `json:"is_personal,omitempty"`
	// Pass the offset that a client should send in the next query
	// with the same text to receive more results.
	// Pass an empty string if there are no more results
	// or if you don‘t support pagination.
	// Offset length can’t exceed 64 bytes.
	NextOffset string `json:"next_offset,omitempty"`
	// If passed, clients will display a button with specified text
	// that switches the user to a private chat with the bot and
	// sends the bot a start message with the parameter switch_pm_parameter
	SwitchPMText string `json:"switch_pm_text,omitempty"`
	// Parameter for the start message sent to the bot
	// when user presses the switch button
	SwitchPMParameter string `json:"switch_pm_parameter"`
}

AnswerInlineQueryCfg contains information on making an InlineQuery response.

func (AnswerInlineQueryCfg) Name

func (cfg AnswerInlineQueryCfg) Name() string

Name returns method name

func (AnswerInlineQueryCfg) Values

func (cfg AnswerInlineQueryCfg) Values() (url.Values, error)

Values returns a url.Values representation of AnswerInlineQueryCfg. Returns a RequiredError if Action is empty.

type Audio

type Audio struct {
	MetaFile

	// Duration of the recording in seconds as defined by sender.
	Duration int `json:"duration"`
	//  Performer of the audio as defined by sender
	// or by audio tags. Optional.
	Performer string `json:"performer,omitempty"`
	// Title of the audio as defined by sender
	// or by audio tags. Optional.
	Title string `json:"title,omitempty"`
	// MIMEType of the file as defined by sender. Optional.
	MIMEType string `json:"mime_type,omitempty"`
}

Audio object represents an audio file to be treated as music by the Telegram clients.

type AudioCfg

type AudioCfg struct {
	BaseFile
	Duration  int
	Performer string
	Title     string
}

AudioCfg contains information about a SendAudio request. Use it to send information about an audio Implements Filer and Messenger interfaces.

func (AudioCfg) Field

func (cfg AudioCfg) Field() string

Field returns name for audio file data

func (AudioCfg) Name

func (cfg AudioCfg) Name() string

Name returns method name

func (AudioCfg) Values

func (cfg AudioCfg) Values() (url.Values, error)

Values returns a url.Values representation of AudioCfg.

type BaseChat

type BaseChat struct {
	// Unique identifier for the target chat
	ID int64
	// Username of the target channel (in the format @channelusername)
	ChannelUsername string
}

BaseChat describes chat settings. It's an abstract type.

You must set ID or ChannelUsername.

func (*BaseChat) SetChatID

func (c *BaseChat) SetChatID(id int64)

SetChatID sets new chat id

func (BaseChat) Values

func (c BaseChat) Values() (url.Values, error)

Values returns RequiredError if neither ID or ChannelUsername are empty. Prefers ChannelUsername if both ID and ChannelUsername are not empty.

type BaseEdit

type BaseEdit struct {
	// Required if inline_message_id is not specified.
	// Unique identifier for the target chat or
	// username of the target channel (in the format @channelusername)
	ChatID          int64
	ChannelUsername string
	// Required if inline_message_id is not specified.
	// Unique identifier of the sent message
	MessageID int64
	// Required if chat_id and message_id are not specified.
	// Identifier of the inline message
	InlineMessageID string
	// Only InlineKeyboardMarkup supported right now.
	ReplyMarkup ReplyMarkup
}

BaseEdit is base type of all chat edits.

func (BaseEdit) Values

func (m BaseEdit) Values() (url.Values, error)

Values returns a url.Values representation of BaseEdit.

type BaseFile

type BaseFile struct {
	BaseMessage
	FileID    string
	MimeType  string
	InputFile InputFile
}

BaseFile describes file settings. It's an abstract type.

func (BaseFile) Exist

func (b BaseFile) Exist() bool

Exist returns true if file exists on telegram servers

func (BaseFile) File

func (b BaseFile) File() InputFile

File returns InputFile object that are used to create request

func (BaseFile) GetFileID

func (b BaseFile) GetFileID() string

GetFileID returns fileID if it's exist

func (*BaseFile) Reset

func (b *BaseFile) Reset(i InputFile)

Reset method removes FileID and sets new InputFile

func (BaseFile) Values

func (b BaseFile) Values() (url.Values, error)

Values returns a url.Values representation of BaseFile.

type BaseInlineQueryResult

type BaseInlineQueryResult struct {
	Type                string              `json:"type"` // required
	ID                  string              `json:"id"`   // required
	InputMessageContent InputMessageContent `json:"input_message_content,omitempty"`
	// ReplyMarkup supports only InlineKeyboardMarkup for InlineQueryResult
	ReplyMarkup ReplyMarkup `json:"reply_markup,omitempty"`
}

BaseInlineQueryResult is a base class for InlineQueryResult

type BaseMessage

type BaseMessage struct {
	BaseChat
	// If the message is a reply, ID of the original message
	ReplyToMessageID int64
	// Additional interface options.
	// A JSON-serialized object for a custom reply keyboard,
	// instructions to hide keyboard or to force a reply from the user.
	ReplyMarkup ReplyMarkup
	// Sends the message silently.
	// iOS users will not receive a notification,
	// Android users will receive a notification with no sound.
	// Other apps coming soon.
	DisableNotification bool
}

BaseMessage is a base type for all message config types. Implements Messenger interface.

func (BaseMessage) Message

func (BaseMessage) Message() *Message

Message returns instance of *Message type.

func (BaseMessage) Values

func (m BaseMessage) Values() (url.Values, error)

Values returns url.Values representation of BaseMessage

type CallbackQuery

type CallbackQuery struct {
	// Unique identifier for this query
	ID string `json:"id"`
	// Sender
	From *User `json:"from"`
	// Message with the callback button that originated the query.
	// Note that message content and message date
	// will not be available if the message is too old. Optional.
	Message *Message `json:"message,omitempty"`
	// Identifier of the message sent via the bot in inline mode,
	// that originated the query. Optional.
	InlineMessageID string `json:"inline_message_id,omitempty"`
	// Data associated with the callback button.
	// Be aware that a bad client can send arbitrary data in this field
	Data string `json:"data"`
}

CallbackQuery represents an incoming callback query from a callback button in an inline keyboard. If the button that originated the query was attached to a message sent by the bot, the field message will be presented. If the button was attached to a message sent via the bot (in inline mode), the field inline_message_id will be presented.

type Chat

type Chat struct {
	// ID is a Unique identifier for this chat, not exceeding 1e13 by absolute value.
	ID int64 `json:"id"`
	// Type of chat, can be either “private”, “group”, "supergroup" or “channel”
	Type string `json:"type"`

	Title     string `json:"title,omitempty"`
	FirstName string `json:"first_name,omitempty"`
	LastName  string `json:"last_name,omitempty"`
	Username  string `json:"username,omitempty"`
}

Chat object represents a Telegram user, bot or group chat. Title for channels and group chats

type ChatActionCfg

type ChatActionCfg struct {
	BaseChat
	// 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_audio or upload_audio for audio files,
	// upload_document for general files,
	// find_location for location data.
	// Use one of constants: ActionTyping, ActionFindLocation, etc
	Action string
}

ChatActionCfg contains information about a SendChatAction request. Action field is required.

func NewChatAction

func NewChatAction(chatID int64, action string) ChatActionCfg

NewChatAction sets a chat action. Actions last for 5 seconds, or until your next action.

chatID is where to send it, action should be set via Action constants.

func (ChatActionCfg) Name

func (cfg ChatActionCfg) Name() string

Name returns method name

func (ChatActionCfg) Values

func (cfg ChatActionCfg) Values() (url.Values, error)

Values returns a url.Values representation of ChatActionCfg. Returns a RequiredError if Action is empty.

type ChatMember

type ChatMember struct {
	// Information about the user.
	User User `json:"user"`
	// The member's status in the chat.
	// One of MemberStatus constants.
	Status string `json:"status"`
}

ChatMember object contains information about one member of the chat.

type ChosenInlineResult

type ChosenInlineResult struct {
	// ResultID is a unique identifier for the result that was chosen.
	ResultID string `json:"result_id"`
	// From is a user that chose the result.
	From User `json:"from"`
	// Query is used to obtain the result.
	Query string `json:"query"`
}

ChosenInlineResult represents a result of an inline query that was chosen by the user and sent to their chat partner

type Contact

type Contact struct {
	PhoneNumber string `json:"phone_number"`
	FirstName   string `json:"first_name"`

	// UserID is a contact's user identifier in Telegram. Optional.
	UserID   int64  `json:"user_id,omitempty"`
	LastName string `json:"last_name,omitempty"`
}

Contact object represents a phone contact of Telegram user

func (Contact) Values

func (c Contact) Values() url.Values

Values returns a url.Values representation of Contact object.

type ContactCfg

type ContactCfg struct {
	BaseMessage
	Contact
}

ContactCfg contains information about a SendContact request. Use it to send information about a venue Implements Messenger interface.

func (ContactCfg) Name

func (cfg ContactCfg) Name() string

Name returns method name

func (ContactCfg) Values

func (cfg ContactCfg) Values() (url.Values, error)

Values returns a url.Values representation of ContactCfg. Returns RequiredError if Text is empty.

type DebugFunc

type DebugFunc func(msg string, fields map[string]interface{})

DebugFunc describes function for debugging.

type Document

type Document struct {
	MetaFile

	// Document thumbnail as defined by sender. Optional.
	Thumb *PhotoSize `json:"thumb,omitempty"`

	// Original filename as defined by sender. Optional.
	FileName string `json:"file_name,omitempty"`

	// MIMEType of the file as defined by sender. Optional.
	MIMEType string `json:"mime_type,omitempty"`
}

Document object represents a general file (as opposed to Photo or Audio). Telegram users can send files of any type of up to 1.5 GB in size.

type DocumentCfg

type DocumentCfg struct {
	BaseFile
}

DocumentCfg contains information about a SendDocument request. Use it to send information about a documents Implements Filer and Messenger interfaces.

func (DocumentCfg) Field

func (cfg DocumentCfg) Field() string

Field returns name for document file data

func (DocumentCfg) Name

func (cfg DocumentCfg) Name() string

Name returns method name

func (DocumentCfg) Values

func (cfg DocumentCfg) Values() (url.Values, error)

Values returns a url.Values representation of DocumentCfg.

type EditMessageCaptionCfg

type EditMessageCaptionCfg struct {
	BaseEdit
	// New caption of the message
	Caption string
}

EditMessageCaptionCfg allows you to modify the caption of a message.

func NewEditMessageCaption

func NewEditMessageCaption(chatID, messageID int64, caption string) EditMessageCaptionCfg

NewEditMessageCaption allows you to edit the caption of a message.

func (EditMessageCaptionCfg) Name

Name returns method name

func (EditMessageCaptionCfg) Values

func (cfg EditMessageCaptionCfg) Values() (url.Values, error)

Values returns a url.Values representation of EditMessageCaptionCfg.

type EditMessageReplyMarkupCfg

type EditMessageReplyMarkupCfg struct {
	BaseEdit
}

EditMessageReplyMarkupCfg allows you to modify the reply markup of a message.

func NewEditMessageReplyMarkup

func NewEditMessageReplyMarkup(chatID, messageID int64, replyMarkup *InlineKeyboardMarkup) EditMessageReplyMarkupCfg

NewEditMessageReplyMarkup allows you to edit the inline keyboard markup.

func (EditMessageReplyMarkupCfg) Name

Name returns method name

func (EditMessageReplyMarkupCfg) Values

func (cfg EditMessageReplyMarkupCfg) Values() (url.Values, error)

Values returns a url.Values representation of EditMessageReplyMarkupCfg.

type EditMessageTextCfg

type EditMessageTextCfg struct {
	BaseEdit
	// New text of the message
	Text string
	// Send Markdown or HTML, if you want Telegram apps
	// to show bold, italic, fixed-width text
	// or inline URLs in your bot's message. Optional.
	ParseMode string
	// Disables link previews for links in this message. Optional.
	DisableWebPagePreview bool
}

EditMessageTextCfg allows you to modify the text in a message.

func NewEditMessageText

func NewEditMessageText(chatID, messageID int64, text string) EditMessageTextCfg

NewEditMessageText allows you to edit the text of a message.

func (EditMessageTextCfg) Name

func (EditMessageTextCfg) Name() string

Name returns method name

func (EditMessageTextCfg) Values

func (cfg EditMessageTextCfg) Values() (url.Values, error)

Values returns a url.Values representation of EditMessageTextCfg.

type EditResult

type EditResult struct {
	Message *Message
	Ok      bool
}

EditResult is an option type, because telegram may return bool or Message

func (*EditResult) UnmarshalJSON

func (e *EditResult) UnmarshalJSON(data []byte) error

UnmarshalJSON helps to parse EditResult. On success, if edited message is sent by the bot, the edited Message is returned, otherwise True is returned.

type File

type File struct {
	MetaFile
	// FilePath is a relative path to file.
	// Use https://api.telegram.org/file/bot<token>/<file_path>
	// to get the file.
	FilePath string `json:"file_path,omitempty"`

	// Link is inserted by Api client after GetFile request
	Link string `json:"link"`
}

File object represents any sort of file. The file can be downloaded via the Link. It is guaranteed that the link will be valid for at least 1 hour. When the link expires, a new one can be requested by calling GetFile. Maximum file size to download is 20 MB.

type FileCfg

type FileCfg struct {
	FileID string
}

FileCfg has information about a file hosted on Telegram.

func (FileCfg) Name

func (cfg FileCfg) Name() string

Name returns method name

func (FileCfg) Values

func (cfg FileCfg) Values() (url.Values, error)

Values returns a url.Values representation of FileCfg.

type Filer

type Filer interface {
	// Field name for file data
	Field() string
	// File data
	File() InputFile
	// Exist returns true if file exists on telegram servers
	Exist() bool
	// Reset removes FileID and sets new InputFile
	// Reset(InputFile)
	// GetFileID returns fileID if it's exist
	GetFileID() string
}

Filer is any config type that can be sent that includes a file.

type ForceReply

type ForceReply struct {
	MarkReplyMarkup

	ForceReply bool `json:"force_reply"`
	Selective  bool `json:"selective"` // optional
}

ForceReply allows the Bot to have users directly reply to it without additional interaction. Implements ReplyMarkup interface.

type ForwardMessageCfg

type ForwardMessageCfg struct {
	BaseChat
	// Unique identifier for the chat where the original message was sent
	FromChat BaseChat
	// Unique message identifier
	MessageID int64
	// Sends the message silently.
	// iOS users will not receive a notification,
	// Android users will receive a notification with no sound.
	// Other apps coming soon.
	DisableNotification bool
}

ForwardMessageCfg contains information about a ForwardMessage request. Use it to forward messages of any kind Implements Messenger interface.

func NewForwardMessage

func NewForwardMessage(chatID, fromChatID, messageID int64) ForwardMessageCfg

NewForwardMessage creates a new Message.

chatID is where to send it, text is the message text.

func (ForwardMessageCfg) Message

func (ForwardMessageCfg) Message() *Message

Message returns instance of *Message type.

func (ForwardMessageCfg) Name

func (cfg ForwardMessageCfg) Name() string

Name returns method name

func (ForwardMessageCfg) Values

func (cfg ForwardMessageCfg) Values() (url.Values, error)

Values returns a url.Values representation of MessageCfg. Returns RequiredError if Text is empty.

type GetChatAdministratorsCfg

type GetChatAdministratorsCfg struct {
	BaseChat
}

GetChatAdministratorsCfg contains information about a getChat request.

func (GetChatAdministratorsCfg) Name

func (cfg GetChatAdministratorsCfg) Name() string

Name returns method name

func (GetChatAdministratorsCfg) Values

func (cfg GetChatAdministratorsCfg) Values() (url.Values, error)

Values returns a url.Values representation of GetChatCfg. Returns RequiredError if Chat is not set.

type GetChatCfg

type GetChatCfg struct {
	BaseChat
}

GetChatCfg contains information about a getChat request.

func (GetChatCfg) Name

func (cfg GetChatCfg) Name() string

Name returns method name

func (GetChatCfg) Values

func (cfg GetChatCfg) Values() (url.Values, error)

Values returns a url.Values representation of GetChatCfg. Returns RequiredError if Chat is not set.

type GetChatMemberCfg

type GetChatMemberCfg struct {
	BaseChat
	UserID int64 `json:"user_id"`
}

GetChatMemberCfg contains information about a getChatMember request.

func (GetChatMemberCfg) Name

func (cfg GetChatMemberCfg) Name() string

Name returns method name

func (GetChatMemberCfg) Values

func (cfg GetChatMemberCfg) Values() (url.Values, error)

Values returns a url.Values representation of GetChatMemberCfg. Returns RequiredError if Chat or UserID are not set.

type GetChatMembersCountCfg

type GetChatMembersCountCfg struct {
	BaseChat
}

GetChatMembersCountCfg contains information about a getChatMemberCount request.

func (GetChatMembersCountCfg) Name

func (cfg GetChatMembersCountCfg) Name() string

Name returns method name

func (GetChatMembersCountCfg) Values

func (cfg GetChatMembersCountCfg) Values() (url.Values, error)

Values returns a url.Values representation of GetChatMembersCountCfg. Returns RequiredError if Chat is not set.

type HTTPDoer

type HTTPDoer interface {
	Do(*http.Request) (*http.Response, error)
}

HTTPDoer interface helps to test api

type InlineKeyboardButton

type InlineKeyboardButton struct {
	// Label text on the button
	Text string `json:"text"`
	// HTTP url to be opened when button is pressed. Optional.
	URL string `json:"url,omitempty"`
	// Data to be sent in a callback query to the bot
	// when button is pressed. Optional.
	CallbackData string `json:"callback_data,omitempty"`
	// If set, 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.
	// Optional.
	//
	// 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.
	SwitchInlineQuery string `json:"switch_inline_query,omitempty"`
}

InlineKeyboardButton object represents one button of an inline keyboard. You must use exactly one of the optional fields.

Note: This will only work in Telegram versions released after 9 April, 2016. Older clients will display unsupported message.

type InlineKeyboardMarkup

type InlineKeyboardMarkup struct {
	MarkReplyMarkup

	InlineKeyboard [][]InlineKeyboardButton `json:"inline_keyboard"`
}

InlineKeyboardMarkup object represents an inline keyboard that appears right next to the message it belongs to.

Warning: Inline keyboards are currently being tested and are only available in one‐on‐one chats (i.e., user‐bot or user‐user in the case of inline bots). Note: This will only work in Telegram versions released after 9 April, 2016. Older clients will display unsupported message.

type InlineQuery

type InlineQuery struct {
	// ID is a unique identifier for this query.
	ID string `json:"id"`
	// From is a sender.
	From User `json:"from"`
	// Sender location, only for bots that request user location.
	// Optional.
	Location *Location `json:"location,omitempty"`
	// Query is a text of the query.
	Query string `json:"query"`
	// Offset of the results to be returned, can be controlled by the bot.
	Offset string `json:"offset"`
}

InlineQuery is an incoming inline query. When the user sends an empty query, your bot could return some default or trending results.

type InlineQueryResult

type InlineQueryResult interface {
	// InlineQueryResult is a fake method that helps to identify implementations
	InlineQueryResult()
}

InlineQueryResult interface represents one result of an inline query. Telegram clients currently support results of the following 19 types:

- InlineQueryResultCachedAudio - InlineQueryResultCachedDocument - InlineQueryResultCachedGif - InlineQueryResultCachedMpeg4Gif - InlineQueryResultCachedPhoto - InlineQueryResultCachedSticker - InlineQueryResultCachedVideo - InlineQueryResultCachedVoice - InlineQueryResultArticle - InlineQueryResultAudio - InlineQueryResultContact - InlineQueryResultDocument - InlineQueryResultGif - InlineQueryResultLocation - InlineQueryResultMpeg4Gif - InlineQueryResultPhoto - InlineQueryResultVenue - InlineQueryResultVideo - InlineQueryResultVoice

type InlineQueryResultArticle

type InlineQueryResultArticle struct {
	MarkInlineQueryResult
	BaseInlineQueryResult
	InlineThumb

	Title string `json:"title"` // required
	URL   string `json:"url,omitempty"`
	// Optional. Pass True, if you don't want the URL
	// to be shown in the message
	HideURL     bool   `json:"hide_url,omitempty"`
	Description string `json:"description,omitempty"`
}

InlineQueryResultArticle is an inline query response article.

func NewInlineQueryResultArticle

func NewInlineQueryResultArticle(id, title, messageText string) *InlineQueryResultArticle

NewInlineQueryResultArticle creates a new inline query article.

type InlineQueryResultAudio

type InlineQueryResultAudio struct {
	MarkInlineQueryResult
	BaseInlineQueryResult

	AudioURL      string `json:"audio_url"` // required
	Title         string `json:"title"`     // required
	Performer     string `json:"performer"`
	AudioDuration int    `json:"audio_duration"`
}

InlineQueryResultAudio is an inline query response audio.

type InlineQueryResultContact

type InlineQueryResultContact struct {
	MarkInlineQueryResult
	BaseInlineQueryResult
	InlineThumb
	Contact
}

InlineQueryResultContact represents a contact with a phone number. By default, this contact will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the contact.

type InlineQueryResultDocument

type InlineQueryResultDocument struct {
	MarkInlineQueryResult
	BaseInlineQueryResult
	InlineThumb

	DocumentURL string `json:"document_url"` // required
	// Mime type of the content of the file,
	// either “application/pdf” or “application/zip”
	MimeType string `json:"mime_type"` // required
	// Title for the result
	Title string `json:"title"` // required
	// Optional. Caption of the document to be sent, 0-200 characters
	Caption string `json:"caption,omitempty"`
	// Optional. Short description of the result
	Description string `json:"description,omitempty"`
}

InlineQueryResultDocument is an inline query response document.

type InlineQueryResultGIF

type InlineQueryResultGIF struct {
	MarkInlineQueryResult
	BaseInlineQueryResult
	InlineThumb

	// A valid URL for the GIF file. File size must not exceed 1MB
	GifURL    string `json:"gif_url"` // required
	GifWidth  int    `json:"gif_width,omitempty"`
	GifHeight int    `json:"gif_height,omitempty"`
	Title     string `json:"title,omitempty"`
	Caption   string `json:"caption,omitempty"`
}

InlineQueryResultGIF is an inline query response GIF.

type InlineQueryResultLocation

type InlineQueryResultLocation struct {
	MarkInlineQueryResult
	BaseInlineQueryResult
	InlineThumb

	Latitude  float64 `json:"latitude"`  // required
	Longitude float64 `json:"longitude"` // required
	Title     string  `json:"title"`     // required
}

InlineQueryResultLocation is an inline query response location.

type InlineQueryResultMPEG4GIF

type InlineQueryResultMPEG4GIF struct {
	MarkInlineQueryResult
	BaseInlineQueryResult

	MPEG4URL    string `json:"mpeg4_url"` // required
	MPEG4Width  int    `json:"mpeg4_width,omitempty"`
	MPEG4Height int    `json:"mpeg4_height,omitempty"`
	Title       string `json:"title,omitempty"`
	Caption     string `json:"caption,omitempty"`
}

InlineQueryResultMPEG4GIF is an inline query response MPEG4 GIF.

type InlineQueryResultPhoto

type InlineQueryResultPhoto struct {
	MarkInlineQueryResult
	BaseInlineQueryResult
	InlineThumb

	PhotoURL    string `json:"photo_url"` // required
	PhotoWidth  int    `json:"photo_width,omitempty"`
	PhotoHeight int    `json:"photo_height,omitempty"`
	MimeType    string `json:"mime_type,omitempty"`
	Title       string `json:"title,omitempty"`
	Description string `json:"description,omitempty"`
	Caption     string `json:"caption,omitempty"`
}

InlineQueryResultPhoto is an inline query response photo.

type InlineQueryResultVenue

type InlineQueryResultVenue struct {
	MarkInlineQueryResult
	BaseInlineQueryResult
	InlineThumb
	Venue
}

InlineQueryResultVenue represents a venue. By default, the venue will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the venue.

type InlineQueryResultVideo

type InlineQueryResultVideo struct {
	MarkInlineQueryResult
	BaseInlineQueryResult
	InlineThumb

	VideoURL      string `json:"video_url"` // required
	MimeType      string `json:"mime_type"` // required
	Title         string `json:"title,omitempty"`
	Caption       string `json:"caption,omitempty"`
	VideoWidth    int    `json:"video_width,omitempty"`
	VideoHeight   int    `json:"video_height,omitempty"`
	VideoDuration int    `json:"video_duration,omitempty"`
	Description   string `json:"description,omitempty"`
}

InlineQueryResultVideo is an inline query response video.

type InlineQueryResultVoice

type InlineQueryResultVoice struct {
	MarkInlineQueryResult
	BaseInlineQueryResult

	VoiceURL string `json:"voice_url"` // required
	Title    string `json:"title"`     // required
	Duration int    `json:"voice_duration,omitempty"`
}

InlineQueryResultVoice is an inline query response voice.

type InlineThumb

type InlineThumb struct {
	ThumbURL    string `json:"thumb_url,omitempty"`
	ThumbWidth  int    `json:"thumb_width,omitempty"`
	ThumbHeight int    `json:"thumb_height,omitempty"`
}

InlineThumb struct helps to describe thumbnail.

type InputContactMessageContent

type InputContactMessageContent struct {
	MarkInputMessageContent
	Contact
}

InputContactMessageContent contains a contact for displaying as an inline query result. Implements InputMessageContent

type InputFile

type InputFile interface {
	Reader() io.Reader
	Name() string
}

InputFile describes interface for input files.

func NewBytesFile

func NewBytesFile(filename string, data []byte) InputFile

NewBytesFile takes byte slice and returns InputFile.

func NewInputFile

func NewInputFile(filename string, r io.Reader) InputFile

NewInputFile takes Reader object and returns InputFile.

type InputLocationMessageContent

type InputLocationMessageContent struct {
	MarkInputMessageContent
	Location
}

InputLocationMessageContent contains a location for displaying as an inline query result. Implements InputMessageContent

type InputMessageContent

type InputMessageContent interface {
	// MessageContent is a fake method that helps to identify implementations
	InputMessageContent()
}

InputMessageContent interface represents the content of a message to be sent as a result of an inline query. Telegram clients currently support the following 4 types:

  • InputTextMessageContent
  • InputLocationMessageContent
  • InputVenueMessageContent
  • InputContactMessageContent

type InputTextMessageContent

type InputTextMessageContent struct {
	MarkInputMessageContent

	// Text of the message to be sent, 1‐4096 characters
	MessageText string `json:"message_text"`
	// Send Markdown or HTML, if you want Telegram apps to show
	// bold, italic, fixed‐width text or inline URLs in your bot's message.
	// Use Mode constants. Optional.
	ParseMode string `json:"parse_mode,omitempty"`
	// Disables link previews for links in this message.
	DisableWebPagePreview bool `json:"disable_web_page_preview,omitempty"`
}

InputTextMessageContent represents the content of a text message to be sent as the result of an inline query.

type InputVenueMessageContent

type InputVenueMessageContent struct {
	MarkInputMessageContent
	Venue
}

InputVenueMessageContent contains a venue for displaying as an inline query result. Implements InputMessageContent

type KeyboardButton

type KeyboardButton struct {
	// Text of the button. If none of the optional fields are used,
	// it will be sent to the bot as a message when the button is pressed
	Text string `json:"text"`
	// If true, the user's phone number will be sent as a contact
	// when the button is pressed. Available in private chats only.
	// Optional.
	RequestContact bool `json:"request_contact,omitempty"`
	// If true, the user's current location will be sent
	// when the button is pressed. Available in private chats only.
	// Optional.
	RequestLocation bool `json:"request_location,omitempty"`
}

KeyboardButton object represents one button of the reply keyboard. Optional fields are mutually exclusive.

Note: request_contact and request_location options will only work in Telegram versions released after 9 April, 2016. Older clients will ignore them.

type KickChatMemberCfg

type KickChatMemberCfg struct {
	BaseChat
	UserID int64 `json:"user_id"`
}

KickChatMemberCfg contains information about a kickChatMember request.

func (KickChatMemberCfg) Name

func (cfg KickChatMemberCfg) Name() string

Name returns method name

func (KickChatMemberCfg) Values

func (cfg KickChatMemberCfg) Values() (url.Values, error)

Values returns a url.Values representation of KickChatMemberCfg. Returns RequiredError if Chat or UserID are not set.

type LeaveChatCfg

type LeaveChatCfg struct {
	BaseChat
}

LeaveChatCfg contains information about a leaveChat request.

func (LeaveChatCfg) Name

func (cfg LeaveChatCfg) Name() string

Name returns method name

func (LeaveChatCfg) Values

func (cfg LeaveChatCfg) Values() (url.Values, error)

Values returns a url.Values representation of LeaveChatCfg. Returns RequiredError if Chat is not set.

type Location

type Location struct {
	// Longitude as defined by sender
	Longitude float64 `json:"longitude"`
	// Latitude as defined by sender
	Latitude float64 `json:"latitude"`
}

Location object represents geographic position.

func (Location) Values

func (l Location) Values() url.Values

Values returns a url.Values representation of Location object.

type LocationCfg

type LocationCfg struct {
	BaseMessage
	Location
}

LocationCfg contains information about a SendLocation request.

func NewLocation

func NewLocation(chatID int64, lat float64, lon float64) LocationCfg

NewLocation shares your location.

chatID is where to send it, latitude and longitude are coordinates.

func (LocationCfg) Name

func (cfg LocationCfg) Name() string

Name method returns Telegram API method name for sending Location.

func (LocationCfg) Values

func (cfg LocationCfg) Values() (url.Values, error)

Values returns a url.Values representation of LocationCfg.

type MarkInlineQueryResult

type MarkInlineQueryResult struct{}

A MarkInlineQueryResult implements InlineQueryResult interface. You can mark your structures with this object.

func (MarkInlineQueryResult) InlineQueryResult

func (MarkInlineQueryResult) InlineQueryResult()

InlineQueryResult is a fake method that helps to identify implementations

type MarkInputMessageContent

type MarkInputMessageContent struct{}

A MarkInputMessageContent implements InputMessageContent interface. You can mark your structures with this object.

func (MarkInputMessageContent) InputMessageContent

func (MarkInputMessageContent) InputMessageContent()

InputMessageContent is a fake method that helps to identify implementations

type MarkReplyMarkup

type MarkReplyMarkup struct{}

A MarkReplyMarkup implements ReplyMarkup interface. You can mark your structures with this object.

func (MarkReplyMarkup) ReplyMarkup

func (MarkReplyMarkup) ReplyMarkup()

ReplyMarkup is a fake method that helps to identify implementations

type MeCfg

type MeCfg struct{}

MeCfg contains information about a getMe request.

func (MeCfg) Name

func (cfg MeCfg) Name() string

Name returns method name

func (MeCfg) Values

func (cfg MeCfg) Values() (url.Values, error)

Values for getMe is empty

type Message

type Message struct {
	// MessageID is a unique message identifier.
	MessageID int64 `json:"message_id"`

	// From is a sender, can be empty for messages sent to channels.
	// Optional.
	From *User `json:"from,omitempty"`
	// Date  the message was sent in Unix time.
	Date int `json:"date"`
	// Chat is a conversation the message belongs to.
	Chat Chat `json:"chat"`

	// ForwardFrom is a sender of the original message
	// for forwarded messages. Optional.
	ForwardFrom *User `json:"forward_from,omitempty"`

	// For messages forwarded from a channel,
	// information about the original channel. Optional.
	ForwardFromChat *Chat `json:"forward_from_chat,omitempty"`

	// ForwardDate is a unixtime of the original message
	// for forwarded messages. Optional.
	ForwardDate int `json:"forward_date"`

	// ReplyToMessage is an original message for replies.
	// Note that the Message object in this field will not
	// contain further ReplyToMessage fields even if it
	// itself is a reply. Optional.
	ReplyToMessage *Message `json:"reply_to_message,omitempty"`

	// Date the message was last edited in Unix time
	// Zero value means object wasn't edited.
	// Optional.
	EditDate int `json:"edit_date,omitempty"`

	// For text messages, special entities like usernames,
	// URLs, bot commands, etc. that appear in the text. Optional
	Entities []MessageEntity `json:"entities"`

	// Text is an actual UTF-8 text of the message for a text message,
	// 0-4096 characters. Optional.
	Text string `json:"text,omitempty"`

	// Audio has information about the audio file. Optional.
	Audio *Audio `json:"audio,omitempty"`

	// Document has information about a general file. Optional.
	Document *Document `json:"document,omitempty"`

	// Photo has a slice of available sizes of photo. Optional.
	Photo []PhotoSize `json:"photo,omitempty"`

	// Sticker has information about the sticker. Optional.
	Sticker *Sticker `json:"sticker,omitempty"`

	// For a video, information about it.
	Video *Video `json:"video,omitempty"`

	// Message is a voice message, information about the file
	Voice *Voice `json:"voice,omitempty"`

	// Caption for the document, photo or video, 0‐200 characters
	Caption string `json:"caption,omitempty"`

	// For a contact, contact information itself.
	Contact *Contact `json:"contact,omitempty"`

	// For a location, its longitude and latitude.
	Location *Location `json:"location,omitempty"`

	// Message is a venue, information about the venue
	Venue *Venue `json:"venue,omitempty"`

	// NewChatMember has an information about a new member
	// that was added to the group
	// (this member may be the bot itself). Optional.
	NewChatMember *User `json:"new_chat_member,omitempty"`

	// LeftChatMember has an information about a member
	// that was removed from the group
	// (this member may be the bot itself). Optional.
	LeftChatMember *User `json:"left_chat_member,omitempty"`

	// For a service message, represents a new title
	// for chat this message came from.
	//
	// Sender would lead to a User, capable of change.
	NewChatTitle string `json:"new_chat_title,omitempty"`

	// For a service message, represents all available
	// thumbnails of new chat photo.
	//
	// Sender would lead to a User, capable of change.
	NewChatPhoto []PhotoSize `json:"new_chat_photo,omitempty"`

	// For a service message, true if chat photo just
	// got removed.
	//
	// Sender would lead to a User, capable of change.
	DeleteChatPhoto bool `json:"delete_chat_photo,omitempty"`

	// For a service message, true if group has been created.
	//
	// You would receive such a message if you are one of
	// initial group chat members.
	//
	// Sender would lead to creator of the chat.
	GroupChatCreated bool `json:"group_chat_created,omitempty"`

	// For a service message, true if super group has been created.
	//
	// You would receive such a message if you are one of
	// initial group chat members.
	//
	// Sender would lead to creator of the chat.
	SuperGroupChatCreated bool `json:"supergroup_chat_created,omitempty"`

	// For a service message, true if channel has been created.
	//
	// You would receive such a message if you are one of
	// initial channel administrators.
	//
	// Sender would lead to creator of the chat.
	ChannelChatCreated bool `json:"channel_chat_created,omitempty"`

	// For a service message, the destination (super group) you
	// migrated to.
	//
	// You would receive such a message when your chat has migrated
	// to a super group.
	//
	// Sender would lead to creator of the migration.
	MigrateToChatID int64 `json:"migrate_to_chat_id,omitempty"`

	// For a service message, the Origin (normal group) you migrated
	// from.
	//
	// You would receive such a message when your chat has migrated
	// to a super group.
	//
	// Sender would lead to creator of the migration.
	MigrateFromChatID int64 `json:"migrate_from_chat_id,omitempty"`
	// Specified message was pinned.
	// Note that the Message object in this field
	// will not contain further reply_to_message fields
	// even if it is itself a reply.
	PinnedMessage *Message `json:"pinned_message,omitempty"`
}

Message object represents a message.

func (*Message) Command

func (m *Message) Command() (string, string)

Command checks if the message was a command and if it was, returns the command and agrument. If the Message was not a command, it returns an empty strings.

If the command contains the at bot syntax, it removes the bot name.

func (*Message) IsCommand

func (m *Message) IsCommand() bool

IsCommand returns true if message starts with '/'.

type MessageCfg

type MessageCfg struct {
	BaseMessage
	Text string
	// Send Markdown or HTML, if you want Telegram apps to show
	// bold, italic, fixed-width text or inline URLs in your bot's message.
	// Use one of constants: ModeHTML, ModeMarkdown.
	ParseMode string
	// Disables link previews for links in this message.
	DisableWebPagePreview bool
}

MessageCfg contains information about a SendMessage request. Use it to send text messages. Implements Messenger interface.

func NewMessage

func NewMessage(chatID int64, text string) MessageCfg

NewMessage creates a new Message.

chatID is where to send it, text is the message text.

func NewMessagef

func NewMessagef(chatID int64, text string, args ...interface{}) MessageCfg

NewMessagef creates a new Message with formatting.

chatID is where to send it, text is the message text

func (MessageCfg) Name

func (cfg MessageCfg) Name() string

Name returns method name

func (MessageCfg) Values

func (cfg MessageCfg) Values() (url.Values, error)

Values returns a url.Values representation of MessageCfg. Returns RequiredError if Text is empty.

type MessageEntity

type MessageEntity struct {
	// Type of the entity. One of mention ( @username ), hashtag,
	// bot_command, url, email, bold (bold text),
	// italic (italic text), code (monowidth string),
	// pre (monowidth block), text_link (for clickable text URLs),
	// text_mention (for users without usernames)
	// Use constants SomethingEntityType instead of string.
	Type string `json:"type"`
	// Offset in UTF‐16 code units to the start of the entity
	Offset int `json:"offset"`
	// Length of the entity in UTF‐16 code units
	Length int `json:"length"`
	// For “text_link” only, url that will be opened
	// after user taps on the text. Optional
	URL string `json:"url,omitempty"`
	// For “text_mention” only, the mentioned user. Optional.
	User *User `json:"user,omitempty"`
}

MessageEntity object represents one special entity in a text message. For example, hashtags, usernames, URLs, etc.

type Messenger

type Messenger interface {
	Method
	Message() *Message
}

Messenger is a virtual interface to distinct methods that return Message from others.BaseMessage

func CloneMessage

func CloneMessage(msg *Message, baseMessage *BaseMessage) Messenger

CloneMessage convert message to Messenger type to send it to another chat. It supports only data message: Text, Sticker, Audio, Photo, Location, Contact, Audio, Voice, Document.

type MetaFile

type MetaFile struct {
	// FileID is a Unique identifier for this file.
	FileID string `json:"file_id"`
	// FileSize is a size of file if known. Optional.
	FileSize int `json:"file_size,omitempty"`
}

MetaFile represents meta information about file.

type Method

type Method interface {
	// method name
	Name() string
	// method params
	Values() (url.Values, error)
}

Method describes interface for Telegram API request

Every method is https://api.telegram.org/bot<token>/METHOD_NAME Values are passed as application/x-www-form-urlencoded for usual request and multipart/form-data when files are uploaded.

type PhotoCfg

type PhotoCfg struct {
	BaseFile
	Caption string
}

PhotoCfg contains information about a SendPhoto request. Use it to send information about a venue Implements Filer and Messenger interfaces.

func NewPhotoShare

func NewPhotoShare(chatID int64, fileID string) PhotoCfg

NewPhotoShare creates a new photo uploader.

chatID is where to send it

func NewPhotoUpload

func NewPhotoUpload(chatID int64, inputFile InputFile) PhotoCfg

NewPhotoUpload creates a new photo uploader.

chatID is where to send it, inputFile is a file representation.

func (PhotoCfg) Field

func (cfg PhotoCfg) Field() string

Field returns name for photo file data

func (PhotoCfg) Name

func (cfg PhotoCfg) Name() string

Name returns method name

func (PhotoCfg) Values

func (cfg PhotoCfg) Values() (url.Values, error)

Values returns a url.Values representation of PhotoCfg.

type PhotoSize

type PhotoSize struct {
	MetaFile
	Size
}

PhotoSize object represents one size of a photo or a file / sticker thumbnail.

type ReplyKeyboardHide

type ReplyKeyboardHide struct {
	MarkReplyMarkup

	HideKeyboard bool `json:"hide_keyboard"`
	Selective    bool `json:"selective"` // optional
}

ReplyKeyboardHide tells Telegram clients to hide the current custom keyboard and display the default letter-keyboard. Implements ReplyMarkup interface.

type ReplyKeyboardMarkup

type ReplyKeyboardMarkup struct {
	MarkReplyMarkup

	// Array of button rows, each represented by an Array of Strings
	Keyboard [][]KeyboardButton `json:"keyboard"`
	// 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.
	ResizeKeyboard bool `json:"resize_keyboard,omitempty"`
	// 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.
	OneTimeKeyboard bool `json:"one_time_keyboard,omitempty"`
	// 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.
	Selective bool `json:"selective,omitempty"`
}

ReplyKeyboardMarkup represents a custom keyboard with reply options. Implements ReplyMarkup interface.

type ReplyMarkup

type ReplyMarkup interface {
	// ReplyMarkup is a fake method that helps to identify implementations
	ReplyMarkup()
}

ReplyMarkup describes interface for reply_markup keyboards.

type RequiredError

type RequiredError struct {
	Fields []string
}

RequiredError tells if fields are required but were not filled

func NewRequiredError

func NewRequiredError(fields ...string) *RequiredError

NewRequiredError creates RequireError

func (*RequiredError) Error

func (e *RequiredError) Error() string

Error returns string representation for RequiredError

type Size

type Size struct {
	Width  int `json:"width"`
	Height int `json:"height"`
}

Size object represent size information.

type Sticker

type Sticker struct {
	MetaFile
	Size // Sticker width and height

	// Sticker thumbnail in .webp or .jpg format. Optional.
	Thumb *PhotoSize `json:"thumb,omitempty"`
	// Emoji associated with the sticker. Optional.
	Emoji string `json:"emoji,omitempty"`
}

Sticker object represents a WebP image, so-called sticker.

type StickerCfg

type StickerCfg struct {
	BaseFile
}

StickerCfg contains information about a SendSticker request. Implements Filer and Messenger interfaces.

func (StickerCfg) Field

func (cfg StickerCfg) Field() string

Field returns name for sticker file data

func (StickerCfg) Name

func (cfg StickerCfg) Name() string

Name method returns Telegram API method name for sending Sticker.

func (StickerCfg) Values

func (cfg StickerCfg) Values() (url.Values, error)

Values returns a url.Values representation of StickerCfg.

type UnbanChatMemberCfg

type UnbanChatMemberCfg struct {
	BaseChat
	UserID int64 `json:"user_id"`
}

UnbanChatMemberCfg contains information about a unbanChatMember request.

func (UnbanChatMemberCfg) Name

func (cfg UnbanChatMemberCfg) Name() string

Name returns method name

func (UnbanChatMemberCfg) Values

func (cfg UnbanChatMemberCfg) Values() (url.Values, error)

Values returns a url.Values representation of UnbanChatMemberCfg. Returns RequiredError if Chat or UserID are not set.

type Update

type Update struct {
	// UpdateID is the update‘s unique identifier.
	// Update identifiers start from a certain positive number
	// and increase sequentially
	UpdateID int64 `json:"update_id"`
	// Message is a new incoming message of any kind:
	// text, photo, sticker, etc. Optional.
	Message *Message `json:"message,omitempty"`
	// New version of a message that is known to the bot and was edited.
	// Optional.
	EditedMessage *Message `json:"edited_message,omitempty"`
	// InlineQuery is a new incoming inline query. Optional.
	InlineQuery *InlineQuery `json:"inline_query,omitempty"`
	// ChosenInlineResult is a result of an inline query
	// that was chosen by a user and sent to their chat partner. Optional.
	ChosenInlineResult *ChosenInlineResult `json:"chosen_inline_result,omitempty"`
	// CallbackQuery is a new incoming callback query. Optional.
	CallbackQuery *CallbackQuery `json:"callback_query,omitempty"`
}

Update object represents an incoming update. Only one of the optional parameters can be present in any given update

func (Update) Chat

func (u Update) Chat() (chat *Chat)

Chat takes chat from Message and CallbackQuery

func (Update) From

func (u Update) From() (from *User)

From takes User from Message, CallbackQuery, InlineQuery or ChosenInlineResult

func (Update) HasMessage

func (u Update) HasMessage() bool

HasMessage returns true if update object contains Message field

func (Update) IsEdited

func (u Update) IsEdited() bool

IsEdited returns true if update object contains EditedMessage field

type UpdateCfg

type UpdateCfg struct {
	// Identifier of the first update to be returned.
	// Must be greater by one than the highest
	// among the identifiers of previously received updates.
	// By default, updates starting with the earliest
	// unconfirmed update are returned. An update is considered confirmed
	// as soon as getUpdates is called with an offset
	// higher than its update_id. The negative offset
	// can be specified to retrieve updates starting
	// from -offset update from the end of the updates queue.
	// All previous updates will forgotten.
	Offset int64
	// 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
	Timeout int
}

UpdateCfg contains information about a getUpdates request.

func NewUpdate

func NewUpdate(offset int64) UpdateCfg

NewUpdate gets updates since the last Offset with Timeout 30 seconds

offset is the last Update ID to include. You likely want to set this to the last Update ID plus 1. The negative offset can be specified to retrieve updates starting from -offset update from the end of the updates queue. All previous updates will forgotten.

func (UpdateCfg) Name

func (cfg UpdateCfg) Name() string

Name returns method name

func (UpdateCfg) Values

func (cfg UpdateCfg) Values() (url.Values, error)

Values returns getUpdate params. It returns error if Limit is not between 0 and 100. Zero params are not included to request.

type User

type User struct {
	// ID is a unique identifier for this user or bot.
	ID int64 `json:"id"`
	// FirstName is a user‘s or bot’s first name
	FirstName string `json:"first_name"`
	// LastName is a user‘s or bot’s last name. Optional.
	LastName string `json:"last_name,omitempty"`
	// Username is a user‘s or bot’s username. Optional.
	Username string `json:"username,omitempty"`
}

User object represents a Telegram user or bot.

object represents a group chat if Title is empty.

type UserProfilePhotos

type UserProfilePhotos struct {
	// Total number of profile pictures the target user has
	TotalCount int `json:"total_count"`
	// Requested profile pictures (in up to 4 sizes each)
	Photos [][]PhotoSize `json:"photos"`
}

UserProfilePhotos contains a set of user profile pictures.

type UserProfilePhotosCfg

type UserProfilePhotosCfg struct {
	UserID int64
	// Sequential number of the first photo to be returned.
	// By default, all photos are returned.
	Offset int
	// Limits the number of photos to be retrieved.
	// Values between 1—100 are accepted. Defaults to 100.
	Limit int
}

UserProfilePhotosCfg contains information about a GetUserProfilePhotos request.

func NewUserProfilePhotos

func NewUserProfilePhotos(userID int64) UserProfilePhotosCfg

NewUserProfilePhotos gets user profile photos.

userID is the ID of the user you wish to get profile photos from.

func (UserProfilePhotosCfg) Name

func (cfg UserProfilePhotosCfg) Name() string

Name returns method name

func (UserProfilePhotosCfg) Values

func (cfg UserProfilePhotosCfg) Values() (url.Values, error)

Values returns a url.Values representation of UserProfilePhotosCfg. Returns RequiredError if UserID is empty.

type ValidationError

type ValidationError struct {
	// Field name
	Field       string `json:"field"`
	Description string `json:"description"`
}

ValidationError tells if field has wrong value

func NewValidationError

func NewValidationError(field string, description string) *ValidationError

NewValidationError creates ValidationError

func (*ValidationError) Error

func (e *ValidationError) Error() string

Error returns string representation for ValidationError

type Venue

type Venue struct {
	// Venue location
	Location Location `json:"location"`
	// Name of the venue
	Title string `json:"title"`
	// Address of the venue
	Address string `json:"address"`
	// Foursquare identifier of the venue. Optional.
	FoursquareID string `json:"foursquare_id,omitempty"`
}

Venue object represents a venue.

func (Venue) Values

func (venue Venue) Values() url.Values

Values returns a url.Values representation of Venue object.

type VenueCfg

type VenueCfg struct {
	BaseMessage
	Venue
}

VenueCfg contains information about a SendVenue request. Use it to send information about a venue Implements Messenger interface.

func (VenueCfg) Name

func (cfg VenueCfg) Name() string

Name returns method name

func (VenueCfg) Values

func (cfg VenueCfg) Values() (url.Values, error)

Values returns a url.Values representation of VenueCfg. Returns RequiredError if Text is empty.

type Video

type Video struct {
	MetaFile
	Size

	// Duration of the recording in seconds as defined by sender.
	Duration int `json:"duration"`
	// MIMEType of the file as defined by sender. Optional.
	MIMEType string `json:"mime_type,omitempty"`
	// Video thumbnail. Optional.
	Thumb *PhotoSize `json:"thumb,omitempty"`
}

Video object represents an MP4-encoded video.

type VideoCfg

type VideoCfg struct {
	BaseFile
	Duration int
	Caption  string
}

VideoCfg contains information about a SendVideo request. Use it to send information about a video Implements Filer and Messenger interfaces.

func (VideoCfg) Field

func (cfg VideoCfg) Field() string

Field returns name for video file data

func (VideoCfg) Name

func (cfg VideoCfg) Name() string

Name returns method name

func (VideoCfg) Values

func (cfg VideoCfg) Values() (url.Values, error)

Values returns a url.Values representation of VideoCfg.

type Voice

type Voice struct {
	MetaFile

	// Duration of the recording in seconds as defined by sender.
	Duration int `json:"duration"`
	// MIMEType of the file as defined by sender. Optional.
	MIMEType string `json:"mime_type,omitempty"`
}

Voice object represents a voice note.

type VoiceCfg

type VoiceCfg struct {
	BaseFile
	Duration int
}

VoiceCfg contains information about a SendVoice request. Use it to send information about a venue Implements Filer and Messenger interfaces.

func (VoiceCfg) Field

func (cfg VoiceCfg) Field() string

Field returns name for voice file data

func (VoiceCfg) Name

func (cfg VoiceCfg) Name() string

Name returns method name

func (VoiceCfg) Values

func (cfg VoiceCfg) Values() (url.Values, error)

Values returns a url.Values representation of VoiceCfg.

type WebhookCfg

type WebhookCfg struct {
	URL string
	// self generated TLS certificate
	Certificate InputFile
}

WebhookCfg contains information about a SetWebhook request. Implements Method and Filer interface

func NewWebhook

func NewWebhook(link string) WebhookCfg

NewWebhook creates a new webhook.

link is the url parsable link you wish to get the updates.

func NewWebhookWithCert

func NewWebhookWithCert(link string, file InputFile) WebhookCfg

NewWebhookWithCert creates a new webhook with a certificate.

link is the url you wish to get webhooks, file contains a string to a file, FileReader, or FileBytes.

func (WebhookCfg) Exist

func (cfg WebhookCfg) Exist() bool

Exist is true if we don't have a certificate to upload. It's kind of confusing.

func (WebhookCfg) Field

func (cfg WebhookCfg) Field() string

Field returns name for webhook file data

func (WebhookCfg) File

func (cfg WebhookCfg) File() InputFile

File returns certificate data

func (*WebhookCfg) GetFileID

func (cfg *WebhookCfg) GetFileID() string

GetFileID for webhook is always empty

func (WebhookCfg) Name

func (cfg WebhookCfg) Name() string

Name method returns Telegram API method name for sending Location.

func (*WebhookCfg) Reset

func (cfg *WebhookCfg) Reset(i InputFile)

Reset method sets new Certificate

func (WebhookCfg) Values

func (cfg WebhookCfg) Values() (url.Values, error)

Values returns a url.Values representation of Webhook config.

Directories

Path Synopsis
cmd
examples
api
inline
Inline example shows how to use inline bots
Inline example shows how to use inline bots

Jump to

Keyboard shortcuts

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