telegram

package
v1.15.16 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2026 License: GPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const AdminOrderDaily = `` /* 327-byte string literal not displayed */

AdminOrderDaily 管理员每日订单统计

View Source
const AdminOrderNotify = `` /* 353-byte string literal not displayed */

AdminOrderNotify 管理员订单通知

View Source
const BindNotify = `` /* 247-byte string literal not displayed */
View Source
const PurchaseNotify = `` /* 388-byte string literal not displayed */
View Source
const RechargeNotify = `` /* 368-byte string literal not displayed */

RechargeNotify 充值通知

View Source
const RenewalNotify = `` /* 388-byte string literal not displayed */
View Source
const ResetTrafficNotify = `` /* 341-byte string literal not displayed */

ResetTrafficNotify 重置流量通知

View Source
const SubscribeExpireNotify = `` /* 292-byte string literal not displayed */

SubscribeExpireNotify 订阅到期通知

View Source
const UnbindNotify = `` /* 353-byte string literal not displayed */

UnbindNotify 解绑通知

Variables

This section is empty.

Functions

This section is empty.

Types

type Command added in v1.15.16

type Command struct {
	Command     string
	Description string
}

Command describes one entry of the bot's command menu. It mirrors Telegram's BotCommand without binding this package to the bot library.

func AdminCommands added in v1.15.16

func AdminCommands() []Command

AdminCommands is the menu registered for an administrator's own chat. It deliberately excludes /confirm_* and /cancel_* because those carry a generated action id and are only ever offered inline.

func PublicCommands added in v1.15.16

func PublicCommands() []Command

PublicCommands is the menu every user gets: account binding, plus the help entry that makes the administrator surface discoverable to the people who have access to it. Handlers still authenticate, so a non-administrator only learns that the command exists.

type TelegramAdmin

type TelegramAdmin struct {
	logger.Logger
	// contains filtered or unexported fields
}

TelegramAdmin handles administrative Telegram commands independently from the general Telegram bot flow.

func (*TelegramAdmin) Handle

func (a *TelegramAdmin) Handle(msg *tgbotapi.Message)

Handle runs an administrator command.

type TelegramAdminActionStore

type TelegramAdminActionStore interface {
	Get(ctx context.Context, key string) (string, error)
	Set(ctx context.Context, key, value string, ttl time.Duration) error
	Delete(ctx context.Context, key string) error
}

TelegramAdminActionStore persists short-lived confirmations for destructive administrator commands.

type TelegramAdminDependencies

type TelegramAdminDependencies struct {
	Messenger TelegramMessenger
	// Commands publishes the administrator command menu; optional so tests
	// and deployments without a live bot still work.
	Commands      TelegramCommandRegistrar
	Actions       TelegramAdminActionStore
	Tickets       repository.TicketRepo
	Orders        repository.OrderRepo
	Users         repository.UserRepo
	UserAuth      repository.UserAuthRepo
	Subscriptions repository.UserSubscriptionRepo
	UserCache     repository.UserCacheRepo
	Plans         repository.SubscribeRepo
	Logs          repository.LogRepo
	// Wallet is the billing-domain read port for balance display.
	Wallet repository.WalletRepo
}

TelegramAdminDependencies contains only the collaborators used by Telegram administrator commands. It intentionally does not accept ServiceContext.

type TelegramAdminHandler

type TelegramAdminHandler interface {
	Handle(msg *tgbotapi.Message)
}

TelegramAdminHandler handles administrator Telegram commands.

type TelegramCommandRegistrar added in v1.15.16

type TelegramCommandRegistrar interface {
	SetCommands(chatID int64, commands []Command) error
}

TelegramCommandRegistrar publishes the command menu Telegram shows in the message composer. A zero chatID addresses the default scope, which every user sees; a non-zero chatID scopes the menu to that chat.

func NewTelegramBotCommandRegistrar added in v1.15.16

func NewTelegramBotCommandRegistrar(bot *tgbotapi.BotAPI) TelegramCommandRegistrar

NewTelegramBotCommandRegistrar adapts a Telegram Bot API client to the command-menu port.

type TelegramLogic

type TelegramLogic struct {
	logger.Logger
	// contains filtered or unexported fields
}

func (*TelegramLogic) TelegramLogic

func (l *TelegramLogic) TelegramLogic(req *tgbotapi.Update)

type TelegramLogicDependencies

type TelegramLogicDependencies struct {
	Messenger TelegramMessenger
	Sessions  TelegramSessionStore
	UserAuth  repository.UserAuthRepo
	UserCache repository.UserCacheRepo
	Admin     TelegramAdminHandler
}

TelegramLogicDependencies explicitly declares the collaborators used by general Telegram command dispatch and account binding.

type TelegramMessenger

type TelegramMessenger interface {
	Send(chatID int64, message string) error
}

TelegramMessenger sends a response to a Telegram chat.

func NewTelegramBotMessenger

func NewTelegramBotMessenger(bot *tgbotapi.BotAPI) TelegramMessenger

NewTelegramBotMessenger adapts a Telegram Bot API client to the command messenger port.

type TelegramRedisStore

type TelegramRedisStore interface {
	TelegramSessionStore
	TelegramAdminActionStore
}

TelegramRedisStore supports both account-binding sessions and administrator command confirmations.

func NewTelegramRedisStore

func NewTelegramRedisStore(client *redis.Client) TelegramRedisStore

NewTelegramRedisStore adapts Redis to the binding-session and administrator confirmation ports.

type TelegramSessionStore

type TelegramSessionStore interface {
	Get(ctx context.Context, key string) (string, error)
	Delete(ctx context.Context, key string) error
}

TelegramSessionStore reads and consumes short-lived account-binding tokens. Deleting the token on a successful bind is what makes the deep link single-use.

Jump to

Keyboard shortcuts

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