tgbot

package module
v0.0.0-...-3c1f76c Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2015 License: GPL-2.0 Imports: 27 Imported by: 0

README

Telegram Bot API library! GoDoc

Telegram API bot wrapper for Go (golang) Language! <3

This is a beauty way to build telegram bots with golang.

Almost all methods have been added, and all features will be available soon. If you want a feature that hasn't been added yet or something is broken, open an issue and let's build it!

Also, if you develop a bot with this, I would love to hear about it! ^^

Disclaimer

This is the first time I write Go code, so, if you see something that I'm doing bad, please, tell me, I love to learn :-)

Also, some people had tell me that the way this library have to handle the functions is "too javascript". I am trying to be as much Go-like as I know, and the way I build the library chains are based in mux and gorequest, if you know a most Go-like way of build this, please, tell me! (I hate JS, and have heard that my library looks like JS made me sad xD)

You can talk to me in telegram

Example

Show me the code!

package main

import (
	"fmt"

	"github.com/rockneurotiko/go-tgbot"
)

func echoHandler(bot tgbot.TgBot, msg tgbot.Message, vals []string, kvals map[string]string) *string {
	newmsg := fmt.Sprintf("[Echoed]: %s", vals[1])
	return &newmsg
}

func main() {
	bot := tgbot.NewTgBot("token").
		CommandFn(`echo (.+)`, echoHandler)
	bot.SimpleStart()
}

You can see the code in the echo example

Installation

As all the go libraries, you can install it with the go get tool:

go get -u github.com/rockneurotiko/go-tgbot

Receiving messages!

First, you need to create a new TgBot:

bot := tgbot.NewTgBot("token")

The "token" is the token that @botfather gives you when you create a new bot.

After that, you can add your functions that will be executed, see bellow to see the the different ways and conditions for your functions, choose the proper one. This functions are called in a goroutine, so don't worry to "hang" the bot :-)

Call in text messages (The typical)

Currently, there are two function signatures that you can use:

  • The simplest one, this should be used for messages that don't have parameters, like /help

    func(TgBot, Message, string) *string
    

    The parameters are:

    • TgBot: the instance of the bot, so you can call functions inside that one.
    • Message: The Message struct that represents it, so you can get any param.
    • string: The message in a string :)
  • The complex one, this should be used when you gave complex regular expressions.

    func(TgBot, Message, []string, map[string]string) *string
    

    The parameters are:

    • TgBot: the instance of the bot, so you can call functions inside that one.
    • Message: The Message struct that represents it, so you can get any param.
    • []string: This will be the captures groups in the regular expression, easy to get them ^^
    • map[string]string: This are the named capture groups, much more easy to get them!!

With this two kinds of functions, you can build your function calls with commands in the TgBot instance, all the functions that start with Simple uses the simplest function call.

Before of explain them, you have to know what a command is. A command is what Telegram API understand as a command, that ones that @botfather let you define with /setcommands function.

That commands always look like /<command>, but they can have other parameters /<command> <param1> <param2> ..., we'll see that later.

The curious thing is that the commands can be called as /<command> or /<command>@username, this is useful when you are in a group and you want to specify the bot to send that command. If you use this functions, you don't have to worry about adding or handling the @username, the library will handle it magically for you <3

Also, more magic is that you don't need to write the / command, neither the safe-command characters for the expression, that are the starting ^ and the leading $, so, if you say you want the command help, the library will understand you and make ^/help(?:@username)?$ :)

So, let's stop talking and let's see the functions that you can use, in the simpleexample file you can see an example for every one ^^

  • SimpleCommandFn(string, func(TgBot, Message, string) *string): This is the basic one, when you want a command without arguments, like the basic /start or /help, you just have to create a simple function that we saw before, and add it to a command. For example, this code will add a simple command handler (helpHandler) to the /help command, and it will be called properly with a /help command and /help@username ^^

    bot := tgbot.NewTgBot("token").
      SimpleCommandFn(`^/help$`, helpHandler)
    bot.SimpleStart()
    
  • CommandFn(string, func(TgBot, Message, []string, map[string]string) *string): Sometimes, you don't want a simple command, you want something more interesting that take parameters, this function will help you. This snippet code will add a command handler (not a simple one) (echoHandler) to the /echo command that will take a parameter, it will be called properly if /echo@username is used 😄

    bot := tgbot.NewTgBot("token").
      CommandFn(`^/echo (.+)`, echoHandler)
    bot.SimpleStart()
    

    The vals []string parameter in the echoHandler will be of size 2, the first one is the complete text, and the second one is what the capture group (.+) handles.

  • MultiCommandFn([]string, func(TgBot, Message, []string, map[string]string) *string): Other times, you want multiple commands, for example, you want a /help and /help <command>, of course, you can build a regexp that matches that, or build it with two different functions, but there can be more complicated situations, and this is a beauty way to build this. You just give him a list of regular expressions that will try to execute in order, but will only execute one of them.

    bot := tgbot.NewTgBot("token").
      MultiCommandFn([]string{`^/help (\w+)$`, `^/help$`}, helpHand).
    bot.SimpleStart()
    

That's all the functions for working with commands! You have many choices to build, and many times they are interchangeable, so you can use the one you prefer =D

After see the commands, there are some messages that are not commands, but you still want to do something in that messages! So, the regex functions come to save you!

And why to use different functions? Two reasons, first one, you can know what's a real command and what not, just for looking in the call, second one, because the command functions do magic to handle the @username thing, won't work properly in custom regexp ;-)

Actually, this functions work exactly the same as their command-like function, just that don't add the @username magic :)

  • SimpleRegexFn(string, func(TgBot, Message, string) *string):

    bot := tgbot.NewTgBot("token").
      SimpleRegexFn(`^Hello!$`, helloHand)
    bot.SimpleStart()
    
  • RegexFn([]string, func(TgBot, Message, []string, map[string]string) *string):

    bot := tgbot.NewTgBot("token").
      RegexFn(`^Repet this: (.+)$`, repeatHand)
    bot.SimpleStart()
    
  • MultiRegexFn([]string, func(TgBot, Message, []string, map[string]string) *string): (Sorry for this bad example, but no one comed to my mind, if you have some good example, please tell me!)

    bot := tgbot.NewTgBot("token").
      MultiRegexFn([]string{`^First regex$`, `^Second regex (.*)`}, multiregHand)
    bot.SimpleStart()
    
Call in file messages.
  • ImageFn(func(TgBot, Message, []PhotoSize, string)) Function to be called when an image is received, the two extra parameters are an array of PhotoSize, and the ID of the file.
Other miscellaneous calls.
  • AnyMsgFn(func(TgBot, Message)) This functions will be called in every message, be careful!

  • CustomFn(func(TgBot, Message) bool, func(TgBot, Message)) With this callbacks you can add your custom conditions, first it will execute the first function, if the return value is true, execute the second one.

Doing actions!

So, you know how to get your functions call when something arrives, but how can you answer? That's really important! If the bot can't answer, then you don't have a bot! So, let's talk about the action functions availables in TgBot

The basic action is send a text, and this is really simple here, did you see that the functions had a *string parameter at the end? Well, that's because the string that you return, will be sended to the chat that the message comes from. Easy! Why a pointer? to allow returning nil, but I don't like this, if you have a better idea, please tell me!

For example, this function will send to the sender (person or group) the same message:

func example(bot tgbot.TgBot, msg tgbot.Message, text string) *string {
    return &text
}

You can do other actions too! Did you see that the first parameter is the TgBot instance? That's to allow you doing actions!

All the actions have a "pure" function that just sends the query, you can call them directry, they are called like ActionNameQuery, for example, SendMessageQuery or ForwardMessageQuery, but it's better to use the custom functions:

Message actions
  • SendMessage functions:

    • SimpleSendMessage(msg Message, text string) (Message, error): Simplified call with the message and a string, and it will send that string to the sender.

    • SendMessage(chatid int, text string, disable_web_preview *bool, reply_to_message_id *int, reply_markup *ReplyMarkupInt) ResultWithMessage: Send a message with all parameters, the chat id (you can acces with msg.Chat.ID), the string to send, and two pointers (because are optional, so if you don't want them, just pass nil), disable_web_preview, reply_to_message_id, and reply_markup, that is an interface, and the structs you can use are: ReplyKeyboardMarkup, ReplyKeyboardHide and ForceReply, but for this, better use the following functions.

    • SendMessageWithKeyboard(chatid int, text string, disable_web_preview *bool, reply_to_message_id *int, reply_markup ReplyKeyboardMarkup) ResultWithMessage: This makes easier to send a keyboard, just pass the struct :)

    • SendMessageWithKeyboardHide(chatid int, text string, disable_web_preview *bool, reply_to_message_id *int, reply_markup ReplyKeyboardHide) ResultWithMessage: This makes easier to send a the hide keyboard, just pass the struct :)

    • SendMessageWithForceReply(chatid int, text string, disable_web_preview *bool, reply_to_message_id *int, reply_markup ForceReply) ResultWithMessage: This makes easier to send a force reply, just pass the struct :)

    • SendMessageQuery(payload QuerySendMessage) ResultWithMessage: Try not to use this :)

  • ForwardMessage functions:

    • ForwardMessage(chatid int, fromid int, messageid int) ResultWithMessage: Will forward to chatid saying that comes from fromid the message messageid

    • ForwardMessageQuery(payload ForwardMessageQuery) ResultWithMessage: Try to don't use this :)

File actions
  • SendPhoto functions, wherever you see the path, can be a file path or a file id 😄, it's handled automatically:

    • SimpleSendPhoto(msg Message, path string) (Message, error): Simplified call with the path and a string, and it will send that string to the sender.

    • SendPhoto(chatid int, path string, caption *string, reply_to_message_id *int, reply_markup *ReplyMarkupInt) ResultWithMessage: Like the SendMessage, but sending the photo, use this for full control over the parameters.

    • SendPhotoWithKeyboard(chatid int, path string, caption *string, reply_to_message_id *int, reply_markup ReplyKeyboardMarkup) ResultWithMessage: This makes easier to send a keyboard, just pass the struct instead of a pointer to an interface :)

    • SendPhotoWithKeyboardHide(chatid int, path string, caption *string, reply_to_message_id *int, reply_markup ReplyKeyboardHide) ResultWithMessage: This makes easier to send a the hide keyboard, just pass the struct instead of a pointer to an interface :)

    • SendPhotoWithForceReply(chatid int, path string, caption *string, reply_to_message_id *int, reply_markup ForceReply) ResultWithMessage: This makes easier to send a force reply, just pass the struct instead of a pointer to an interface :)

    • SendPhotoQuery(payload interface{}) ResultWithMessage: Try not to use this :) (btw, the interface{} is checked agains SendPhotoIDQuery and SendPhotoPathQuery)

Full examples!

You can found a full example with all the functions/calls in the simpleexample/main.go file.

If you want to handle the messages by yourself, you can too, you will have to add a channel to the listener and start it.

See the manualexample/main.go file to see an example of manual handling 😄

What is done and what left!

You are welcome to help in building this project 😄 <3

  • Callback functions

    • Simple command
    • Command with parameters
    • Multiple commands
    • Simple regular expression
    • Normal regular expression
    • Multiple regular expressions
    • Any message
    • On custom function
    • On image
    • On audio
    • On document
    • On video
    • On location
    • On message replied
    • On message forwarded
    • On any group event
    • On new chat participant
    • On left chat participant
    • On new chat title
    • On new chat photo
    • On delete chat photo
    • On group chat created
  • Action functions

    • Get me
    • Send message
      • easy with keyboard
      • easy with force reply
      • easy with keyboard hide
    • Forward message
    • getUpdates
      • This is done automatically when you use the SimpleStart() or Start(), you shouldn't touch this ;-)
    • setWebhook (!! in testing !!)
      • This is done automatically when you use ServerStart(), you can use other ways.
    • Send photo
    • From id
    • From file
    • easy with keyboard
    • easy with force reply
    • easy with keyboard hide
    • Send audio
    • From id
    • From file
    • easy with keyboard
    • easy with force reply
    • easy with keyboard hide
    • Send document
    • From id
    • From file
    • easy with keyboard
    • easy with force reply
    • easy with keyboard hide
    • Send sticker
    • From id
    • From file
    • easy with keyboard
    • easy with force reply
    • easy with keyboard hide
    • Send video
    • From id
    • From file
    • easy with keyboard
    • easy with force reply
    • easy with keyboard hide
    • Send location
    • Send chat action
    • Get user profile photos
  • Other nice things!

    • Default options for messages configured before start.
      • Disable webpage preview
      • Selective the reply_markup
      • One time keyboard
      • Clean initial @username in message
      • Add slash in message if don't exist and @username had been used
    • Easy to work with authorized users
    • Easy to work with "flow" messages
  • Complete documentation xD

    • Audio doc
    • Document doc
    • Sticker doc
    • Video doc
    • Location doc
    • ChatAction doc
    • Awesome chain doc
    • GetUserProfilePhotos
    • Webhook
    • Chain messages
    • Default options
    • Call from ReplyFn
  • Tests

Bitdeli Badge

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AlwaysReturnTrue

func AlwaysReturnTrue(bot TgBot, msg Message) bool

AlwaysReturnTrue ...

func StartServerMultiplesBots

func StartServerMultiplesBots(uri string, pathl string, newrelic *RelicConfig, bots ...*TgBot)

StartServerMultiplesBots ...

func StartServerMultiplesBotsHostPort

func StartServerMultiplesBotsHostPort(uri string, pathl string, host string, port string, newrelic *RelicConfig, bots ...*TgBot)

Types

type Audio

type Audio struct {
	FileID    string  `json:"file_id"`
	Duration  int     `json:"duration"`
	Performer *string `json:"performer,omitempty"`
	Title     *string `json:"title,omitempty"`
	MimeType  *string `json:"mime_type,omitempty"`
	FileSize  *int    `json:"file_size,omitempty"`
}

Audio ...

type AudioConditionalCall

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

AudioConditionalCall ...

type ChainStructure

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

ChainStructure ...

func NewChainStructure

func NewChainStructure() *ChainStructure

NewChainStructure ...

func (*ChainStructure) AddToConditionalFuncs

func (cc *ChainStructure) AddToConditionalFuncs(cf ConditionCallStructure)

AddToConditionalFuncs ...

func (*ChainStructure) SetCancelCond

func (cc *ChainStructure) SetCancelCond(c ConditionCallStructure)

SetCancelCond ...

func (*ChainStructure) SetLoop

func (cc *ChainStructure) SetLoop(b bool)

SetLoop ...

func (*ChainStructure) UserInChain

func (cc *ChainStructure) UserInChain(msg Message) bool

UserInChain ...

type ChatAction

type ChatAction int

ChatAction ...

const (
	Typing ChatAction = 1 + iota
	UploadPhoto
	RecordVideo
	UploadVideo
	RecordAudio
	UploadAudio
	UploadDocument
	FindLocation
)

This is the enumerable

func (ChatAction) String

func (ca ChatAction) String() string

type CommandStructure

type CommandStructure interface {
	// contains filtered or unexported methods
}

CommandStructure ...

type ConditionCallStructure

type ConditionCallStructure interface {
	// contains filtered or unexported methods
}

ConditionCallStructure ...

type Contact

type Contact struct {
	PhoneNumber string  `json:"phone_number"`
	FirstName   string  `json:"first_name"`
	LastName    *string `json:"last_name,omitempty"`
	UserID      *int    `json:"user_id,omitempty"`
}

Contact ...

type CustomCall

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

CustomCall ...

type DefaultOptionsBot

type DefaultOptionsBot struct {
	DisableWebURL              *bool
	Selective                  *bool
	OneTimeKeyboard            *bool
	CleanInitialUsername       bool
	AllowWithoutSlashInMention bool
	LowerText                  bool
}

DefaultOptionsBot represents the options that the bot will try to apply automatically

type DeleteChatPhotoConditionalCall

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

DeleteChatPhotoConditionalCall ...

type Document

type Document struct {
	FileID   string     `json:"file_id"`
	Thumb    *PhotoSize `json:"thumb,omitempty"`
	FileName *string    `json:"file_name,omitempty"`
	MimeType *string    `json:"mime_type,omitempty"`
	FileSize *int       `json:"file_size,omitempty"`
}

Document ...

type DocumentConditionalCall

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

DocumentConditionalCall ...

type ForceReply

type ForceReply struct {
	Force     bool `json:"force_reply"` // always true!
	Selective bool `json:"selective,omitempty"`
}

ForceReply ...

func (ForceReply) ImplementReplyMarkup

func (fr ForceReply) ImplementReplyMarkup()

ImplementReplyMarkup ...

type ForwardConditionalCall

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

ForwardConditionalCall ...

type ForwardMessageQuery

type ForwardMessageQuery struct {
	ChatID     int `json:"chat_id"`
	FromChatID int `json:"from_chat_id"`
	MessageID  int `json:"message_id"`
}

ForwardMessageQuery ...

type GenericSendQuery

type GenericSendQuery struct {
	ChatID           int             `json:"chat_id"`
	Data             interface{}     `json:"data"`
	ReplyToMessageID *int            `json:"reply_to_message_id,omitempty"`
	ReplyMarkup      *ReplyMarkupInt `json:"reply_markup,omitempty"`
}

GenericSendQuery ...

type GetUserProfilePhotosQuery

type GetUserProfilePhotosQuery struct {
	UserID int  `json:"user_id"`
	Offset *int `json:"offset,omitempty"`
	Limit  *int `json:"limit,omitempty"`
}

GetUserProfilePhotosQuery ...

type GroupChat

type GroupChat struct {
	ID    int    `json:"id"`
	Title string `json:"title"`
}

GroupChat ...

type GroupChatCreatedConditionalCall

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

GroupChatCreatedConditionalCall ...

type GroupConditionalCall

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

GroupConditionalCall ...

type ImageConditionalCall

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

ImageConditionalCall ...

type KeyboardLayout

type KeyboardLayout [][]string

KeyboardLayout ...

type LeftParticipantConditionalCall

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

LeftParticipantConditionalCall ...

type Location

type Location struct {
	Longitude float64 `json:"longitude"`
	Latitude  float64 `json:"latitude"`
}

Location ...

type LocationConditionalCall

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

LocationConditionalCall ...

type Message

type Message struct {
	ID                  int          `json:"message_id"`
	From                User         `json:"from"`
	Date                int          `json:"date"`
	Chat                UserGroup    `json:"chat"`
	ForwardFrom         *User        `json:"forward_from,omitempty"`
	ForwardDate         *int         `json:"forward_date,omitempty"`
	ReplyToMessage      *Message     `json:"reply_to_message,omitempty"`
	Text                *string      `json:"text,omitempty"`
	Audio               *Audio       `json:"audio,omitempty"`
	Voice               *Voice       `json:"voice,omitempty"`
	Document            *Document    `json:"document,omitempty"`
	Photo               *[]PhotoSize `json:"photo,omitempty"`
	Sticker             *Sticker     `json:"sticker,omitempty"`
	Video               *Video       `json:"video,omitempty"`
	Caption             *string      `json:"caption,omitempty"`
	Location            *Location    `json:"location,omitempty"`
	NewChatParticipant  *User        `json:"new_chat_participant,omitempty"`
	LeftChatParticipant *User        `json:"left_chat_participant,omitempty"`
	NewChatTitle        *string      `json:"new_chat_title,omitempty"`
	NewChatPhoto        *string      `json:"new_chat_photo,omitempty"`
	DeleteChatPhoto     *bool        `json:"delete_chat_photo,omitempty"`
	GroupChatCreated    *bool        `json:"group_chat_created,omitempty"`
}

Message ...

func (Message) String

func (msg Message) String() string

type MessageWithUpdateID

type MessageWithUpdateID struct {
	Msg      Message `json:"message"`
	UpdateID int     `json:"update_id"`
}

MessageWithUpdateID ...

type MultiRegexCommand

type MultiRegexCommand struct {
	Regex []*regexp.Regexp
	// contains filtered or unexported fields
}

MultiRegexCommand ...

type NewParticipantConditionalCall

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

NewParticipantConditionalCall ...

type NewPhotoConditionalCall

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

NewPhotoConditionalCall ...

type NewTitleConditionalCall

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

NewTitleConditionalCall ...

type ParseModeT

type ParseModeT int
const (
	Markdown ParseModeT = 1 + iota
)

func (ParseModeT) String

func (pa ParseModeT) String() string

type PhotoSize

type PhotoSize struct {
	FileID   string `json:"file_id"`
	Width    int    `json:"width"`
	Height   int    `json:"height"`
	FileSize *int   `json:"file_size,omitempty"`
}

PhotoSize ...

type QuerySendMessage

type QuerySendMessage struct {
	ChatID                int             `json:"chat_id"`
	Text                  string          `json:"text"`
	ParseMode             *string         `json:"parse_mode,omitempty"`
	DisableWebPagePreview *bool           `json:"disable_web_page_preview,omitempty"`
	ReplyToMessageID      *int            `json:"reply_to_message_id,omitempty"`
	ReplyMarkup           *ReplyMarkupInt `json:"reply_markup,omitempty"`
}

QuerySendMessage ...

func (QuerySendMessage) String

func (qsm QuerySendMessage) String() string

type ReaderSender

type ReaderSender struct {
	Read io.Reader
	Name string
}

type RegexCommand

type RegexCommand struct {
	Regex *regexp.Regexp
	// contains filtered or unexported fields
}

RegexCommand ...

type RelicConfig

type RelicConfig struct {
	Token string
	Name  string
}

type RepliedConditionalCall

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

RepliedConditionalCall ...

type ReplyKeyboardHide

type ReplyKeyboardHide struct {
	HideKeyboard bool `json:"hide_keyboard"` // always true!
	Selective    bool `json:"selective,omitempty"`
}

ReplyKeyboardHide ...

func (ReplyKeyboardHide) ImplementReplyMarkup

func (rkh ReplyKeyboardHide) ImplementReplyMarkup()

ImplementReplyMarkup ...

type ReplyKeyboardMarkup

type ReplyKeyboardMarkup struct {
	Keyboard        KeyboardLayout `json:"keyboard"`
	ResizeKeyboard  bool           `json:"resize_keyboard,omitempty"`   // Default false
	OneTimeKeyboard bool           `json:"one_time_keyboard,omitempty"` // Default false
	Selective       bool           `json:"selective,omitempty"`
}

ReplyKeyboardMarkup ...

func (ReplyKeyboardMarkup) ImplementReplyMarkup

func (rkm ReplyKeyboardMarkup) ImplementReplyMarkup()

ImplementReplyMarkup ...

type ReplyMarkupInt

type ReplyMarkupInt interface {
	ImplementReplyMarkup()
}

ReplyMarkupInt ...

type ResultBase

type ResultBase struct {
	Ok          bool    `json:"ok"`
	ErrorCode   *int    `json:"error_code,omitempty"`
	Description *string `json:"description,omitempty"`
}

ResultBase ...

type ResultGetUpdates

type ResultGetUpdates struct {
	ResultBase
	Result []MessageWithUpdateID `json:"result"`
}

ResultGetUpdates ...

type ResultGetUser

type ResultGetUser struct {
	ResultBase
	Result User `json:"result,omitempty"`
}

ResultGetUser ...

type ResultSetWebhook

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

ResultSetWebhook ...

type ResultWithMessage

type ResultWithMessage struct {
	ResultBase
	Result *Message `json:"result,omitempty"`
}

ResultWithMessage ...

type ResultWithUserProfilePhotos

type ResultWithUserProfilePhotos struct {
	ResultBase
	Result *UserProfilePhotos `json:"result,omitempty"`
}

ResultWithUserProfilePhotos ...

type Send

type Send struct {
	ChatID int
	Bot    *TgBot
}

Send general construct to generate send actions

func (*Send) Action

func (s *Send) Action(action ChatAction) *SendChatAction

Action return a SendAction instance to chain actions easy

func (*Send) Audio

func (s *Send) Audio(audio string) *SendAudio

Audio return a SendAudio instance to chain actions easy

func (*Send) Document

func (s *Send) Document(doc interface{}) *SendDocument

Document return a SendDocument instance to chain actions easy

func (*Send) Forward

func (s *Send) Forward(to int, msg int) *SendForward

Forward return a SendForward instance to chain actions easy

func (*Send) Location

func (s *Send) Location(latitude float64, long float64) *SendLocation

Location return a SendLocation instance to chain actions easy

func (*Send) Photo

func (s *Send) Photo(photo interface{}) *SendPhoto

Photo return a SendPhoto instance to chain actions easy

func (*Send) Sticker

func (s *Send) Sticker(stick interface{}) *SendSticker

Sticker return a SendSticker instance to chain actions easy

func (*Send) Text

func (s *Send) Text(text string) *SendText

Text return a SendText instance to chain actions easy

func (*Send) Video

func (s *Send) Video(vid string) *SendVideo

Video return a SendVideo instance to chain actions easy

func (*Send) Voice

func (s *Send) Voice(voice string) *SendVoice

Voice return a SendVoice instance to chain actions easy

type SendAudio

type SendAudio struct {
	Send             *Send
	Audio            string
	DurationField    *int
	PerformerField   *string
	TitleField       *string
	ReplyToMessageID *int
	ReplyMarkup      *ReplyMarkupInt
}

SendAudio ...

func (*SendAudio) Duration

func (sp *SendAudio) Duration(d int) *SendAudio

Duration ...

func (SendAudio) End

func (sp SendAudio) End() ResultWithMessage

End ...

func (*SendAudio) ForceReply

func (sp *SendAudio) ForceReply(fr ForceReply) *SendAudio

ForceReply ...

func (*SendAudio) Keyboard

func (sp *SendAudio) Keyboard(kb ReplyKeyboardMarkup) *SendAudio

Keyboard ...

func (*SendAudio) KeyboardHide

func (sp *SendAudio) KeyboardHide(kb ReplyKeyboardHide) *SendAudio

KeyboardHide ...

func (*SendAudio) Performer

func (sp *SendAudio) Performer(p string) *SendAudio

Performer ...

func (*SendAudio) ReplyToMessage

func (sp *SendAudio) ReplyToMessage(rm int) *SendAudio

ReplyToMessage ...

func (*SendAudio) Title

func (sp *SendAudio) Title(d string) *SendAudio

Title ...

type SendAudioIDQuery

type SendAudioIDQuery struct {
	ChatID           int             `json:"chat_id"`
	Audio            string          `json:"audio"`
	Duration         *int            `json:"duration,omitempty"`
	Performer        *string         `json:"performer,omitempty"`
	Title            *string         `json:"title,omitempty"`
	ReplyToMessageID *int            `json:"reply_to_message_id,omitempty"`
	ReplyMarkup      *ReplyMarkupInt `json:"reply_markup,omitempty"`
}

SendAudioIDQuery ...

type SendAudioPathQuery

type SendAudioPathQuery struct {
	ChatID           int             `json:"chat_id"`
	Audio            string          `json:"audio"`
	Duration         *int            `json:"duration,omitempty"`
	Performer        *string         `json:"performer,omitempty"`
	Title            *string         `json:"title,omitempty"`
	ReplyToMessageID *int            `json:"reply_to_message_id,omitempty"`
	ReplyMarkup      *ReplyMarkupInt `json:"reply_markup,omitempty"`
}

SendAudioPathQuery ...

type SendChatAction

type SendChatAction struct {
	Send   *Send
	Action ChatAction
}

SendChatAction ...

func (SendChatAction) End

func (sca SendChatAction) End()

End ...

func (*SendChatAction) SetAction

func (sca *SendChatAction) SetAction(act ChatAction) *SendChatAction

SetAction ...

type SendChatActionQuery

type SendChatActionQuery struct {
	ChatID int    `json:"chat_id"`
	Action string `json:"action"`
}

SendChatActionQuery ...

type SendDocument

type SendDocument struct {
	Send             *Send
	Document         interface{}
	ReplyToMessageID *int
	ReplyMarkup      *ReplyMarkupInt
}

SendDocument ...

func (SendDocument) End

End ...

func (*SendDocument) ForceReply

func (sp *SendDocument) ForceReply(fr ForceReply) *SendDocument

ForceReply ...

func (*SendDocument) Keyboard

func (sp *SendDocument) Keyboard(kb ReplyKeyboardMarkup) *SendDocument

Keyboard ...

func (*SendDocument) KeyboardHide

func (sp *SendDocument) KeyboardHide(kb ReplyKeyboardHide) *SendDocument

KeyboardHide ...

func (*SendDocument) ReplyToMessage

func (sp *SendDocument) ReplyToMessage(rm int) *SendDocument

ReplyToMessage ...

type SendDocumentIDQuery

type SendDocumentIDQuery struct {
	ChatID           int             `json:"chat_id"`
	Document         string          `json:"document"`
	ReplyToMessageID *int            `json:"reply_to_message_id,omitempty"`
	ReplyMarkup      *ReplyMarkupInt `json:"reply_markup,omitempty"`
}

SendDocumentIDQuery ...

type SendDocumentPathQuery

type SendDocumentPathQuery struct {
	ChatID           int             `json:"chat_id"`
	Document         string          `json:"document"`
	ReplyToMessageID *int            `json:"reply_to_message_id,omitempty"`
	ReplyMarkup      *ReplyMarkupInt `json:"reply_markup,omitempty"`
}

SendDocumentPathQuery ...

type SendForward

type SendForward struct {
	Send *Send
	// contains filtered or unexported fields
}

SendForward ...

func (*SendForward) End

func (sf *SendForward) End() ResultWithMessage

End ...

type SendLocation

type SendLocation struct {
	Send             *Send
	Latitude         float64
	Longitude        float64
	ReplyToMessageID *int
	ReplyMarkup      *ReplyMarkupInt
}

SendLocation ...

func (SendLocation) End

End ...

func (*SendLocation) ForceReply

func (sp *SendLocation) ForceReply(fr ForceReply) *SendLocation

ForceReply ...

func (*SendLocation) Keyboard

func (sp *SendLocation) Keyboard(kb ReplyKeyboardMarkup) *SendLocation

Keyboard ...

func (*SendLocation) KeyboardHide

func (sp *SendLocation) KeyboardHide(kb ReplyKeyboardHide) *SendLocation

KeyboardHide ...

func (*SendLocation) ReplyToMessage

func (sp *SendLocation) ReplyToMessage(rm int) *SendLocation

ReplyToMessage ...

func (*SendLocation) SetLatitude

func (sp *SendLocation) SetLatitude(lat float64) *SendLocation

SetLatitude ...

func (*SendLocation) SetLongitude

func (sp *SendLocation) SetLongitude(long float64) *SendLocation

SetLongitude ...

type SendLocationQuery

type SendLocationQuery struct {
	ChatID           int             `json:"chat_id"`
	Latitude         float64         `json:"latitude"`
	Longitude        float64         `json:"longitude"`
	ReplyToMessageID *int            `json:"reply_to_message_id,omitempty"`
	ReplyMarkup      *ReplyMarkupInt `json:"reply_markup,omitempty"`
}

SendLocationQuery ...

type SendPhoto

type SendPhoto struct {
	Send             *Send
	Photo            interface{}
	CaptionField     *string
	ReplyToMessageID *int
	ReplyMarkup      *ReplyMarkupInt
}

SendPhoto ...

func (*SendPhoto) Caption

func (sp *SendPhoto) Caption(caption string) *SendPhoto

Caption ...

func (SendPhoto) End

func (sp SendPhoto) End() ResultWithMessage

End ...

func (*SendPhoto) ForceReply

func (sp *SendPhoto) ForceReply(fr ForceReply) *SendPhoto

ForceReply ...

func (*SendPhoto) Keyboard

func (sp *SendPhoto) Keyboard(kb ReplyKeyboardMarkup) *SendPhoto

Keyboard ...

func (*SendPhoto) KeyboardHide

func (sp *SendPhoto) KeyboardHide(kb ReplyKeyboardHide) *SendPhoto

KeyboardHide ...

func (*SendPhoto) ReplyToMessage

func (sp *SendPhoto) ReplyToMessage(rm int) *SendPhoto

ReplyToMessage ...

type SendPhotoIDQuery

type SendPhotoIDQuery struct {
	ChatID           int             `json:"chat_id"`
	Photo            string          `json:"photo"`
	Caption          *string         `json:"caption,omitempty"`
	ReplyToMessageID *int            `json:"reply_to_message_id,omitempty"`
	ReplyMarkup      *ReplyMarkupInt `json:"reply_markup,omitempty"`
}

SendPhotoIDQuery ...

type SendPhotoPathQuery

type SendPhotoPathQuery struct {
	ChatID           int             `json:"chat_id"`
	Photo            string          `json:"photo"`
	Caption          *string         `json:"caption,omitempty"`
	ReplyToMessageID *int            `json:"reply_to_message_id,omitempty"`
	ReplyMarkup      *ReplyMarkupInt `json:"reply_markup,omitempty"`
}

SendPhotoPathQuery ...

type SendSticker

type SendSticker struct {
	Send             *Send
	Sticker          interface{}
	ReplyToMessageID *int
	ReplyMarkup      *ReplyMarkupInt
}

SendSticker ...

func (SendSticker) End

func (sp SendSticker) End() ResultWithMessage

End ...

func (*SendSticker) ForceReply

func (sp *SendSticker) ForceReply(fr ForceReply) *SendSticker

ForceReply ...

func (*SendSticker) Keyboard

func (sp *SendSticker) Keyboard(kb ReplyKeyboardMarkup) *SendSticker

Keyboard ...

func (*SendSticker) KeyboardHide

func (sp *SendSticker) KeyboardHide(kb ReplyKeyboardHide) *SendSticker

KeyboardHide ...

func (*SendSticker) ReplyToMessage

func (sp *SendSticker) ReplyToMessage(rm int) *SendSticker

ReplyToMessage ...

type SendStickerIDQuery

type SendStickerIDQuery struct {
	ChatID           int             `json:"chat_id"`
	Sticker          string          `json:"sticker"`
	ReplyToMessageID *int            `json:"reply_to_message_id,omitempty"`
	ReplyMarkup      *ReplyMarkupInt `json:"reply_markup,omitempty"`
}

SendStickerIDQuery ...

type SendStickerPathQuery

type SendStickerPathQuery struct {
	ChatID           int             `json:"chat_id"`
	Sticker          string          `json:"sticker"`
	ReplyToMessageID *int            `json:"reply_to_message_id,omitempty"`
	ReplyMarkup      *ReplyMarkupInt `json:"reply_markup,omitempty"`
}

SendStickerPathQuery ...

type SendText

type SendText struct {
	Send                  *Send
	Text                  string
	ParseModeS            *ParseModeT
	DisableWebPagePreview *bool
	ReplyToMessageID      *int
	ReplyMarkup           *ReplyMarkupInt
}

SendText ...

func (*SendText) DisablePreview

func (sp *SendText) DisablePreview(disab bool) *SendText

DisablePreview ...

func (SendText) End

func (sp SendText) End() ResultWithMessage

End ...

func (*SendText) ForceReply

func (sp *SendText) ForceReply(fr ForceReply) *SendText

ForceReply ...

func (*SendText) Keyboard

func (sp *SendText) Keyboard(kb ReplyKeyboardMarkup) *SendText

Keyboard ...

func (*SendText) KeyboardHide

func (sp *SendText) KeyboardHide(kb ReplyKeyboardHide) *SendText

KeyboardHide ...

func (*SendText) ParseMode

func (sp *SendText) ParseMode(pm ParseModeT) *SendText

func (*SendText) ReplyToMessage

func (sp *SendText) ReplyToMessage(rm int) *SendText

ReplyToMessage ...

type SendVideo

type SendVideo struct {
	Send             *Send
	Video            string
	CaptionField     *string
	DurationField    *int
	ReplyToMessageID *int
	ReplyMarkup      *ReplyMarkupInt
}

SendVideo ...

func (*SendVideo) Caption

func (sp *SendVideo) Caption(cap string) *SendVideo

Caption ...

func (*SendVideo) Duration

func (sp *SendVideo) Duration(dur int) *SendVideo

Duration ...

func (SendVideo) End

func (sp SendVideo) End() ResultWithMessage

End ...

func (*SendVideo) ForceReply

func (sp *SendVideo) ForceReply(fr ForceReply) *SendVideo

ForceReply ...

func (*SendVideo) Keyboard

func (sp *SendVideo) Keyboard(kb ReplyKeyboardMarkup) *SendVideo

Keyboard ...

func (*SendVideo) KeyboardHide

func (sp *SendVideo) KeyboardHide(kb ReplyKeyboardHide) *SendVideo

KeyboardHide ...

func (*SendVideo) ReplyToMessage

func (sp *SendVideo) ReplyToMessage(rm int) *SendVideo

ReplyToMessage ...

type SendVideoIDQuery

type SendVideoIDQuery struct {
	ChatID           int             `json:"chat_id"`
	Video            string          `json:"video"`
	Duration         *int            `json:"duration,omitempty"`
	Caption          *string         `json:"caption,omitempty"`
	ReplyToMessageID *int            `json:"reply_to_message_id,omitempty"`
	ReplyMarkup      *ReplyMarkupInt `json:"reply_markup,omitempty"`
}

SendVideoIDQuery ...

type SendVideoPathQuery

type SendVideoPathQuery struct {
	ChatID           int             `json:"chat_id"`
	Video            string          `json:"video"`
	Duration         *int            `json:"duration,omitempty"`
	Caption          *string         `json:"caption,omitempty"`
	ReplyToMessageID *int            `json:"reply_to_message_id,omitempty"`
	ReplyMarkup      *ReplyMarkupInt `json:"reply_markup,omitempty"`
}

SendVideoPathQuery ...

type SendVoice

type SendVoice struct {
	Send             *Send
	Voice            string
	DurationField    *int
	ReplyToMessageID *int
	ReplyMarkup      *ReplyMarkupInt
}

SendVoice ...

func (*SendVoice) Duration

func (sp *SendVoice) Duration(d int) *SendVoice

Duration ...

func (SendVoice) End

func (sp SendVoice) End() ResultWithMessage

End ...

func (*SendVoice) ForceReply

func (sp *SendVoice) ForceReply(fr ForceReply) *SendVoice

ForceReply ...

func (*SendVoice) Keyboard

func (sp *SendVoice) Keyboard(kb ReplyKeyboardMarkup) *SendVoice

Keyboard ...

func (*SendVoice) KeyboardHide

func (sp *SendVoice) KeyboardHide(kb ReplyKeyboardHide) *SendVoice

KeyboardHide ...

func (*SendVoice) ReplyToMessage

func (sp *SendVoice) ReplyToMessage(rm int) *SendVoice

ReplyToMessage ...

type SendVoiceIDQuery

type SendVoiceIDQuery struct {
	ChatID           int             `json:"chat_id"`
	Voice            string          `json:"voice"`
	Duration         *int            `json:"duration,omitempty"`
	ReplyToMessageID *int            `json:"reply_to_message_id,omitempty"`
	ReplyMarkup      *ReplyMarkupInt `json:"reply_markup,omitempty"`
}

SendVoiceIDQuery ...

type SendVoicePathQuery

type SendVoicePathQuery struct {
	ChatID           int             `json:"chat_id"`
	Voice            string          `json:"voice"`
	Duration         *int            `json:"duration,omitempty"`
	ReplyToMessageID *int            `json:"reply_to_message_id,omitempty"`
	ReplyMarkup      *ReplyMarkupInt `json:"reply_markup,omitempty"`
}

SendVoicePathQuery ...

type SetWebhookCertQuery

type SetWebhookCertQuery struct {
	URL         string `json:"url,omitempty"`
	Certificate string `json:"certificate,omitempty"`
}

SetWebhookCertQuery ...

type SetWebhookQuery

type SetWebhookQuery struct {
	URL *string `json:"url,omitempty"`
}

SetWebhookQuery ...

type SimpleCommandFuncStruct

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

SimpleCommandFuncStruct struct wrapper for simple command funcs

func (SimpleCommandFuncStruct) CallSimpleCommandFunc

func (scf SimpleCommandFuncStruct) CallSimpleCommandFunc(bot TgBot, msg Message, m []string, km map[string]string) *string

CallSimpleCommandFunc wrapper for simple functions

type Sticker

type Sticker struct {
	FileID   string     `json:"file_id"`
	Width    int        `json:"width"`
	Height   int        `json:"height"`
	Thumb    *PhotoSize `json:"thumb,omitempty"` // .webp or .jpg format
	FileSize *int       `json:"file_size,omitempty"`
}

Sticker ...

type StickerConditionalCall

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

StickerConditionalCall ...

type TextConditionalCall

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

TextConditionalCall ...

type TgBot

type TgBot struct {
	Token                string
	FirstName            string
	ID                   int
	Username             string
	BaseRequestURL       string
	RelicCfg             *RelicConfig
	BotanIO              *botan.Botan
	MainListener         chan MessageWithUpdateID
	LastUpdateID         int64
	TestConditionalFuncs []ConditionCallStructure
	ChainConditionals    []*ChainStructure
	BuildingChain        bool
	DefaultOptions       DefaultOptionsBot
}

TgBot basic bot struct that handle all the interaction functions.

func New

func New(token string) *TgBot

New creates an instance of a new bot with the token supplied, if it's invalid this method fail with a panic.

func NewTgBot

func NewTgBot(token string) *TgBot

NewTgBot creates an instance of a new bot with the token supplied, if it's invalid this method fail with a panic.

func NewWithError

func NewWithError(token string) (*TgBot, error)

NewWithError creates an instance and return possible error

func (*TgBot) AddMainListener

func (bot *TgBot) AddMainListener(list chan MessageWithUpdateID)

AddMainListener add the channel as the main listener, this will be called with the messages received.

func (*TgBot) Answer

func (bot *TgBot) Answer(msg Message) *Send

Answer start a Send petition answering the message. See Send* structs (SendPhoto, SendText, ...)

func (*TgBot) AnyMsgFn

func (bot *TgBot) AnyMsgFn(f func(TgBot, Message)) *TgBot

AnyMsgFn add a function to be called in every message :)

func (*TgBot) AudioFn

func (bot *TgBot) AudioFn(f func(TgBot, Message, Audio, string)) *TgBot

AudioFn add a function to be called when an audio arrives.

func (*TgBot) CancelChainCommand

func (bot *TgBot) CancelChainCommand(path string, f func(TgBot, Message, string) *string) *TgBot

CancelChainCommand add a special command that cancel the current chain

func (*TgBot) CommandFn

func (bot *TgBot) CommandFn(path string, f func(TgBot, Message, []string, map[string]string) *string) *TgBot

CommandFn Add a command function, with capture groups and/or named capture groups.

func (*TgBot) CustomFn

func (bot *TgBot) CustomFn(cond func(TgBot, Message) bool, f func(TgBot, Message)) *TgBot

CustomFn add a function to be called with a custom conditional function.

func (*TgBot) DefaultAllowWithoutSlashInMention

func (bot *TgBot) DefaultAllowWithoutSlashInMention(b bool) *TgBot

DefaultAllowWithoutSlashInMention ...

func (*TgBot) DefaultCleanInitialUsername

func (bot *TgBot) DefaultCleanInitialUsername(b bool) *TgBot

DefaultCleanInitialUsername ...

func (*TgBot) DefaultDisableWebpagePreview

func (bot *TgBot) DefaultDisableWebpagePreview(b bool) *TgBot

DefaultDisableWebpagePreview ...

func (*TgBot) DefaultOneTimeKeyboard

func (bot *TgBot) DefaultOneTimeKeyboard(b bool) *TgBot

DefaultOneTimeKeyboard ...

func (*TgBot) DefaultSelective

func (bot *TgBot) DefaultSelective(b bool) *TgBot

DefaultSelective ...

func (*TgBot) DeleteChatPhotoFn

func (bot *TgBot) DeleteChatPhotoFn(f func(TgBot, Message, int)) *TgBot

DeleteChatPhotoFn add a function to be called when the photo of a chat is deleted.

func (*TgBot) DocumentFn

func (bot *TgBot) DocumentFn(f func(TgBot, Message, Document, string)) *TgBot

DocumentFn add a function to be called when a document arrives.

func (*TgBot) EndChain

func (bot *TgBot) EndChain() *TgBot

EndChain ends the chain, after this, the functions will be added as always.

func (*TgBot) ForwardFn

func (bot *TgBot) ForwardFn(f func(TgBot, Message, User, int)) *TgBot

ForwardFn add a function to be called when a message forwarding other arrives.

func (TgBot) ForwardMessage

func (bot TgBot) ForwardMessage(cid int, fid int, mid int) ResultWithMessage

ForwardMessage full function wrapper for forwardMessage

func (TgBot) ForwardMessageQuery

func (bot TgBot) ForwardMessageQuery(payload ForwardMessageQuery) ResultWithMessage

ForwardMessageQuery full forwardMessage call

func (TgBot) GetMe

func (bot TgBot) GetMe() (User, error)

GetMe Call getMe path

func (*TgBot) GetMessageChannel

func (bot *TgBot) GetMessageChannel() chan MessageWithUpdateID

GetMessageChannel create a channel and start the default messages handler, you can use this to build your own server listener (just send the MessageWithUpdateID to that channel)

func (TgBot) GetUpdates

func (bot TgBot) GetUpdates() ([]MessageWithUpdateID, error)

GetUpdates call getUpdates

func (TgBot) GetUserProfilePhotos

func (bot TgBot) GetUserProfilePhotos(uid int, args ...int) UserProfilePhotos

GetUserProfilePhotos args will use only the two first parameters, the first one will be the limit of images to get, and the second will be the offset photo id.

func (TgBot) GetUserProfilePhotosQuery

func (bot TgBot) GetUserProfilePhotosQuery(quer GetUserProfilePhotosQuery) ResultWithUserProfilePhotos

GetUserProfilePhotosQuery raw method that uses the struct to send the petition.

func (*TgBot) GroupChatCreatedFn

func (bot *TgBot) GroupChatCreatedFn(f func(TgBot, Message, int)) *TgBot

GroupChatCreatedFn add a function to be called when a group chat is created.

func (*TgBot) GroupFn

func (bot *TgBot) GroupFn(f func(TgBot, Message, int, string)) *TgBot

GroupFn add a function to be called in every group message.

func (TgBot) HandleBotan

func (bot TgBot) HandleBotan(msg Message)

func (*TgBot) ImageFn

func (bot *TgBot) ImageFn(f func(TgBot, Message, []PhotoSize, string)) *TgBot

ImageFn add a function to be called when an image arrives.

func (*TgBot) LeftParticipantFn

func (bot *TgBot) LeftParticipantFn(f func(TgBot, Message, int, User)) *TgBot

LeftParticipantFn add a function to be called when a participant left.

func (*TgBot) LocationFn

func (bot *TgBot) LocationFn(f func(TgBot, Message, float64, float64)) *TgBot

LocationFn add a function to be called when a location arrives.

func (*TgBot) LoopChain

func (bot *TgBot) LoopChain() *TgBot

LoopChain will make the chain start again when the last action is done.

func (TgBot) MessagesHandler

func (bot TgBot) MessagesHandler(Incoming <-chan MessageWithUpdateID)

MessagesHandler is the default listener, just listen for a channel and call the default message processor

func (*TgBot) MultiCommandFn

func (bot *TgBot) MultiCommandFn(paths []string, f func(TgBot, Message, []string, map[string]string) *string) *TgBot

MultiCommandFn add multiples commands with capture groups. Only one of this will be executed.

func (*TgBot) MultiRegexFn

func (bot *TgBot) MultiRegexFn(paths []string, f func(TgBot, Message, []string, map[string]string) *string) *TgBot

MultiRegexFn add multiples regular expressions with capture groups. Only one will be executed.

func (*TgBot) NewParticipantFn

func (bot *TgBot) NewParticipantFn(f func(TgBot, Message, int, User)) *TgBot

NewParticipantFn add a function to be called when new participant is received.

func (*TgBot) NewPhotoChatFn

func (bot *TgBot) NewPhotoChatFn(f func(TgBot, Message, int, string)) *TgBot

NewPhotoChatFn add a function to be called when the photo of a chat is changed.

func (*TgBot) NewTitleChatFn

func (bot *TgBot) NewTitleChatFn(f func(TgBot, Message, int, string)) *TgBot

NewTitleChatFn add a function to be called when the title of a group is changed.

func (TgBot) ProcessAllMsg

func (bot TgBot) ProcessAllMsg(msg Message)

ProcessAllMsg default message handler that take care of clean the messages, the chains and the action functions.

func (*TgBot) ProcessMessages

func (bot *TgBot) ProcessMessages(messages []MessageWithUpdateID)

ProcessMessages will take care about the highest message ID to get updates in the right way. This will call the MainListener channel with a MessageWithUpdateID

func (*TgBot) RegexFn

func (bot *TgBot) RegexFn(path string, f func(TgBot, Message, []string, map[string]string) *string) *TgBot

RegexFn add a regular expression function with capture groups and/or named capture groups.

func (*TgBot) ReplyFn

func (bot *TgBot) ReplyFn(f func(TgBot, Message, Message)) *TgBot

ReplyFn add a function to be called when a message replied other is arrives.

func (*TgBot) Send

func (bot *TgBot) Send(cid int) *Send

Send start a Send petition to the user/chat cid. See Send* structs (SendPhoto, SendVideo, ...)

func (TgBot) SendAudio

func (bot TgBot) SendAudio(cid int, audio string, duration *int, performer *string, title *string, rmi *int, rm *ReplyMarkupInt) ResultWithMessage

SendAudio full function to send an audio. Uses the reply markup interface.

func (TgBot) SendAudioQuery

func (bot TgBot) SendAudioQuery(payload interface{}) ResultWithMessage

SendAudioQuery full function using the query.

func (TgBot) SendAudioWithForceReply

func (bot TgBot) SendAudioWithForceReply(cid int, audio string, duration *int, performer *string, title *string, rmi *int, rm ForceReply) ResultWithMessage

SendAudioWithForceReply send a audio with explicit Force Reply.

func (TgBot) SendAudioWithKeyboard

func (bot TgBot) SendAudioWithKeyboard(cid int, audio string, duration *int, performer *string, title *string, rmi *int, rm ReplyKeyboardMarkup) ResultWithMessage

SendAudioWithKeyboard send a audio with explicit Keyboard

func (TgBot) SendAudioWithKeyboardHide

func (bot TgBot) SendAudioWithKeyboardHide(cid int, audio string, duration *int, performer *string, title *string, rmi *int, rm ReplyKeyboardHide) ResultWithMessage

SendAudioWithKeyboardHide send a audio with explicit Keyboard Hide.

func (TgBot) SendChatAction

func (bot TgBot) SendChatAction(cid int, ca ChatAction)

SendChatAction send an action to an id.

func (TgBot) SendChatActionQuery

func (bot TgBot) SendChatActionQuery(payload SendChatActionQuery)

SendChatActionQuery send an action query.

func (TgBot) SendDocument

func (bot TgBot) SendDocument(cid int, document interface{}, rmi *int, rm *ReplyMarkupInt) ResultWithMessage

SendDocument full function to send document, uses the reply markup interface.

func (TgBot) SendDocumentQuery

func (bot TgBot) SendDocumentQuery(payload interface{}) ResultWithMessage

SendDocumentQuery full function using the query.

func (TgBot) SendDocumentWithForceReply

func (bot TgBot) SendDocumentWithForceReply(cid int, document string, rmi *int, rm ForceReply) ResultWithMessage

SendDocumentWithForceReply send a document with explicit force reply

func (TgBot) SendDocumentWithKeyboard

func (bot TgBot) SendDocumentWithKeyboard(cid int, document string, rmi *int, rm ReplyKeyboardMarkup) ResultWithMessage

SendDocumentWithKeyboard send a document with explicit keyboard.

func (TgBot) SendDocumentWithKeyboardHide

func (bot TgBot) SendDocumentWithKeyboardHide(cid int, document string, rmi *int, rm ReplyKeyboardHide) ResultWithMessage

SendDocumentWithKeyboardHide send a document with explicit keyboard hide.

func (TgBot) SendLocation

func (bot TgBot) SendLocation(cid int, latitude float64, longitude float64, rtmid *int, rm *ReplyMarkupInt) ResultWithMessage

SendLocation full function wrapper for sendLocation

func (TgBot) SendLocationQuery

func (bot TgBot) SendLocationQuery(payload SendLocationQuery) ResultWithMessage

SendLocationQuery full sendLocation call with query.

func (TgBot) SendLocationWithForceReply

func (bot TgBot) SendLocationWithForceReply(cid int, latitude float64, longitude float64, rtmid *int, rm ForceReply) ResultWithMessage

SendLocationWithForceReply send a location with explicit force reply.

func (TgBot) SendLocationWithKeyboard

func (bot TgBot) SendLocationWithKeyboard(cid int, latitude float64, longitude float64, rtmid *int, rm ReplyKeyboardMarkup) ResultWithMessage

SendLocationWithKeyboard send a location with explicit keyboard.

func (TgBot) SendLocationWithKeyboardHide

func (bot TgBot) SendLocationWithKeyboardHide(cid int, latitude float64, longitude float64, rtmid *int, rm ReplyKeyboardHide) ResultWithMessage

SendLocationWithKeyboardHide send a location with explicit keyboard hide.

func (TgBot) SendMessage

func (bot TgBot) SendMessage(cid int, text string, parsemode *ParseModeT, dwp *bool, rtmid *int, rm *ReplyMarkupInt) ResultWithMessage

SendMessage full function wrapper for sendMessage, uses the markup interface

func (TgBot) SendMessageQuery

func (bot TgBot) SendMessageQuery(payload QuerySendMessage) ResultWithMessage

SendMessageQuery full sendMessage with the query.

func (TgBot) SendMessageWithForceReply

func (bot TgBot) SendMessageWithForceReply(cid int, text string, parsemode *ParseModeT, dwp *bool, rtmid *int, rm ForceReply) ResultWithMessage

SendMessageWithForceReply send a message with explicit Force Reply.

func (TgBot) SendMessageWithKeyboard

func (bot TgBot) SendMessageWithKeyboard(cid int, text string, parsemode *ParseModeT, dwp *bool, rtmid *int, rm ReplyKeyboardMarkup) ResultWithMessage

SendMessageWithKeyboard send a message with explicit Keyboard

func (TgBot) SendMessageWithKeyboardHide

func (bot TgBot) SendMessageWithKeyboardHide(cid int, text string, parsemode *ParseModeT, dwp *bool, rtmid *int, rm ReplyKeyboardHide) ResultWithMessage

SendMessageWithKeyboardHide send a message with explicit Keyboard Hide.

func (TgBot) SendPhoto

func (bot TgBot) SendPhoto(cid int, photo interface{}, caption *string, rmi *int, rm *ReplyMarkupInt) ResultWithMessage

SendPhoto full function wrapper for sendPhoto, use the markup interface.

func (TgBot) SendPhotoQuery

func (bot TgBot) SendPhotoQuery(payload interface{}) ResultWithMessage

SendPhotoQuery full function that uses the query.

func (TgBot) SendPhotoWithForceReply

func (bot TgBot) SendPhotoWithForceReply(cid int, photo interface{}, caption *string, rmi *int, rm ForceReply) ResultWithMessage

SendPhotoWithForceReply send a photo with explicit Force Reply.

func (TgBot) SendPhotoWithKeyboard

func (bot TgBot) SendPhotoWithKeyboard(cid int, photo interface{}, caption *string, rmi *int, rm ReplyKeyboardMarkup) ResultWithMessage

SendPhotoWithKeyboard send a photo with explicit Keyboard

func (TgBot) SendPhotoWithKeyboardHide

func (bot TgBot) SendPhotoWithKeyboardHide(cid int, photo interface{}, caption *string, rmi *int, rm ReplyKeyboardHide) ResultWithMessage

SendPhotoWithKeyboardHide send a photo with explicit Keyboard Hide.

func (TgBot) SendSticker

func (bot TgBot) SendSticker(cid int, sticker interface{}, rmi *int, rm *ReplyMarkupInt) ResultWithMessage

SendSticker full function to send a sticker, uses reply markup interface.

func (TgBot) SendStickerQuery

func (bot TgBot) SendStickerQuery(payload interface{}) ResultWithMessage

SendStickerQuery full function to send an sticker, uses the query.

func (TgBot) SendStickerWithForceReply

func (bot TgBot) SendStickerWithForceReply(cid int, sticker interface{}, rmi *int, rm ForceReply) ResultWithMessage

SendStickerWithForceReply send a sticker with explicit force reply.

func (TgBot) SendStickerWithKeyboard

func (bot TgBot) SendStickerWithKeyboard(cid int, sticker interface{}, rmi *int, rm ReplyKeyboardMarkup) ResultWithMessage

SendStickerWithKeyboard send a sticker with explicit keyboard.

func (TgBot) SendStickerWithKeyboardHide

func (bot TgBot) SendStickerWithKeyboardHide(cid int, sticker interface{}, rmi *int, rm ReplyKeyboardHide) ResultWithMessage

SendStickerWithKeyboardHide send a sticker with explicit keyboad hide.

func (TgBot) SendVideo

func (bot TgBot) SendVideo(cid int, photo string, caption *string, duration *int, rmi *int, rm *ReplyMarkupInt) ResultWithMessage

SendVideo full function to send a video.

func (TgBot) SendVideoQuery

func (bot TgBot) SendVideoQuery(payload interface{}) ResultWithMessage

SendVideoQuery full function to send video with query.

func (TgBot) SendVideoWithForceReply

func (bot TgBot) SendVideoWithForceReply(cid int, photo string, caption *string, duration *int, rmi *int, rm ForceReply) ResultWithMessage

SendVideoWithForceReply send a video with explicit force reply.

func (TgBot) SendVideoWithKeyboard

func (bot TgBot) SendVideoWithKeyboard(cid int, photo string, caption *string, duration *int, rmi *int, rm ReplyKeyboardMarkup) ResultWithMessage

SendVideoWithKeyboard send a video with explicit keyboard.

func (TgBot) SendVideoWithKeyboardHide

func (bot TgBot) SendVideoWithKeyboardHide(cid int, photo string, caption *string, duration *int, rmi *int, rm ReplyKeyboardHide) ResultWithMessage

SendVideoWithKeyboardHide send a video with explici keyboard hide.

func (TgBot) SendVoice

func (bot TgBot) SendVoice(cid int, audio string, duration *int, rmi *int, rm *ReplyMarkupInt) ResultWithMessage

SendVoice full function to send an audio. Uses the reply markup interface.

func (TgBot) SendVoiceQuery

func (bot TgBot) SendVoiceQuery(payload interface{}) ResultWithMessage

SendVoiceQuery full function using the query.

func (TgBot) SendVoiceWithForceReply

func (bot TgBot) SendVoiceWithForceReply(cid int, audio string, duration *int, rmi *int, rm ForceReply) ResultWithMessage

SendVoiceWithForceReply send a audio with explicit Force Reply.

func (TgBot) SendVoiceWithKeyboard

func (bot TgBot) SendVoiceWithKeyboard(cid int, audio string, duration *int, rmi *int, rm ReplyKeyboardMarkup) ResultWithMessage

SendVoiceWithKeyboard send a audio with explicit Keyboard

func (TgBot) SendVoiceWithKeyboardHide

func (bot TgBot) SendVoiceWithKeyboardHide(cid int, audio string, duration *int, rmi *int, rm ReplyKeyboardHide) ResultWithMessage

SendVoiceWithKeyboardHide send a audio with explicit Keyboard Hide.

func (*TgBot) ServerStart

func (bot *TgBot) ServerStart(uri string, pathl string)

ServerStart starts a server that listen for updates, if uri parameter is not empty string, it will try to set the proper webhook The default server uses Martini classic, and listen in POST /<pathl>/token (The token without the :) To listen it runs the Martini.Run() method, that get $HOST and $PORT from the environment, or uses locashost/3000 if not setted.

func (*TgBot) ServerStartHostPort

func (bot *TgBot) ServerStartHostPort(uri string, pathl string, host string, port string)

func (*TgBot) SetBotanToken

func (bot *TgBot) SetBotanToken(tok string) *TgBot

func (*TgBot) SetLowerText

func (bot *TgBot) SetLowerText(b bool) *TgBot

func (*TgBot) SetRelicConfig

func (bot *TgBot) SetRelicConfig(tok string, name string) *TgBot

func (TgBot) SetWebhook

func (bot TgBot) SetWebhook(url string) (ResultSetWebhook, error)

SetWebhook call the setWebhook API method with the URL suplied, will return the result or an error (the error will be sended if the webhook can't be setted)

func (TgBot) SetWebhookNoQuery

func (bot TgBot) SetWebhookNoQuery(urlw string) ResultSetWebhook

SetWebhookNoQuery ...

func (TgBot) SetWebhookQuery

func (bot TgBot) SetWebhookQuery(url *string, cert *string) ResultSetWebhook

SetWebhookQuery raw method that uses the struct to send the petition.

func (TgBot) SetWebhookWithCert

func (bot TgBot) SetWebhookWithCert(url string, cert string) ResultSetWebhook

SetWebhookWithCert ...

func (*TgBot) SimpleCommandFn

func (bot *TgBot) SimpleCommandFn(path string, f func(TgBot, Message, string) *string) *TgBot

SimpleCommandFn Add a simple command function.

func (*TgBot) SimpleRegexFn

func (bot *TgBot) SimpleRegexFn(path string, f func(TgBot, Message, string) *string) *TgBot

SimpleRegexFn add a simple regular expression function.

func (TgBot) SimpleSendAudio

func (bot TgBot) SimpleSendAudio(msg Message, audio string) (res Message, err error)

SimpleSendAudio send just an audio

func (TgBot) SimpleSendChatAction

func (bot TgBot) SimpleSendChatAction(msg Message, ca ChatAction)

SimpleSendChatAction just send an action answering a message.

func (TgBot) SimpleSendDocument

func (bot TgBot) SimpleSendDocument(msg Message, document string) (res Message, err error)

SimpleSendDocument send just a document.

func (TgBot) SimpleSendLocation

func (bot TgBot) SimpleSendLocation(msg Message, latitude float64, longitude float64) (res Message, err error)

SimpleSendLocation just send a location.

func (TgBot) SimpleSendMessage

func (bot TgBot) SimpleSendMessage(msg Message, text string) (res Message, err error)

SimpleSendMessage send a simple text message.

func (TgBot) SimpleSendPhoto

func (bot TgBot) SimpleSendPhoto(msg Message, photo interface{}) (res Message, err error)

SimpleSendPhoto send just a photo.

func (TgBot) SimpleSendSticker

func (bot TgBot) SimpleSendSticker(msg Message, sticker interface{}) (res Message, err error)

SimpleSendSticker just send a sticker!!

func (TgBot) SimpleSendVideo

func (bot TgBot) SimpleSendVideo(msg Message, photo string) (res Message, err error)

SimpleSendVideo just send a video from file path or id

func (TgBot) SimpleSendVoice

func (bot TgBot) SimpleSendVoice(msg Message, audio string) (res Message, err error)

SimpleSendVoice send just an audio

func (*TgBot) SimpleStart

func (bot *TgBot) SimpleStart()

SimpleStart will start to get updates with the default listener and callbacks (with long-polling getUpdates way)

func (*TgBot) Start

func (bot *TgBot) Start()

Start will start the main process (that use the MainListener channel), it uses getUpdates with longs-polling way and handle the ID

func (*TgBot) StartChain

func (bot *TgBot) StartChain() *TgBot

StartChain will start a chain process, all the functions you add after this will be part of the same chain.

func (*TgBot) StartMainListener

func (bot *TgBot) StartMainListener()

StartMainListener will run a start a new channel and start the default message handler, assigning it to the main listener.

func (*TgBot) StartWithMessagesChannel

func (bot *TgBot) StartWithMessagesChannel(ch chan MessageWithUpdateID)

StartWithMessagesChannel will start to get updates with your own channel that handle the messages (with long-polling getUpdates way)

func (*TgBot) StickerFn

func (bot *TgBot) StickerFn(f func(TgBot, Message, Sticker, string)) *TgBot

StickerFn add a function to be called when a sticker arrives.

func (*TgBot) VideoFn

func (bot *TgBot) VideoFn(f func(TgBot, Message, Video, string)) *TgBot

VideoFn add a function to be called when a video arrives.

func (*TgBot) VoiceFn

func (bot *TgBot) VoiceFn(f func(TgBot, Message, Voice, string)) *TgBot

VoiceFn add a function to be called when an audio arrives.

type User

type User struct {
	ID        int     `json:"id"`
	FirstName string  `json:"first_name"`
	LastName  *string `json:"last_name,omitempty"`
	Username  *string `json:"username,omitempty"`
}

User ...

func (User) String

func (user User) String() string

type UserGroup

type UserGroup struct {
	ID        int     `json:"id"`
	FirstName *string `json:"first_name,omitempty"`
	LastName  *string `json:"last_name,omitempty"`
	Username  *string `json:"username,omitempty"`
	Title     *string `json:"title,omitempty"`
}

UserGroup ..

type UserPhotos

type UserPhotos [][]PhotoSize

UserPhotos ...

type UserProfilePhotos

type UserProfilePhotos struct {
	TotalCount int        `json:"total_count"`
	Photos     UserPhotos `json:"photos"`
}

UserProfilePhotos ...

type Video

type Video struct {
	FileID   string     `json:"file_id"`
	Width    int        `json:"width"`
	Height   int        `json:"height"`
	Duration int        `json:"duration"`
	Thumb    *PhotoSize `json:"thumb,omitempty"`
	MimeType *string    `json:"mime_type,omitempty"`
	FileSize *int       `json:"file_size,omitempty"`
}

Video ...

type VideoConditionalCall

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

VideoConditionalCall ...

type Voice

type Voice struct {
	FileID   string  `json:"file_id"`
	Duration int     `json:"duration"`
	MimeType *string `json:"mime_type,omitempty"`
	FileSize *int    `json:"file_size,omitempty"`
}

Voice ...

type VoiceConditionalCall

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

VoiceConditionalCall ...

Directories

Path Synopsis
example

Jump to

Keyboard shortcuts

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