child_bot

package
v1.0.19 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2023 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	None mode = iota
	OnlyFirst
	Always
)

Variables

This section is empty.

Functions

func NewService

func NewService(
	logger zerolog.Logger,
	childBotHost,
	childBotPort,
	childTokenPathPrefix string,
	childStateRepo *child_state.Repo,
	userRepo *user.Repo,
	peerRepo *peer.Repo,
	childBotRepo *Repo,
	replyRepo *reply.Repo,
	keywordsLimitPerBot,
	inLimitPerKeyword,
	inLimitChars,
	outLimitChars uint16,
	parentBotUsername string,
	setWebhooks,
	timeoutOnHandle bool,
) *service

Types

type Bot

type Bot struct {
	ID              primitive.ObjectID `bson:"_id,omitempty"`
	OwnerUserID     primitive.ObjectID `bson:"ui,omitempty"`
	OwnerUserChatID int64              `bson:"uci,omitempty"`
	Token           string             `bson:"t,omitempty"`
	SetupDone       bool               `bson:"sd,omitempty"`
	OnPeerStart     string             `bson:"ops,omitempty"`
	Keywords        []Keyword          `bson:"k,omitempty"`
	WebhookAt       time.Time          `bson:"wa,omitempty"`
	Mode            mode               `bson:"m,omitempty"`
}

type Item

type Item struct {
	Doc Bot
	Err error
}

type Keyword

type Keyword struct {
	In  []string `bson:"i,omitempty"`
	Out string   `bson:"o,omitempty"`
	Ban bool     `bson:"b,omitempty"`
}

type Repo

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

func NewRepo

func NewRepo(ctx context.Context, db *mongo.Database) (*Repo, error)

func (*Repo) CountByUserID

func (r *Repo) CountByUserID(c context.Context, userID primitive.ObjectID) (int64, error)

func (*Repo) Create

func (r *Repo) Create(c context.Context, userID primitive.ObjectID, token string) error

func (*Repo) Delete

func (r *Repo) Delete(c context.Context, userID, id primitive.ObjectID) error

func (*Repo) Get added in v1.0.3

func (r *Repo) Get(c context.Context) chan Item

func (*Repo) GetByToken

func (r *Repo) GetByToken(c context.Context, token string) (Bot, bool, error)

func (*Repo) GetByUserID

func (r *Repo) GetByUserID(c context.Context, userID primitive.ObjectID) ([]Bot, error)

func (*Repo) SetKeywordsAndMode

func (r *Repo) SetKeywordsAndMode(c context.Context, id primitive.ObjectID, keywords []Keyword, mode mode) error

func (*Repo) SetOnPeerStart

func (r *Repo) SetOnPeerStart(c context.Context, id primitive.ObjectID, onPeerStart string) error

func (*Repo) SetSetupDoneTrue

func (r *Repo) SetSetupDoneTrue(c context.Context, id primitive.ObjectID) error

func (*Repo) SetUserChatID

func (r *Repo) SetUserChatID(c context.Context, id primitive.ObjectID, userChatID int64) error

func (*Repo) SetWebhookNow

func (r *Repo) SetWebhookNow(c context.Context, id primitive.ObjectID) error

Jump to

Keyboard shortcuts

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