mastodon

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AppName    = "shipdon"
	AppWebsite = "https://github.com/kpfaulkner/shipdon"

	// get 20 messages at a time.
	MastodonLimit   = 20
	MastodonSleepMS = 100
)

Variables

View Source
var (
	AccountID mastodon.ID
)

Functions

func String

func String(length int) string

func StringWithCharset

func StringWithCharset(length int, charset string) string

Types

type List

type List struct {
	Name string
}

func NewList

func NewList() *List

type MastodonBackend

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

func NewMastodonBackend

func NewMastodonBackend(eventListener *events.EventListener, config *config.Config) (*MastodonBackend, error)

func (*MastodonBackend) Boost

func (c *MastodonBackend) Boost(id mastodon.ID, boost bool) error

Boost or unboost a toot

func (*MastodonBackend) ClearSearch

func (c *MastodonBackend) ClearSearch() error

clear search results.

func (*MastodonBackend) GenerateConfigWithCode

func (c *MastodonBackend) GenerateConfigWithCode(code string) error

generateConfigWithCode generates the config for Shipdon.

func (*MastodonBackend) GenerateOAuthLoginURL

func (c *MastodonBackend) GenerateOAuthLoginURL(instanceURL string) (string, error)

generateOAuthLoginURL will create a URL for the user to visit to authenticate.

func (*MastodonBackend) GetAccountIDByUserName

func (c *MastodonBackend) GetAccountIDByUserName(username string) (interface{}, interface{})

GetAccountIDByUserName get the account ID by username.

func (*MastodonBackend) GetLists

func (c *MastodonBackend) GetLists() ([]*mastodon.List, error)

GetLists get all the lists that we're subscribed to.

func (*MastodonBackend) GetThread

func (c *MastodonBackend) GetThread(statusID int64) ([]mastodon.Status, error)

GetThread (ie list of status which are related by replies

func (*MastodonBackend) GetTimeline

func (c *MastodonBackend) GetTimeline(timelineID string) ([]mastodon.Status, error)

GetTimeline get all messages for main timeline.

func (*MastodonBackend) LoginWithOAuth2

func (c *MastodonBackend) LoginWithOAuth2() error

LoginWithOAuth2 login to Mastodon using OAuth2 Can only log in if the config file has appID, appSecret, instance and Token info

func (*MastodonBackend) LoginWithPassword

func (c *MastodonBackend) LoginWithPassword(username string, password string) error

LoginWithPassword logs in to Mastodon using username + password combination The username/password are stored in PLAIN TEXT in the config file. It is NOT recommended to use this method. TODO(kpfaulkner) secure password in SOME fashion.

func (*MastodonBackend) Logoff

func (c *MastodonBackend) Logoff() error

Logoff from Mastodon

func (*MastodonBackend) Post

func (c *MastodonBackend) Post(msg string, replyStatusID mastodon.ID) error

Post new message to Mastodon

func (*MastodonBackend) RefreshMessagesCallback

func (c *MastodonBackend) RefreshMessagesCallback(e events.Event) error

RefreshMessagesCallback refreshes the messages for a specific timeline. If the RefreshEvent.GetOlder is set, then we actually want to get older messages (due to user having scrolled back and wanting to see older messages) Was originally going to try and get all timelines... but will just do whatever the timeline passed in in the event. Will just trigger multiple events... one per timeline

func (*MastodonBackend) Search

func (c *MastodonBackend) Search(query string) (*mastodon.Results, error)

func (*MastodonBackend) SetFavourite

func (c *MastodonBackend) SetFavourite(id mastodon.ID, fav bool) error

Favourite a toot

type TimelineCache

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

func NewTimelineCache

func NewTimelineCache() *TimelineCache

func (*TimelineCache) AddToTimeline

func (tc *TimelineCache) AddToTimeline(timeline string, clearExisting bool, messages []mastodon.Status, shouldSort bool) error

func (*TimelineCache) ClearTimeline

func (tc *TimelineCache) ClearTimeline(timeline string) error

func (*TimelineCache) GetAllStatusForTimeline

func (tc *TimelineCache) GetAllStatusForTimeline(timelineID string) []mastodon.Status

func (*TimelineCache) GetTimelineDetails

func (tc *TimelineCache) GetTimelineDetails(timelineID string) (TimelineDetails, bool)

func (*TimelineCache) LogCacheDetails

func (tc *TimelineCache) LogCacheDetails()

func (*TimelineCache) PrintStats added in v0.1.2

func (tc *TimelineCache) PrintStats() error

func (*TimelineCache) UpdateTimeline

func (tc *TimelineCache) UpdateTimeline(timelineID string, sinceID mastodon.ID, messages []mastodon.ID)

type TimelineDetails

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

Jump to

Keyboard shortcuts

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