telegram

package
v0.25.14 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2026 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

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

	// MessageTypeEdited is 'edited_message'
	MessageTypeEdited = "edited_message"

	// MessageTypeChannelPost is 'channel_post'
	MessageTypeChannelPost = "channel_post"

	// MessageTypeEditedChannelPost is 'edited_channel_post'
	MessageTypeEditedChannelPost = "edited_channel_post"
)
View Source
const ChatInstancesCollection = "chatInstances"
View Source
const PlatformID botsfwconst.Platform = "telegram"

PlatformID is 'telegram'

Variables

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

CallbackCurrent is what?

View Source
var NewChatInstanceData = func(botCode string) botsfwtgmodels.TgChatInstanceData {
	panic("telegram.NewChatInstanceData is not set")
}
View Source
var Platform botsfw.BotPlatform = platform{}

Platform is a bots platform descriptor (in this case - for Telegram)

Functions

func BaseTgChatDtoMaker

func BaseTgChatDtoMaker(botID string) (botChat botsfwmodels.BotChatData, err error)

func BaseTgUserDtoMaker

func BaseTgUserDtoMaker(botID string) (botsfwmodels.PlatformUserData, error)

func EditMessageOnCallbackQuery

func EditMessageOnCallbackQuery(whcbq botinput.CallbackQuery, parseMode, text string) *tgbotapi.EditMessageTextConfig

EditMessageOnCallbackQuery creates edit message

func GetTelegramBotAPIClient added in v0.20.0

func GetTelegramBotAPIClient(ctx context.Context, botContext botsfw.BotContext) *tgbotapi.BotAPI

func NewBotRecordsFieldsSetter

func NewBotRecordsFieldsSetter(
	setAppUserFields func(appUser botsfwmodels.AppUserData, sender botinput.Sender) error,
) botsfw.BotRecordsFieldsSetter

func NewTelegramBot

func NewTelegramBot(
	environment string,
	profile botsfw.BotProfile,
	code, token, paymentTestToken, paymentToken, gaToken string,
	locale i18n.Locale,
	getDatabase botsfw.DbGetter,
	getAppUser botsfw.AppUserGetter,
) botsfw.BotSettings

NewTelegramBot creates definition of new telegram bot

func NewTelegramChatInstance added in v0.19.0

func NewTelegramChatInstance(chatInstanceID string, chatID int64, preferredLanguage string) (tgChatInstanceData botsfwtgmodels.TgChatInstanceData)

func NewTelegramWebhookHandler

func NewTelegramWebhookHandler(
	botContextProvider botsfw.BotContextProvider,
	translatorProvider botsfw.TranslatorProvider,
	setAppUserFields func(botsfwmodels.AppUserData, botinput.Sender) error,
) botsfw.WebhookHandler

NewTelegramWebhookHandler creates new Telegram webhooks handler

func NewTelegramWebhookInput

func NewTelegramWebhookInput(update *tgbotapi.Update, logRequest func()) (botinput.InputMessage, error)

NewTelegramWebhookInput maps telegram update struct to bots framework interface

func NewTgChatInstanceKey added in v0.19.0

func NewTgChatInstanceKey(botCode, chatInstanceID string) *dal.Key

Types

type CallbackAnswer

type CallbackAnswer tgbotapi.AnswerCallbackQueryConfig

CallbackAnswer is a callback answer message

func (CallbackAnswer) BotEndpoint added in v0.20.0

func (a CallbackAnswer) BotEndpoint() string

func (CallbackAnswer) BotMessageType

func (CallbackAnswer) BotMessageType() botmsg.Type

BotMessageType returns BotMessageTypeCallbackAnswer

type ChatMessageUID

type ChatMessageUID struct {
	ChatID    int64
	MessageID int
}

ChatMessageUID is what?

func GetMessageUID added in v0.17.0

func GetMessageUID(whc botsfw.WebhookContext) (*ChatMessageUID, error)

GetMessageUID returns UID of the message to be edited

func NewChatMessageUID

func NewChatMessageUID(chatID int64, messageID int) *ChatMessageUID

NewChatMessageUID create new ChatMessageUID

func (ChatMessageUID) GetChatID added in v0.25.0

func (m ChatMessageUID) GetChatID() int64

func (ChatMessageUID) GetMessageID added in v0.25.0

func (m ChatMessageUID) GetMessageID() int

func (ChatMessageUID) UID

func (m ChatMessageUID) UID() string

UID return unique ID of the message

type DataStore

type DataStore interface {
	TgChatInstanceDal
}
type ExportChatInviteLink tgbotapi.ExportChatInviteLink

ExportChatInviteLink is a TG message

func (ExportChatInviteLink) BotEndpoint added in v0.20.0

func (m ExportChatInviteLink) BotEndpoint() string

func (ExportChatInviteLink) BotMessageType

func (ExportChatInviteLink) BotMessageType() botmsg.Type

BotMessageType returns BotMessageTypeExportChatInviteLink

type InlineBotMessage

type InlineBotMessage tgbotapi.InlineConfig

InlineBotMessage is a wrapper for Telegram bot message

func (InlineBotMessage) BotEndpoint added in v0.20.0

func (m InlineBotMessage) BotEndpoint() string

func (InlineBotMessage) BotMessageType

func (InlineBotMessage) BotMessageType() botmsg.Type

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 Invoice added in v0.20.0

type Invoice tgbotapi.InvoiceConfig

func (Invoice) BotEndpoint added in v0.20.0

func (m Invoice) BotEndpoint() string

func (Invoice) BotMessageType added in v0.20.0

func (Invoice) BotMessageType() botmsg.Type

type LeaveChat

type LeaveChat tgbotapi.LeaveChatConfig

LeaveChat is a leave chat message from bot

func (LeaveChat) BotEndpoint added in v0.20.0

func (m LeaveChat) BotEndpoint() string

func (LeaveChat) BotMessageType

func (LeaveChat) BotMessageType() botmsg.Type

BotMessageType return BotMessageTypeLeaveChat

type MessageType added in v0.24.0

type MessageType string

MessageType represents tpye of Telegram message

type PreCheckoutQueryAnswer added in v0.20.0

type PreCheckoutQueryAnswer tgbotapi.AnswerPreCheckoutQueryConfig

func (PreCheckoutQueryAnswer) BotMessageType added in v0.20.0

func (PreCheckoutQueryAnswer) BotMessageType() botmsg.Type

type SendPhoto added in v0.21.0

type SendPhoto tgbotapi.PhotoConfig

func (SendPhoto) BotEndpoint added in v0.21.0

func (m SendPhoto) BotEndpoint() string

func (SendPhoto) BotMessageType added in v0.21.0

func (SendPhoto) BotMessageType() botmsg.Type

type SetBotCommands added in v0.20.0

type SetBotCommands tgbotapi.SetMyCommandsConfig

func (SetBotCommands) BotEndpoint added in v0.20.0

func (m SetBotCommands) BotEndpoint() string

func (SetBotCommands) BotMessageType added in v0.20.0

func (SetBotCommands) BotMessageType() botmsg.Type

type SetBotDescription added in v0.20.0

type SetBotDescription tgbotapi.SetMyDescription

func (SetBotDescription) BotEndpoint added in v0.20.0

func (m SetBotDescription) BotEndpoint() string

func (SetBotDescription) BotMessageType added in v0.20.0

func (SetBotDescription) BotMessageType() botmsg.Type

type SetBotShortDescription added in v0.20.0

type SetBotShortDescription tgbotapi.SetMyShortDescription

func (SetBotShortDescription) BotEndpoint added in v0.20.0

func (m SetBotShortDescription) BotEndpoint() string

func (SetBotShortDescription) BotMessageType added in v0.20.0

func (SetBotShortDescription) BotMessageType() botmsg.Type

type TgChat added in v0.24.0

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

TgChat is wrapper for Telegram chat

func (TgChat) GetID added in v0.24.0

func (wh TgChat) GetID() string

GetID returns telegram chat ID

func (TgChat) GetType added in v0.24.0

func (wh TgChat) GetType() string

GetType returns telegram chat type

func (TgChat) IsGroupChat added in v0.24.0

func (wh TgChat) IsGroupChat() bool

IsGroupChat indicates type of chat (group or private)

type TgChatInstance added in v0.19.0

type TgChatInstance struct {
	record.WithID[string]
	Data botsfwtgmodels.TgChatInstanceData
}

type TgChatInstanceDal

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

TgChatInstanceDal is Data Access Layer for telegram chat instance Data

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() botinput.Chat

func (TgWebhookInlineQuery) GetFrom

func (iq TgWebhookInlineQuery) GetFrom() botinput.Sender

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() botinput.Recipient

func (TgWebhookInlineQuery) GetSender

func (whi TgWebhookInlineQuery) GetSender() botinput.User

func (TgWebhookInlineQuery) GetTime

func (whi TgWebhookInlineQuery) GetTime() time.Time

func (TgWebhookInlineQuery) InputType

func (whi TgWebhookInlineQuery) InputType() botinput.Type

func (TgWebhookInlineQuery) LogRequest

func (whi TgWebhookInlineQuery) LogRequest()

func (TgWebhookInlineQuery) MessageIntID added in v0.23.0

func (whi TgWebhookInlineQuery) MessageIntID() int

func (TgWebhookInlineQuery) MessageStringID added in v0.23.0

func (whi TgWebhookInlineQuery) MessageStringID() 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

type WebhookCallbackQuery added in v0.19.0

type WebhookCallbackQuery interface {
	botinput.CallbackQuery
	GetInlineMessageID() string // Telegram only?
	GetChatInstanceID() string  // Telegram only?
}

Jump to

Keyboard shortcuts

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