telegram

package
v2.0.0-beta2 Latest Latest
Warning

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

Go to latest
Published: May 5, 2023 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

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 ConfigKey = "telegram"

Variables

This section is empty.

Functions

func BotActivator

func BotActivator() *di.Activator

func SubActivator

func SubActivator() *di.Activator

Types

type Bot

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

func GetBot

func GetBot(ctx context.Context, c ...di.Container) (*Bot, error)

func NewBot

func NewBot(cfg *Config) *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 Message) error

type BotKey

type BotKey struct{}

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 Dict

type Dict[T any] struct {
	// contains filtered or unexported fields
}

func NewDict

func NewDict[T any]() *Dict[T]

func (*Dict[T]) Del

func (d *Dict[T]) Del(key string) (value T)

func (*Dict[T]) Get

func (d *Dict[T]) Get(key string) (value T)

func (*Dict[T]) Has

func (d *Dict[T]) Has(key string) bool

func (*Dict[T]) Len

func (d *Dict[T]) Len() int

func (*Dict[T]) Loop

func (d *Dict[T]) Loop(fn func(string, T) bool)

func (*Dict[T]) Set

func (d *Dict[T]) Set(key string, item T)

type List

type List[T any] struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewList

func NewList[T any](size int) *List[T]

func (*List[T]) Add

func (l *List[T]) Add(item T)

func (*List[T]) Del

func (l *List[T]) Del(i int, j int)

func (*List[T]) Get

func (l *List[T]) Get(i int) T

func (*List[T]) Insert

func (l *List[T]) Insert(i int, item T)

func (*List[T]) IsEmpty

func (l *List[T]) IsEmpty() bool

func (*List[T]) Len

func (l *List[T]) Len() int

func (*List[T]) Loop

func (l *List[T]) Loop(fn func(i int, item T) bool)

func (*List[T]) Shift

func (l *List[T]) Shift() T

func (*List[T]) Unshift

func (l *List[T]) Unshift(item T)

type Message

type Message struct {
	ChatID   int64  `json:"chat_id,omitempty"`
	ImageURL string `json:"image_url,omitempty"`
	View     View   `json:"view,omitempty"`
	Data     any    `json:"data,omitempty"`
	Delay    bool   `json:"delay,omitempty"`
}

func (*Message) UnmarshalJSON

func (m *Message) UnmarshalJSON(data []byte) error

type SubKey

type SubKey struct{}

type Subscriber

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

func GetSub

func GetSub(ctx context.Context, c ...di.Container) (*Subscriber, error)

func NewSubscriber

func NewSubscriber(
	bot *Bot,
	sub *pubsub.Subscriber,
	siteRepo repository.ReadRepository[*entity.Site],
	chatRepo repository.ReadRepository[*entity.Chat],
) *Subscriber

func (*Subscriber) Run

func (s *Subscriber) Run(ctx context.Context) error

type View

type View string
const (
	ViewAppStart View = "appstart.html"
	ViewAppStop  View = "appstop.html"
	ViewArticles View = "articles.html"
	ViewArticle  View = "article.html"
	ViewChat     View = "chat.html"
	ViewSites    View = "sites.html"
	ViewSub      View = "sub.html"
	ViewSuccess  View = "success.html"
	ViewError    View = "error.html"
	ViewNotFound View = "notfound.html"

	OpBotNew  = "bot: new ->"
	OpBotSend = "bot: send ->"
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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