fedilib

package module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2024 License: GPL-3.0 Imports: 8 Imported by: 5

README

FediLib

a simple helper for my mastodon bots:

Documentation

Index

Constants

View Source
const (
	DefaultUserAgent = "fedilib/0.01 (2024-03-23)"
)

Variables

This section is empty.

Functions

func StripHtml

func StripHtml(reader io.Reader) (string, error)

func StripHtmlFromNode

func StripHtmlFromNode(nd *html.Node) string

func StripHtmlFromString

func StripHtmlFromString(in string) (string, error)

Types

type Application

type Application interface {
	HandleNotification(n *mastodon.Notification)
}

type Config

type Config struct {
	// https://botsin.space
	Server string `yaml:"server,omitempty" json:"server,omitempty"`
	// Client key: kZoi323…
	ClientID string `yaml:"client_id,omitempty" json:"client_id,omitempty"`
	// Client secret: ose…
	ClientSecret string `yaml:"client_secret,omitempty" json:"client_secret,omitempty"`
	// Application name: fedilpd
	ClientName string `yaml:"client_name,omitempty" json:"client_name,omitempty"`
	// Scopes: read write follow
	Scopes string `yaml:"scopes,omitempty" json:"scopes,omitempty"`
	// Application website: https://berlin.de/presse
	Website string `yaml:"website,omitempty" json:"website,omitempty"`
	// Redirect URI: urn:ietf:wg:oauth:2.0:oob
	RedirectURI string `yaml:"redirect_uri,omitempty" json:"redirect_uri,omitempty"`
	// Your access token: Rdn…
	Token     string `yaml:"token,omitempty" json:"token,omitempty"`
	UserAgent string `yaml:"user_agent,omitempty" json:"user_agent,omitempty"`
}

type Fedi

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

func (*Fedi) Client

func (s *Fedi) Client() *mastodon.Client

func (*Fedi) Ctx

func (s *Fedi) Ctx() context.Context

func (*Fedi) CurrentAccount

func (s *Fedi) CurrentAccount() *mastodon.Account

func (*Fedi) GetList

func (s *Fedi) GetList(title string) *mastodon.List

func (*Fedi) Init

func (s *Fedi) Init(cfg *Config, app Application, log *log.Logger)

func (*Fedi) IsFollower

func (s *Fedi) IsFollower(account *mastodon.Account) error

func (*Fedi) Log

func (s *Fedi) Log() *log.Logger

func (*Fedi) MarkAccount

func (s *Fedi) MarkAccount(account *mastodon.Account, mark string) error

func (*Fedi) ProcessNotifications

func (s *Fedi) ProcessNotifications()

func (*Fedi) TootWithImage

func (s *Fedi) TootWithImage(toot mastodon.Toot, ipath string) (err error)

TootWithImage posts a new status with image (unless empty)

func (*Fedi) TootWithImageReader

func (s *Fedi) TootWithImageReader(toot mastodon.Toot, img io.Reader, alt string) error

TootWithImage posts a new status with image (unless empty)

func (*Fedi) WSClient

func (s *Fedi) WSClient() *mastodon.WSClient

func (*Fedi) WatchNotifications

func (s *Fedi) WatchNotifications()

type Toot

type Toot interface {
	TootWithImageReader(toot mastodon.Toot, img io.Reader, alt string) error
	TootWithImage(toot mastodon.Toot, ipath string) error
}

Jump to

Keyboard shortcuts

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