telegram

package
Version: v0.0.0-...-89493d8 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2018 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// TgMessageTypeRegular is 'message'
	TgMessageTypeRegular = "message"

	// TgMessageTypeEdited is 'edited_message'
	TgMessageTypeEdited = "edited_message"

	// TgMessageTypeChannelPost is 'channel_post'
	TgMessageTypeChannelPost = "channel_post"

	// TgMessageTypeEditedChannelPost is 'edited_channel_post'
	TgMessageTypeEditedChannelPost = "edited_channel_post"
)
View Source
const ChatInstanceKind = "TgChatInstance"

ChatInstanceKind is kind name of TgChatInstance entity

View Source
const (
	// ChatKind is kind name of Telegram chat entity
	ChatKind = "TgChat"
)
View Source
const PlatformID = "telegram"

PlatformID is 'telegram'

View Source
const (
	// TgUserKind is kind name for Telegram user entity
	TgUserKind = "TgUser"
)

Variables

View Source
var CallbackCurrent bots.MessageUID = &callbackCurrent{}

CallbackCurrent is what?

View Source
var DAL dal

DAL is data access layer

View Source
var NewChatInstanceEntity func() ChatInstanceEntity

NewChatInstanceEntity is pointer to func() ChatInstanceEntity

Functions

func EditMessageOnCallbackQuery

func EditMessageOnCallbackQuery(whcbq bots.WebhookCallbackQuery, parseMode, text string) *tgbotapi.EditMessageTextConfig

EditMessageOnCallbackQuery creates edit message

func NewTelegramBot

func NewTelegramBot(mode strongo.Environment, profile, code, token, paymentTestToken, paymentToken, gaToken string, locale strongo.Locale) bots.BotSettings

NewTelegramBot creates definition of new telegram bot

func NewTelegramWebhookHandler

func NewTelegramWebhookHandler(botsBy bots.SettingsProvider, translatorProvider bots.TranslatorProvider) bots.WebhookHandler

NewTelegramWebhookHandler creates new Telegram webhooks handler

func NewTelegramWebhookInput

func NewTelegramWebhookInput(update *tgbotapi.Update, logRequest func()) (bots.WebhookInput, error)

NewTelegramWebhookInput maps telegram update struct to bots framework interface

Types

type CallbackAnswer

type CallbackAnswer tgbotapi.AnswerCallbackQueryConfig

CallbackAnswer is callback answer message

func (CallbackAnswer) BotMessageType

func (CallbackAnswer) BotMessageType() bots.BotMessageType

BotMessageType returns BotMessageTypeCallbackAnswer

type Chat

type Chat struct {
	TgChatBase
	*ChatEntity
}

func (Chat) Entity

func (tgChat Chat) Entity() interface{}

func (Chat) Kind

func (Chat) Kind() string

func (Chat) NewEntity

func (Chat) NewEntity() interface{}

func (*Chat) SetEntity

func (tgChat *Chat) SetEntity(entity interface{})

type ChatEntity

type ChatEntity struct {
	UserGroupID string `datastore:",index,omitempty"` // Do index
	TgChatEntityBase
}

func (*ChatEntity) Load

func (entity *ChatEntity) Load(ps []datastore.Property) error

func (*ChatEntity) Save

func (entity *ChatEntity) Save() (properties []datastore.Property, err error)

type ChatInstance

type ChatInstance struct {
	db.StringID
	ChatInstanceEntity
}

ChatInstance is base struct

func (*ChatInstance) Entity

func (record *ChatInstance) Entity() interface{}

Entity returns entity for saving

func (ChatInstance) Kind

func (ChatInstance) Kind() string

Kind return ChatInstanceKind

func (ChatInstance) NewEntity

func (ChatInstance) NewEntity() interface{}

NewEntity creates new entity

func (*ChatInstance) SetEntity

func (record *ChatInstance) SetEntity(entity interface{})

SetEntity sets entity to record

type ChatInstanceEntity

type ChatInstanceEntity interface {
	GetTgChatID() int64
	GetPreferredLanguage() string
	SetPreferredLanguage(v string)
}

ChatInstanceEntity describes chat instance entity interface

type ChatInstanceEntityBase

type ChatInstanceEntityBase struct {
	TgChatID          int64  `datastore:",noindex"`
	PreferredLanguage string `datastore:",noindex"`
}

ChatInstanceEntityBase is base struct

func (ChatInstanceEntityBase) GetPreferredLanguage

func (entity ChatInstanceEntityBase) GetPreferredLanguage() string

GetPreferredLanguage returns preferred language for the chat

func (ChatInstanceEntityBase) GetTgChatID

func (entity ChatInstanceEntityBase) GetTgChatID() int64

GetTgChatID returns Telegram chat ID

func (*ChatInstanceEntityBase) SetPreferredLanguage

func (entity *ChatInstanceEntityBase) SetPreferredLanguage(v string)

SetPreferredLanguage sets preferred language for the chat

type ChatMessageUID

type ChatMessageUID struct {
	ChatID    int64
	MessageID int
}

ChatMessageUID is what?

func NewChatMessageUID

func NewChatMessageUID(chatID int64, messageID int) *ChatMessageUID

NewChatMessageUID create new ChatMessageUID

func (ChatMessageUID) UID

func (m ChatMessageUID) UID() string

UID return unique ID of the message

type ExportChatInviteLink tgbotapi.ExportChatInviteLink

ExportChatInviteLink is TG message

func (ExportChatInviteLink) BotMessageType

func (ExportChatInviteLink) BotMessageType() bots.BotMessageType

BotMessageType returns BotMessageTypeExportChatInviteLink

type InlineBotMessage

type InlineBotMessage tgbotapi.InlineConfig

InlineBotMessage is wrapper for Telegram bot message

func (InlineBotMessage) BotMessageType

func (InlineBotMessage) BotMessageType() bots.BotMessageType

BotMessageType returns BotMessageTypeInlineResults

type InlineMessageUID

type InlineMessageUID struct {
	InlineMessageID string
}

InlineMessageUID is inline message UID

func NewInlineMessageUID

func NewInlineMessageUID(inlineMessageID string) *InlineMessageUID

NewInlineMessageUID creates new inline message UID

func (InlineMessageUID) UID

func (m InlineMessageUID) UID() string

UID is unique ID of the message

type LeaveChat

type LeaveChat tgbotapi.LeaveChatConfig

LeaveChat is leave chat message from bot

func (LeaveChat) BotMessageType

func (LeaveChat) BotMessageType() bots.BotMessageType

BotMessageType return BotMessageTypeLeaveChat

type Platform

type Platform struct {
}

Platform describes Telegram platform

func (Platform) ID

func (p Platform) ID() string

ID returns 'telegram'

func (Platform) Version

func (p Platform) Version() string

Version returns '2.0'

type TgChatBase

type TgChatBase struct {
	db.StringID
}

TgChatBase holds base properties of Telegram chat entity

func (*TgChatBase) SetID

func (tgChat *TgChatBase) SetID(tgBotID string, tgChatID int64)

SetID sets ID

type TgChatEntity

type TgChatEntity interface {
	SetTgChatInstanceID(v string)
	GetTgChatInstanceID() string
	GetPreferredLanguage() string
}

TgChatEntity is Telegram chat entity interface

type TgChatEntityBase

type TgChatEntityBase struct {
	bots.BotChatEntity
	TelegramUserID        int64   `datastore:",noindex,omitempty"`
	TelegramUserIDs       []int64 `datastore:",noindex"` // For groups
	LastProcessedUpdateID int     `datastore:",noindex,omitempty"`
	TgChatInstanceID      string  `datastore:",noindex,omitempty"` // Do index
}

TgChatEntityBase holds base properties of Telegram chat entity

func NewTelegramChatEntity

func NewTelegramChatEntity() *TgChatEntityBase

NewTelegramChatEntity create new telegram chat entity

func (*TgChatEntityBase) CleanProperties

func (entity *TgChatEntityBase) CleanProperties(properties []datastore.Property) ([]datastore.Property, error)

CleanProperties cleands properties

func (*TgChatEntityBase) GetPreferredLanguage

func (entity *TgChatEntityBase) GetPreferredLanguage() string

GetPreferredLanguage returns preferred language for the chat

func (*TgChatEntityBase) GetTgChatInstanceID

func (entity *TgChatEntityBase) GetTgChatInstanceID() string

GetTgChatInstanceID is what it is

func (*TgChatEntityBase) Load

func (entity *TgChatEntityBase) Load(ps []datastore.Property) error

Load loads entity from datastore

func (*TgChatEntityBase) Save

func (entity *TgChatEntityBase) Save() (properties []datastore.Property, err error)

Save saves entity to datastore

func (*TgChatEntityBase) SetAppUserIntID

func (entity *TgChatEntityBase) SetAppUserIntID(id int64)

SetAppUserIntID sets app user int ID

func (*TgChatEntityBase) SetBotUserID

func (entity *TgChatEntityBase) SetBotUserID(id interface{})

SetBotUserID sets bot user int ID

func (*TgChatEntityBase) SetTgChatInstanceID

func (entity *TgChatEntityBase) SetTgChatInstanceID(v string)

SetTgChatInstanceID is what it is

type TgChatInstanceDal

type TgChatInstanceDal interface {
	GetTelegramChatInstanceByID(c context.Context, id string) (tgChatInstance ChatInstance, err error)
	NewTelegramChatInstance(chatInstanceID string, chatID int64, preferredLanguage string) (tgChatInstance ChatInstance)
	SaveTelegramChatInstance(c context.Context, tgChatInstance ChatInstance) (err error)
}

TgChatInstanceDal is DAL for telegram chat instance entity

type TgMessageType

type TgMessageType string

TgMessageType represents tpye of Telegram message

type TgUser

type TgUser struct {
	ID int64
	TgUserEntity
}

TgUser is Telegram user DB record (with ID)

func (TgUser) GetEmail

func (TgUser) GetEmail() string

GetEmail returns empty string

type TgUserEntity

type TgUserEntity struct {
	bots.BotUserEntity
}

TgUserEntity is Telegram user DB entity (without ID)

func (*TgUserEntity) GetNames

func (entity *TgUserEntity) GetNames() user.Names

GetNames return user names

func (*TgUserEntity) IsEmailConfirmed

func (entity *TgUserEntity) IsEmailConfirmed() bool

IsEmailConfirmed returns false

func (*TgUserEntity) Load

func (entity *TgUserEntity) Load(ps []datastore.Property) error

Load is for datastore

func (TgUserEntity) Name

func (entity TgUserEntity) Name() string

Name returns full display name cmbined from (first+last, nick) name

func (*TgUserEntity) Save

func (entity *TgUserEntity) Save() (properties []datastore.Property, err error)

Save is for datastore

type TgWebhookCallbackQuery

type TgWebhookCallbackQuery struct {
	// contains filtered or unexported fields
}

TgWebhookCallbackQuery is wrapper on callback query

func (TgWebhookCallbackQuery) BotChatID

func (twhcbq TgWebhookCallbackQuery) BotChatID() (string, error)

BotChatID returns bot chat ID

func (TgWebhookCallbackQuery) Chat

func (whi TgWebhookCallbackQuery) Chat() bots.WebhookChat

func (TgWebhookCallbackQuery) GetData

func (twhcbq TgWebhookCallbackQuery) GetData() string

GetData returns callback query data

func (TgWebhookCallbackQuery) GetFrom

func (twhcbq TgWebhookCallbackQuery) GetFrom() bots.WebhookSender

GetFrom returns sender

func (TgWebhookCallbackQuery) GetID

func (twhcbq TgWebhookCallbackQuery) GetID() string

GetID returns update ID

func (TgWebhookCallbackQuery) GetInlineMessageID

func (twhcbq TgWebhookCallbackQuery) GetInlineMessageID() string

GetInlineMessageID returns callback query inline message ID

func (TgWebhookCallbackQuery) GetMessage

func (twhcbq TgWebhookCallbackQuery) GetMessage() bots.WebhookMessage

GetMessage returns message

func (TgWebhookCallbackQuery) GetRecipient

func (whi TgWebhookCallbackQuery) GetRecipient() bots.WebhookRecipient

func (TgWebhookCallbackQuery) GetSender

func (whi TgWebhookCallbackQuery) GetSender() bots.WebhookSender

func (TgWebhookCallbackQuery) GetTime

func (whi TgWebhookCallbackQuery) GetTime() time.Time

func (TgWebhookCallbackQuery) InputType

func (twhcbq TgWebhookCallbackQuery) InputType() bots.WebhookInputType

InputType return WebhookInputCallbackQuery

func (TgWebhookCallbackQuery) LogRequest

func (whi TgWebhookCallbackQuery) LogRequest()

func (TgWebhookCallbackQuery) Sequence

func (twhcbq TgWebhookCallbackQuery) Sequence() int

Sequence returns update ID

func (TgWebhookCallbackQuery) StringID

func (whi TgWebhookCallbackQuery) StringID() string

func (TgWebhookCallbackQuery) TelegramCallbackMessage

func (twhcbq TgWebhookCallbackQuery) TelegramCallbackMessage() *tgbotapi.Message

TelegramCallbackMessage returns message

func (TgWebhookCallbackQuery) TelegramChatID

func (whi TgWebhookCallbackQuery) TelegramChatID() int64

func (TgWebhookCallbackQuery) TgUpdate

func (whi TgWebhookCallbackQuery) TgUpdate() *tgbotapi.Update

type TgWebhookChat

type TgWebhookChat struct {
	// contains filtered or unexported fields
}

TgWebhookChat is wrapper for Telegram chat

func (TgWebhookChat) GetID

func (wh TgWebhookChat) GetID() string

GetID returns telegram chat ID

func (TgWebhookChat) GetType

func (wh TgWebhookChat) GetType() string

GetType returns telegram chat type

func (TgWebhookChat) IsGroupChat

func (wh TgWebhookChat) IsGroupChat() bool

IsGroupChat indicates type of chat (group or private)

type TgWebhookInlineQuery

type TgWebhookInlineQuery struct {
	// contains filtered or unexported fields
}

TgWebhookInlineQuery is wrapper

func (TgWebhookInlineQuery) BotChatID

func (iq TgWebhookInlineQuery) BotChatID() (string, error)

BotChatID returns bot chat ID

func (TgWebhookInlineQuery) Chat

func (whi TgWebhookInlineQuery) Chat() bots.WebhookChat

func (TgWebhookInlineQuery) GetFrom

func (iq TgWebhookInlineQuery) GetFrom() bots.WebhookSender

GetFrom returns recipient

func (TgWebhookInlineQuery) GetID

func (whi TgWebhookInlineQuery) GetID() interface{}

func (TgWebhookInlineQuery) GetInlineQueryID

func (iq TgWebhookInlineQuery) GetInlineQueryID() string

GetInlineQueryID return inline query ID

func (TgWebhookInlineQuery) GetOffset

func (iq TgWebhookInlineQuery) GetOffset() string

GetOffset returns offset

func (TgWebhookInlineQuery) GetQuery

func (iq TgWebhookInlineQuery) GetQuery() string

GetQuery returns query string

func (TgWebhookInlineQuery) GetRecipient

func (whi TgWebhookInlineQuery) GetRecipient() bots.WebhookRecipient

func (TgWebhookInlineQuery) GetSender

func (whi TgWebhookInlineQuery) GetSender() bots.WebhookSender

func (TgWebhookInlineQuery) GetTime

func (whi TgWebhookInlineQuery) GetTime() time.Time

func (TgWebhookInlineQuery) InputType

func (TgWebhookInlineQuery) InputType() bots.WebhookInputType

InputType returns WebhookInputInlineQuery

func (TgWebhookInlineQuery) LogRequest

func (whi TgWebhookInlineQuery) LogRequest()

func (TgWebhookInlineQuery) StringID

func (whi TgWebhookInlineQuery) StringID() string

func (TgWebhookInlineQuery) TelegramChatID

func (whi TgWebhookInlineQuery) TelegramChatID() int64

func (TgWebhookInlineQuery) TgUpdate

func (whi TgWebhookInlineQuery) TgUpdate() *tgbotapi.Update

type TgWebhookInput

type TgWebhookInput interface {
	TgUpdate() *tgbotapi.Update
}

TgWebhookInput is a wrapper of telegram update struct to bots framework interface

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL