hub

package
v0.0.0-...-a470e00 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// endpoints
	ENDPOINT_CAST_BY_MENTION       = "castsByMention?fid=%d"
	ENDPOINT_GET_CAST              = "castById?fid=%d&hash=%s"
	ENDPOINT_SUBMIT_MESSAGE        = "submitMessage"
	ENDPOINT_USERDATA              = "userDataByFid?fid=%d"
	ENDPOINT_CUSTODY_ADDRESS       = "userNameProofsByFid?fid=%d"
	ENDPOINT_USER_FOLLOWERs        = "linksByTargetFid?target_fid=%d"
	ENDPOINT_VERIFICATIONS         = "verificationsByFid?fid=%d"
	ENDPOINT_IDREGISTRY_BY_ADDRESS = "onChainIdRegistryEventByAddress?address=%s"

	// message types
	MESSAGE_TYPE_CAST_ADD     = "MESSAGE_TYPE_CAST_ADD"
	MESSAGE_TYPE_USERPROOF    = "USERNAME_TYPE_FNAME"
	MESSAGE_TYPE_VERIFICATION = "MESSAGE_TYPE_VERIFICATION_ADD_ETH_ADDRESS"
	MESSAGE_TYPE_LINK         = "MESSAGE_TYPE_LINK_ADD"
	MESSAGE_TYPE_USERDATA_ADD = "MESSAGE_TYPE_USER_DATA_ADD"
	// user data types
	USERDATA_TYPE_USERNAME = "USER_DATA_TYPE_USERNAME"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Hub

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

Hub struct implements the farcasterapi.API interface and represents the API of a Farcaster Hub.

func NewHubAPI

func NewHubAPI(apiEndpoint string, apiKeys []string) (*Hub, error)

Init initializes the API Hub with the given arguments. apiKeys must be a slice of strings with an even number of elements, where each pair of elements is a header and a key.

func (*Hub) Channel

func (h *Hub) Channel(ctx context.Context, channelID string) (*farcasterapi.Channel, error)

Channel method is not supported by the Hub API. It returns an error.

func (*Hub) ChannelExists

func (h *Hub) ChannelExists(ctx context.Context, channelID string) (bool, error)

ChannelExists method is not supported by the Hub API. It returns an error.

func (*Hub) ChannelFIDs

func (h *Hub) ChannelFIDs(ctx context.Context, channelID string, _ chan int) ([]uint64, error)

ChannelFIDs method is not supported by the Hub API. It returns an error.

func (*Hub) FID

func (h *Hub) FID() uint64

FID returns the fid of the farcaster user set in the API.

func (*Hub) FindChannel

func (h *Hub) FindChannel(ctx context.Context, query string) ([]*farcasterapi.Channel, error)

ListChannels method is not supported by the Hub API. It returns an error.

func (*Hub) GetCast

func (h *Hub) GetCast(ctx context.Context, fid uint64, hash string) (*farcasterapi.APIMessage, error)

func (*Hub) LastMentions

func (h *Hub) LastMentions(ctx context.Context, timestamp uint64) ([]*farcasterapi.APIMessage, uint64, error)

LastMentions method returns the last mentions of the bot since the given timestamp. It returns the messages, the last timestamp and an error.

func (*Hub) Publish

func (h *Hub) Publish(ctx context.Context, content string, mentionFIDs []uint64, embeds ...string) error

func (*Hub) Reply

func (h *Hub) Reply(ctx context.Context, targetMsg *farcasterapi.APIMessage,
	content string, mentionFIDs []uint64, embeds ...string,
) error

Reply method sends a reply to the given targetFid and targetHash with the given content.

func (*Hub) SetFarcasterUser

func (h *Hub) SetFarcasterUser(fid uint64, signerPrivKey string) error

SetFarcasterUser sets the farcaster user with the given fid and signer privateKey in hex.

func (*Hub) SignersFromFID

func (h *Hub) SignersFromFID(fid uint64) ([]string, error)

SignersFromFID method returns the signers for the given FID. It returns a slice of signers and an error. Hub does not implement this method.

func (*Hub) Stop

func (h *Hub) Stop() error

Stop stops the API Hub. It does nothing.

func (*Hub) UserDataByFID

func (h *Hub) UserDataByFID(ctx context.Context, fid uint64) (*farcasterapi.Userdata, error)

UserDataByFID method returns the user data for the given FID. It includes the username, the custody address, the verification addresses and the signers.

func (*Hub) UserDataByVerificationAddress

func (h *Hub) UserDataByVerificationAddress(ctx context.Context, address []string) ([]*farcasterapi.Userdata, error)

UserDataByVerificationAddress method returns the user data for the given verification addresses. It returns a slice of user data and an error. Hub does not implement this method.

func (*Hub) UserFollowers

func (h *Hub) UserFollowers(ctx context.Context, fid uint64) ([]uint64, error)

UserFollowers method returns the FIDs of the followers of the user with the given id. If something goes wrong, it returns an error.

func (*Hub) WebhookHandler

func (h *Hub) WebhookHandler(_ []byte) error

WebhookHandler method handles the incoming webhooks. Hub does not implement this method.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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