telegram

package
v0.0.0-...-522903d Latest Latest
Warning

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

Go to latest
Published: May 9, 2016 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API interface {
	GetMe() (User, error)
	GetUpdates(int) []Update
	ProcessUpdates(chan *Message)
	SendMessage(*SendMessage) (*Message, error)
}

API holds the API methods

func NewAPI

func NewAPI(httpClient HTTPClient, conf Configuration) API

NewAPI creates a new api from a token

type AnswerBack

type AnswerBack struct {
	*Message
	// contains filtered or unexported fields
}

AnswerBack message helper to answer messages

func NewAnswerBack

func NewAnswerBack(message *Message, sender messageSender) *AnswerBack

NewAnswerBack creates a new instance

func (*AnswerBack) Reply

func (answer *AnswerBack) Reply(message string) (*Message, error)

Reply to the sender of the message in the chat it was originated

func (*AnswerBack) Send

func (answer *AnswerBack) Send(message string) (*Message, error)

Send a message back to the chat where it originated

type Chat

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

Chat payload

type Configuration

type Configuration struct {
	Token string
}

Configuration settings

type ForceReply

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

ForceReply show reply interface

type GetUpdates

type GetUpdates struct {
	Offset  int `json:"offset"`
	Timeout int `json:"timeout"`
}

GetUpdates action parameter

type GroupChat

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

GroupChat payload

type HTTPClient

type HTTPClient interface {
	Get(url string) (*http.Response, error)
	Post(url string, bodyType string, body io.Reader) (resp *http.Response, err error)
}

HTTPClient Small interface for http

type Message

type Message struct {
	MessageID      int      `json:"message_id"`
	From           User     `json:"from"`
	Text           string   `json:"text"`
	Date           int      `json:"date"`
	Chat           Chat     `json:"chat"`
	ReplyToMessage *Message `json:"reply_to_message"`
}

Message payload

type ReplyKeyboardHide

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

ReplyKeyboardHide hide the current keyboard

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 custom keyboard with reply options

type Request

type Request interface {
	Call(method string, in interface{}) (*Response, error)
}

Request basic api requester

func NewRequest

func NewRequest(client HTTPClient, baseURL string) Request

NewRequest Create a new request

type Response

type Response struct {
	Ok     bool            `json:"ok"`
	Result json.RawMessage `json:"result"`
}

Response payload

type SendMessage

type SendMessage struct {
	ChatID    int    `json:"chat_id"`
	Text      string `json:"text"`
	ParseMode string `json:"parse_mode"`
	ReplyTo   int    `json:"reply_to_message_id"`
}

SendMessage action parameter

type Update

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

Update payload

type User

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

User payload

Jump to

Keyboard shortcuts

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