support

package
v0.0.0-...-f657942 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2017 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetPageTitle

func GetPageTitle(pageURL string) (string, error)

GetPageTitle returns the <title> of a given page

func ValidateURL

func ValidateURL(pageURL string) (string, error)

ValidateURL validates an URL

Types

type BotInfo

type BotInfo struct {
	Ok     bool `json:"ok"`
	Result User `json:"result"`
}

BotInfo contains informations about the bot

func (*BotInfo) DecodeJSON

func (u *BotInfo) DecodeJSON(r io.ReadCloser) error

DecodeJSON decodes some JSON into a BotInfo

type Chat

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

Chat telegram data structure

type ConfigFile

type ConfigFile struct {
	CertPath    string `json:"cert_path"`
	KeyPath     string `json:"key_path"`
	URL         string `json:"url"`
	Endpoint    string `json:"endpoint"`
	BotToken    string `json:"bot_token"`
	Port        string `json:"port"`
	GroupHandle string `json:"group_handle"`
}

ConfigFile represents the structure of a configuration file

func CheckConfigFile

func CheckConfigFile() (ConfigFile, error)

CheckConfigFile checks for presence of the config file, then proceeds to its parsing and validation

func (*ConfigFile) DecodeConfigFile

func (c *ConfigFile) DecodeConfigFile(r io.Reader) error

DecodeConfigFile decodes a JSON configuration file into a ConfigFile

type GeneralReply

type GeneralReply struct {
	Ok          bool   `json:"ok"`
	ErrorCode   int    `json:"error_code"`
	Description string `json:"description"`
	Result      Chat   `json:"result"`
}

GeneralReply is any general telegram reply

type JSONData

type JSONData interface {
	DecodeJSON(r io.ReadCloser) error
}

JSONData represents everything that can be decoded to some struct

type Message

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

Message telegram object data structure

type Session

type Session struct {
	Token         string
	Port          string
	Endpoint      string
	URL           string
	Configuration ConfigFile
	ChatID        int
	GroupHandle   string
}

Session is a Telegram bot session

func NewSession

func NewSession() (Session, error)

NewSession returns a new Telegram bot session

func (*Session) GetGroupUniqueID

func (s *Session) GetGroupUniqueID() error

GetGroupUniqueID returns the unique identifier for a given group handle

func (*Session) PrintBotInformations

func (s *Session) PrintBotInformations() error

PrintBotInformations prints some informations about the Bot the session represents

func (*Session) SetupWebHook

func (s *Session) SetupWebHook() error

SetupWebHook setup the Telegram webhook for the running server

type TelegramObject

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

TelegramObject "Update" message model

func (*TelegramObject) DecodeJSON

func (t *TelegramObject) DecodeJSON(r io.ReadCloser) error

DecodeJSON decodes some JSON into a TelegramObject

func (*TelegramObject) ReplyBackToChat

func (t *TelegramObject) ReplyBackToChat(c string) error

ReplyBackToChat replies to the chat referred by Message.Chat.ID

type User

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

User telegram object data struct

func (*User) DecodeJSON

func (u *User) DecodeJSON(r io.ReadCloser) error

DecodeJSON decodes some JSON into a User

Jump to

Keyboard shortcuts

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