telegram

package
v0.0.0-...-c6f5573 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2016 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Audio

type Audio struct{}

Audio is https://core.telegram.org/bots/api#audio

type BotLogic

type BotLogic interface {
	SetIncomingChannel(message <-chan Update)
	SetOutgoingChannel(message chan<- SendMessage)

	Run()
}

BotLogic implements the logic of the bot

type Chat

type Chat struct {
	ID       int64  `json:"id"`
	Type     string `json:"type"`
	Title    string `json:"title"`
	Username string `json:"username"`
	FistName string `json:"first_name"`
	LastName string `json:"last_name"`
}

Chat is https://core.telegram.org/bots/api#chat

type Config

type Config struct {
	Token    string `yaml:"token"`
	BasePath string `yaml:"base-url"`
}

Config holds the configuration for a Telegram bot.

type Contact

type Contact struct {
	PhoneNumber string `json:"phone_number"`
	FistName    string `json:"first_name"`
	LastName    string `json:"last_name"`
	UserID      int64  `json:"user_id"`
}

Contact is https://core.telegram.org/bots/api#contact

type Document

type Document struct{}

Document is https://core.telegram.org/bots/api#document

type ForceReply

type ForceReply struct {
	ForceReply bool `json:"force_reply"`
	Selective  bool `json:"selective"`
}

ForceReply is https://core.telegram.org/bots/api#forcereply

type Location

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

Location is https://core.telegram.org/bots/api#location

type Message

type Message struct {
	MessageID             int64       `json:"message_id"`
	From                  *User       `json:"from"`
	Date                  int64       `json:"date"`
	Chat                  *Chat       `json:"chat"`
	ForwardFrom           *User       `json:"forward_from"`
	ForwardDate           int64       `json:"forward_date"`
	ReplyToMessage        *Message    `json:"reply_to_message"`
	Text                  string      `json:"text"`
	Audio                 *Audio      `json:"audio"`
	Document              *Document   `json:"document"`
	Photo                 []PhotoSize `json:"photo"`
	Sticker               *Sticker    `json:"sticker"`
	Video                 *Video      `json:"video"`
	Voice                 *Voice      `json:"voice"`
	Caption               string      `json:"caption"`
	Contact               *Contact    `json:"contact"`
	Location              *Location   `json:"location"`
	NewChatParticipant    *User       `json:"new_chat_participant"`
	LeftChatParticipant   *User       `json:"left_chat_participant"`
	NewChatTtitle         string      `json:"new_chat_title"`
	NewChatPhoto          []PhotoSize `json:"new_chat_photo"`
	DeleteChatPhoto       bool        `json:"delete_chat_photo"`
	GroupChatCreated      bool        `json:"group_chat_created"`
	SupergroupChatCreated bool        `json:"supergroup_chat_created"`
	ChannelChatCreated    bool        `json:"channel_chat_created"`
	MigrateToChatID       int64       `json:"migrate_to_chat_id"`
	MigrateFromChatID     int64       `json:"migrate_from_chat_id"`
}

Message is https://core.telegram.org/bots/api#message

type PhotoSize

type PhotoSize struct{}

PhotoSize is https://core.telegram.org/bots/api#photosize

type ReplyKeyboardHide

type ReplyKeyboardHide struct {
	HideKeyboard bool `json:"hide_keyboard"`
	Selective    bool `json:"selective"`
}

ReplyKeyboardHide is https://core.telegram.org/bots/api#replykeyboardhide

type ReplyKeyboardMarkup

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

ReplyKeyboardMarkup is https://core.telegram.org/bots/api#replykeyboardmarkup

type SendMessage

type SendMessage struct {
	ChatID                int64       `json:"chat_id"`
	Text                  string      `json:"text"`
	ParseMode             string      `json:"parse_mode"`
	DisableWebPagePreview string      `json:"disable_web_page_preview"`
	ReplyToMessageID      int64       `json:"reply_to_message_id"`
	ReplyMarkup           interface{} `json:"reply_markup"`
}

SendMessage holds the data necessary for the sendMessage API call.

type SetWebhook

type SetWebhook struct {
	URL string `json:"url"`
}

SetWebhook holds the data necessary for the setWebhook API call.

type Sticker

type Sticker struct{}

Sticker is https://core.telegram.org/bots/api#sticker

type Update

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

Update is https://core.telegram.org/bots/api#update

type User

type User struct {
	ID        int64  `json:"id"`
	FirstName string `json:"first_name"`
	LastName  string `json:"last_name"`
	Username  string `json:"username"`
}

User is https://core.telegram.org/bots/api#user

type Video

type Video struct{}

Video is https://core.telegram.org/bots/api#video

type Voice

type Voice struct{}

Voice is https://core.telegram.org/bots/api#voice

type WebhookBot

type WebhookBot struct {
	Token    string
	BasePath string
	// contains filtered or unexported fields
}

WebhookBot is a HTTP server implementing the Telegram bot webhook.

func NewWebhookBot

func NewWebhookBot(config Config, logic BotLogic) *WebhookBot

NewWebhookBot creates a new server.

func (*WebhookBot) Request

func (ws *WebhookBot) Request(method string, data interface{}) error

Request makes a request to the Telegram API.

func (*WebhookBot) Run

func (ws *WebhookBot) Run()

Run runs the server. This method is long-running.

func (*WebhookBot) WebhookHandler

func (ws *WebhookBot) WebhookHandler(w http.ResponseWriter,
	req *http.Request)

WebhookHandler handles a request from the Telegram bot API.

Jump to

Keyboard shortcuts

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