telegram

package
v0.0.0-...-4acabe8 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2016 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const BotURL string = "https://api.telegram.org/bot"

BotURL is url to telegram bot api

Variables

This section is empty.

Functions

This section is empty.

Types

type Audio

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

Audio struct represents an audio file (voice note).

type CommonChat

type CommonChat struct {
	ID int `json:"id"`
}

CommonChat struct is base struct for Chat or User object

type Contact

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

Contact struct represents a phone contact.

type Document

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

Document struct represents a general file (as opposed to photos and audio files).

type GroupChat

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

GroupChat struct represents a group chat.

type Location

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

Location struct represents a point on the map.

type Message

type Message struct {
	MessageID           int         `json:"message_id"`
	From                User        `json:"from"`
	Date                int         `json:"date"`
	Chat                CommonChat  `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"`
	Document            Document    `json:"document,omitempty"`
	Photo               []PhotoSize `json:"photo,omitempty"`
	Sticker             Sticker     `json:"sticker,omitempty"`
	Video               Video       `json:"video,omitempty"`
	Contact             Contact     `json:"contact,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        []PhotoSize `json:"new_chat_photo,omitempty"`
	DeleteChatPhoto     bool        `json:"delete_chat_photo,omitempty"`
	GroupChatCreated    bool        `json:"group_chat_created,omitempty"`
}

Message struct represents a message.

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 struct represents one size of a photo or a file / sticker thumbnail.

type ReplyKeyboardMarkup

type ReplyKeyboardMarkup struct {
	Keyboard        [][]string `json:"keyboard"`
	ResizeKeyboard  bool       `json:"resize_keyboard,omitempty"`
	OneTimeKeyboard bool       `json:"one_time_keyboard,omitempty"`
	Selective       bool       `json:"selective,omitempty"`
}

ReplyKeyboardMarkup struct represents a custom keyboard with reply options.

type Response

type Response struct {
	Response *http.Response
	Ok       bool        `json:"ok"`
	Result   interface{} `json:"result"`
}

Response is telegram base response envelop

type Sticker

type Sticker struct {
	FileID   string    `json:"file_id"`
	Width    int       `json:"width"`
	Height   int       `json:"heiht"`
	Thumb    PhotoSize `json:"thumb"`
	FileSize int       `json:"file_size,omitempty"`
}

Sticker struct

type Telegram

type Telegram struct {
	Key string
	// contains filtered or unexported fields
}

Telegram is struct to store client data

func NewTelegram

func NewTelegram(httpClient *http.Client, key string) *Telegram

NewTelegram is factory method for Telegram struct

func (Telegram) GetMe

func (telegram Telegram) GetMe() (*User, error)

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

func (Telegram) SendMessage

func (telegram Telegram) SendMessage(chatID int, text string, disableWebPagePreview bool, replyToMessageID int, replyMarkup *ReplyKeyboardMarkup) (*Message, error)

SendMessage - Use this method to send text messages

func (Telegram) SendPhoto

func (telegram Telegram) SendPhoto(chatID int, photo image.Image, caption string, replyToMessageID int, replyMarkup *ReplyKeyboardMarkup) (*Message, error)

SendPhoto - Use this method to send photos.

type Update

type Update struct {
	ID      int     `json:"update_id"`
	Message Message `json:"message,omitempty"`
}

Update struct represents an incoming update.

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 struct represents a Telegram user or bot.

type UserProfilePhotos

type UserProfilePhotos struct {
	TotalCount int         `json:"total_count"`
	Photos     []PhotoSize `json:"photos"`
}

UserProfilePhotos struct represents a user's profile pictures.

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"`
	MimeType string    `json:"mime_type,omitempty"`
	FileSize int       `json:"fil_size,omitempty"`
	Caption  string    `json:"caption,omitempty"`
}

Video struct represents a video file.

Jump to

Keyboard shortcuts

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