jazbot

package
v0.0.0-...-1eb5c16 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: MIT Imports: 40 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SupportedCommands = map[string]Command{
	"getlikecount": {
		Name: "getlikecount",
		Desc: "Get the # of likes you have received",
	},
	"getlikesgiven": {
		Name: "getlikesgiven",
		Desc: "Get the # of likes you have given",
	},
	"findmeafriend": {
		Name: "findmeafriend",
		Desc: "Find users that have shared interests.\nCandidates are determined by looking at users with similar recent likes who you do not already follow.",
	},
	"challenge": {
		Name: "challenge",
		Desc: "Challenge a user to a like battle!" +
			"\nA like battle is a contest to see who can give the most likes to the other person's posts in a 48 hour period." +
			"\nYou can only have one active challenge at a time.",
		Args: []string{"@{handle}"},
	},
	"points": {
		Name: "points",
		Desc: "Get your current points.\nPoints can be acquired by participating in challenges.",
	},
	"search": {
		Name: "search",
		Desc: "Search your own posts.\nThe query can be a single word or a phrase that exists somewhere in any of your previous posts.\nTypos aren't supported yet, so make sure you spell everything correctly!",
		Args: []string{"{query}"},
	},
	"leaderboard": {
		Name: "leaderboard",
		Desc: "Get the top 5 coolest users ever (users with the most points)",
	},
	"getstoveylikes": {
		Name: "getstoveylikes",
		Desc: "Get the # of likes Stovey has given you",
	},
	"whereami": {
		Name: "whereami",
		Desc: "Get the name of your PDS",
	},
}

Functions

func GetDIDFromPLCMirror

func GetDIDFromPLCMirror(ctx context.Context, mirror, handle string) (did string, err error)

func GetHandleFromPLCMirror

func GetHandleFromPLCMirror(ctx context.Context, mirror, did string) (handle string, err error)

Types

type ChallengeResults

type ChallengeResults struct {
	InitiatorLikes int64  `json:"initiator_likes"`
	TargetLikes    int64  `json:"target_likes"`
	Tie            bool   `json:"tie"`
	WinnerDid      string `json:"winner_did"`
}

type Command

type Command struct {
	Name string
	Desc string
	Args []string
}

type Consumer

type Consumer struct {
	SocketURL string
	Progress  *Progress
	ProgMux   sync.Mutex
	Logger    *zap.SugaredLogger

	RedisClient *redis.Client
	ProgressKey string

	Jazbot *Jazbot
}

Consumer is the consumer of the firehose

func NewConsumer

func NewConsumer(
	ctx context.Context,
	logger *zap.SugaredLogger,
	redisClient *redis.Client,
	redisPrefix string,
	jazbot *Jazbot,
	socketURL string,
) (*Consumer, error)

NewConsumer creates a new consumer

func (*Consumer) HandleCreateRecord

func (c *Consumer) HandleCreateRecord(
	ctx context.Context,
	repo string,
	path string,
	rec typegen.CBORMarshaler,
	cid *lexutil.LexLink,
) (*time.Time, error)

HandleCreateRecord handles a create record event from the firehose

func (*Consumer) HandleRepoCommit

func (c *Consumer) HandleRepoCommit(ctx context.Context, evt *comatproto.SyncSubscribeRepos_Commit) error

HandleRepoCommit handles a repo commit event from the firehose and processes the records

func (*Consumer) HandleStreamEvent

func (c *Consumer) HandleStreamEvent(ctx context.Context, xe *events.XRPCStreamEvent) error

HandleStreamEvent handles a stream event from the firehose

func (*Consumer) ReadCursor

func (c *Consumer) ReadCursor(ctx context.Context) error

ReadCursor reads the cursor from redis

func (*Consumer) WriteCursor

func (c *Consumer) WriteCursor(ctx context.Context) error

WriteCursor writes the cursor to redis

type Jazbot

type Jazbot struct {
	Store  *store.Store
	Client *xrpc.Client
	Logger *zap.SugaredLogger

	BotDid string

	PLCMirror string
	Directory identity.Directory
	// contains filtered or unexported fields
}

func NewJazbot

func NewJazbot(ctx context.Context, store *store.Store, botDid, plcMirror string) (*Jazbot, error)

func (*Jazbot) AcceptChallenge

func (j *Jazbot) AcceptChallenge(ctx context.Context, actorDid string, parentUri string) (string, []*appbsky.RichtextFacet, error)

func (*Jazbot) Challenge

func (j *Jazbot) Challenge(ctx context.Context, actorDid string, arg string) (string, []*appbsky.RichtextFacet, *int64, error)

func (*Jazbot) ConcludeChallenge

func (j *Jazbot) ConcludeChallenge(ctx context.Context, event *store_queries.Event) error

func (*Jazbot) ConcludeChallenges

func (j *Jazbot) ConcludeChallenges(ctx context.Context) []error

func (*Jazbot) FindFriends

func (j *Jazbot) FindFriends(ctx context.Context, actorDid string) (string, []*appbsky.RichtextFacet, error)

func (*Jazbot) GetLeaderboard

func (j *Jazbot) GetLeaderboard(ctx context.Context, actorDid string) (string, []*appbsky.RichtextFacet, error)

func (*Jazbot) GetPDS

func (j *Jazbot) GetPDS(ctx context.Context, actorDid string) (string, error)

func (*Jazbot) GetPoints

func (j *Jazbot) GetPoints(ctx context.Context, actorDid string) (string, error)

func (*Jazbot) HandleRequest

func (j *Jazbot) HandleRequest(
	ctx context.Context,
	actorDid string,
	rkey string,
	text string,
	postCid *lexutil.LexLink,
	parentURI *string,
	rootURI *string,
	rootCid *string,
) error

func (*Jazbot) SearchMyPosts

func (j *Jazbot) SearchMyPosts(ctx context.Context, actorDid string, searchText string) (string, []*appbsky.RichtextFacet, error)

type Progress

type Progress struct {
	LastSeq            int64     `json:"last_seq"`
	LastSeqProcessedAt time.Time `json:"last_seq_processed_at"`
}

Progress is the cursor for the consumer

Jump to

Keyboard shortcuts

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