telegram

package
v2.0.3 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2023 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OpBotNew  = "bot: new ->"
	OpBotSend = "bot: send ->"
)
View Source
const (
	OpUnmarshalMessage  = "telegram sub: unmarshal message ->"
	OpPrepareMessage    = "telegram sub: prepare message ->"
	OpUnmarshalArticles = "telegram sub: unmarshal articles ->"
	OpFindSite          = "telegram sub: find site ->"
	OpFindChats         = "telegram sub: find chats ->"
	OpProcessor         = "telegram sub: processor ->"
)
View Source
const OpMessageToChattableList = "message: to chattable list ->"
View Source
const (
	PluginName = "telegram"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Bot

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

func NewBot

func NewBot(cfg *Config, log *slog.Logger) *Bot

func (*Bot) Chattable

func (b *Bot) Chattable(c tgbotapi.Chattable) error

func (*Bot) Me

func (b *Bot) Me() tgbotapi.User

func (*Bot) OwnerID

func (b *Bot) OwnerID() int64

func (*Bot) Request

func (b *Bot) Request(c tgbotapi.Chattable) (*tgbotapi.APIResponse, error)

func (*Bot) Send

func (b *Bot) Send(message model.Message) error

type Config

type Config struct {
	Token   string `mapstructure:"token"`
	OwnerID int64  `mapstructure:"owner"`
	Retry   uint   `mapstructure:"retry"`
}

func (*Config) Init

func (cfg *Config) Init()

type Plugin

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

func (*Plugin) Init

func (p *Plugin) Init(cfg config.Configurer, sub common.Sub, uow common.UnitOfWork, client common.Client, log logger.Logger) error

func (*Plugin) Name

func (p *Plugin) Name() string

func (*Plugin) Serve

func (p *Plugin) Serve() chan error

func (*Plugin) Stop

func (p *Plugin) Stop(context.Context) error

type Poller

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

func NewPoller

func NewPoller(cfg *PollerConfig, bot *Bot, client common.Client, logger *slog.Logger) *Poller

func (*Poller) Run

func (p *Poller) Run(done <-chan struct{})

type PollerConfig

type PollerConfig struct {
	OnlyOwner      bool          `mapstructure:"only_owner"`
	Buffer         int           `mapstructure:"buffer"`
	Limit          int           `mapstructure:"limit"`
	Timeout        time.Duration `mapstructure:"timeout"`
	AllowedUpdates []string      `mapstructure:"allowed_updates"`
}

func (*PollerConfig) Init

func (cfg *PollerConfig) Init()

type Subscriber

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

func NewSubscriber

func NewSubscriber(
	bot *Bot,
	sub common.Sub,
	siteRepo repository.ReadRepository[*entity.Site],
	chatRepo repository.ReadRepository[*entity.Chat],
	logger *slog.Logger,
) *Subscriber

func (*Subscriber) Run

func (s *Subscriber) Run(done <-chan struct{})

Jump to

Keyboard shortcuts

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