chats

package
v0.0.0-...-c452e5e Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2024 License: AGPL-3.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const ReaderTtl = 24 * time.Hour

Variables

View Source
var ErrAlreadyExists = errors.New("chat already exists")
View Source
var ErrInternal = errors.New("internal failure")
View Source
var ErrNotFound = errors.New("chat or subscription not found")

Functions

func ResumeAllReaders

func ResumeAllReaders(
	ctx context.Context,
	log *slog.Logger,
	chatStor Storage,
	tgBot *telebot.Bot,
	clientAwk api.Client,
	format messages.Format,
	replicaIndex uint32,
	replicaRange uint32,
) (count uint32, err error)

func StopChatReader

func StopChatReader(subId string) (found bool)

func StopChatReaders

func StopChatReaders(chatId int64)

func UserLeftHandlerFunc

func UserLeftHandlerFunc(chatStor Storage) telebot.HandlerFunc

Types

type Chat

type Chat struct {
	Id          int64         `bson:"id"`
	SubId       string        `bson:"subId"`
	GroupId     string        `bson:"groupId"`
	UserId      string        `bson:"userId"`
	MinInterval time.Duration `bson:"minInterval"`
}

type Reader

type Reader interface {
	Run(ctx context.Context, log *slog.Logger)
}

func NewReader

func NewReader(
	tgCtx telebot.Context,
	clientAwk api.Client,
	chatStor Storage,
	chatId int64,
	subId, groupId, userId string,
	format messages.Format,
	minInterval time.Duration,
) Reader

type Storage

type Storage interface {
	io.Closer
	LinkSubscription(ctx context.Context, c Chat) (err error)
	GetSubscriptionLink(ctx context.Context, subId string) (c Chat, err error)
	UnlinkSubscription(ctx context.Context, subId string) (err error)
	Delete(ctx context.Context, id int64) (count int64, err error)
	GetBatch(ctx context.Context, idRem, idDiv uint32, limit uint32, cursor int64) (page []Chat, err error)
	Count(ctx context.Context) (count int64, err error)
}

func NewStorage

func NewStorage(ctx context.Context, cfgDb config.ChatsDbConfig) (s Storage, err error)

Jump to

Keyboard shortcuts

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