underattack

package
v0.0.0-...-d71c2e5 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RateLimitCall

func RateLimitCall(id int64, duration time.Duration) bool

RateLimitCall provides a simple rate limiter by a specified ID.

Types

type Datastore

type Datastore interface {
	Migrate(ctx context.Context) error
	GetUnderAttackEntry(ctx context.Context, groupID int64) (UnderAttack, error)
	CreateNewEntry(ctx context.Context, groupID int64) error
	SetUnderAttackStatus(ctx context.Context, groupID int64, underAttack bool, expiresAt time.Time, notificationMessageID int64) error
	Close() error
}

type Dependency

type Dependency struct {
	Datastore Datastore
	Memory    *bigcache.BigCache
	Bot       *tb.Bot
}

Dependency contains the dependency injection struct for methods in the UnderAttack package

func (*Dependency) AreWe

func (d *Dependency) AreWe(ctx context.Context, chatID int64) (bool, error)

AreWe ...on under attack mode?

func (*Dependency) DisableUnderAttackModeHandler

func (d *Dependency) DisableUnderAttackModeHandler(ctx context.Context, c tb.Context) error

DisableUnderAttackModeHandler provides a handler for /disableunderattack command.

func (*Dependency) EnableUnderAttackModeHandler

func (d *Dependency) EnableUnderAttackModeHandler(ctx context.Context, c tb.Context) error

EnableUnderAttackModeHandler provides a handler for /UnderAttack command.

func (*Dependency) Kicker

func (d *Dependency) Kicker(ctx context.Context, c tb.Context) error

type UnderAttack

type UnderAttack struct {
	GroupID               int64     `db:"group_id"`
	IsUnderAttack         bool      `db:"is_under_attack"`
	NotificationMessageID int64     `db:"notification_message_id"`
	ExpiresAt             time.Time `db:"expires_at"`
	UpdatedAt             time.Time `db:"updated_at"`
}

UnderAttack provides a data struct to interact with the database table.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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