telegram

package
v0.8.6 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Channel

type Channel struct {
	Client Client
	// contains filtered or unexported fields
}

Channel contains a Telegram client

func New

func New(config Config) *Channel

New returns an initialized Telegram client

func (*Channel) ReceiveMessage

func (c *Channel) ReceiveMessage(body []byte) (*messages.Receive, error)

ReceiveMessage for Telegram

func (*Channel) ReceiveMessages

func (c *Channel) ReceiveMessages(receiveChan chan messages.Receive)

ReceiveMessages uses event queues to receive messages. Starts a long running process

func (*Channel) SendMessage

func (c *Channel) SendMessage(response *messages.Response) error

SendMessage for Telegram

func (*Channel) String added in v0.6.2

func (c *Channel) String() string

func (*Channel) ValidateCallback added in v0.6.0

func (c *Channel) ValidateCallback(r *http.Request) bool

ValidateCallback validates a callback to the channel

type Client

type Client interface {
	Call(method string, params url.Values, v interface{})
}

Client is the Telegram client interface

type Config

type Config struct {
	BotKey string        `mapstructure:"bot_key"`
	Delay  time.Duration `mapstructure:"delay"`
}

Config models Telegram configuration

type MessageIn

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

MessageIn models a Telegram incoming message

type MessageInInner

type MessageInInner struct {
	MessageID int                `json:"message_id"`
	From      MessageInInnerFrom `json:"from"`
	Date      int                `json:"date"`
	Text      string             `json:"text"`
}

MessageInInner models a Telegram incoming message inner struct

type MessageInInnerFrom

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

MessageInInnerFrom models a Telegram incoming message inner struct

Directories

Path Synopsis
Package mocktelegram is a generated GoMock package.
Package mocktelegram is a generated GoMock package.

Jump to

Keyboard shortcuts

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