atom

package
v0.0.0-...-966265d Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2023 License: MIT Imports: 15 Imported by: 0

README

Atom is a simple library that makes liking posts on juweitong a little easier.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrQRLoginAlreadyStarted = errors.New("qr login already started")
	ErrNotLoggedIn           = errors.New("not logged in")
)

Functions

This section is empty.

Types

type Client

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

func NewClient

func NewClient(history LikedPostsHistory) *Client

NewClient creates a client with the DAO. A DAO is used for speeding up the liking process by ignoring already liked posts.

func (*Client) Communities

func (cli *Client) Communities() []Community

func (*Client) CurrentCommunity

func (cli *Client) CurrentCommunity() Community

func (*Client) CurrentCommunityIndex

func (cli *Client) CurrentCommunityIndex() int

func (*Client) GetCommunityById

func (cli *Client) GetCommunityById(id string) (Community, bool)

func (*Client) Id

func (cli *Client) Id() string

func (*Client) IsLoggedIn

func (cli *Client) IsLoggedIn() bool

func (*Client) LikeCCPPosts

func (cli *Client) LikeCCPPosts(count int) int

func (*Client) LikeMoments

func (cli *Client) LikeMoments(count int) int

func (*Client) LikeNotices

func (cli *Client) LikeNotices(count int) int

LikeNotices visits count of the latest notices and returns the number of posts that have been liked

func (*Client) LikeProposals

func (cli *Client) LikeProposals(count int) int

func (*Client) SetCurrentCommunity

func (cli *Client) SetCurrentCommunity(i int) error

SetCurrentCommunity sets the current community at the given index

func (*Client) SetCurrentCommunityById

func (cli *Client) SetCurrentCommunityById(id string) error

func (*Client) SetTimeout

func (cli *Client) SetTimeout(d time.Duration)

func (*Client) StartQRLogin

func (cli *Client) StartQRLogin(onLogin LoginHandler) (string, error)

StartQRLogin starts the qr login process and returns the url of the qr code. If the login already started, ErrQRLoginAlreadyStarted is returned

func (*Client) StopQRLogin

func (cli *Client) StopQRLogin()

type Community

type Community struct {
	Name     string `json:"value"` // name of the community
	MemberId string `json:"key"`   // member id in this community
}

type LikedPost

type LikedPost struct {
	MemberId string
	PostId   string
}

type LikedPostsHistory

type LikedPostsHistory interface {
	Has(post LikedPost) (bool, error)
	Add(post LikedPost) error
}

type LoginHandler

type LoginHandler func()

type NullLikedPostsHistory

type NullLikedPostsHistory struct{}

func (NullLikedPostsHistory) Add

func (NullLikedPostsHistory) Has

func (o NullLikedPostsHistory) Has(post LikedPost) (bool, error)

Jump to

Keyboard shortcuts

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