rss2masto

package module
v1.0.9 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2023 License: MIT Imports: 25 Imported by: 0

README

rss2masto

Go Report Card Release Go Reference GitHub go.mod Go version License

Publish a RSS feed to Mastodon status

Installation

Go modules

If your application uses Go modules for dependency management (recommended), add an import for each service that you use in your application.

Example:

import (
  "github.com/glaydus/rss2masto"
)

Next, run go build or go mod tidy to download and install the new dependencies and update your application's go.mod file.

go get command

Alternatively, you can use the go get command to download and install the appropriate packages that your application uses:

go get -u github.com/glaydus/rss2masto

Code example

package main

import (
	"log"

	"github.com/glaydus/rss2masto"
)

func main() {
	fm, err := rss2masto.NewFeedsMonitor()
	if err != nil {
		log.Fatalln(err)
	}
	fm.Start()
}

Documentation

Index

Constants

View Source
const DefaultCharacterLimit = 500 // default mastodon max character limit
View Source
const DefaultCheckInterval = 10 // default check feed interval in minutes

Variables

This section is empty.

Functions

This section is empty.

Types

type CacheClient added in v1.0.6

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

func Cache added in v1.0.6

func Cache() *CacheClient

Cache returns a singleton instance of CacheClient

func (*CacheClient) Clear added in v1.0.6

func (c *CacheClient) Clear() error

Clear clears all keys in redis

func (*CacheClient) Exists added in v1.0.6

func (c *CacheClient) Exists(key string) bool

Exists checks if a key exists in redis

func (*CacheClient) Get added in v1.0.6

func (c *CacheClient) Get(key string) (string, error)

Get gets a value from redis

func (*CacheClient) GetBytes added in v1.0.6

func (c *CacheClient) GetBytes(key string) ([]byte, error)

GetBytes gets a value from redis as bytes

func (*CacheClient) GetEx added in v1.0.6

func (c *CacheClient) GetEx(key string, expiration time.Duration) (string, error)

GetEx gets a value from redis with an expiration

func (*CacheClient) GetKeys added in v1.0.6

func (c *CacheClient) GetKeys(keyPattern string, count ...int64) ([]string, error)

GetKeys gets all keys matching a pattern

func (*CacheClient) Set added in v1.0.6

func (c *CacheClient) Set(key string, value interface{}, expiration time.Duration) error

Set sets a key-value pair in redis

type Feed

type Feed struct {
	Name        string       `yaml:"name"`
	FeedUrl     string       `yaml:"url"`
	Token       string       `yaml:"token"`
	Prefix      string       `yaml:"prefix,omitempty"`
	Visibility  string       `yaml:"visibility,omitempty"`
	HashLink    string       `yaml:"hashlink,omitempty"`
	ReplaceFrom string       `yaml:"replace_from,omitempty"`
	ReplaceTo   string       `yaml:"replace_to,omitempty"`
	Interval    int64        `yaml:"interval,omitempty"`
	LastRun     int64        `yaml:"last_run,omitempty"`
	Count       int64        `yaml:"-"`
	Id          int64        `yaml:"-"`
	Followers   atomic.Int64 `yaml:"-"`
	Progress    atomic.Int64 `yaml:"-"`
	SendTime    time.Time    `yaml:"-"`
}

type FeedsMonitor

type FeedsMonitor struct {
	Instance struct {
		URL      string  `yaml:"url"`
		Lang     string  `yaml:"lang"`
		Limit    int     `yaml:"limit"`
		TimeZone string  `yaml:"timezone"`
		Save     bool    `yaml:"save,omitempty"`
		Monit    int64   `yaml:"last_monit,omitempty"`
		Feeds    []*Feed `yaml:"feed"`
	} `yaml:"instance"`
	// contains filtered or unexported fields
}

func NewFeedsMonitor

func NewFeedsMonitor() (*FeedsMonitor, error)

func (*FeedsMonitor) FeedIndex added in v1.0.6

func (fm *FeedsMonitor) FeedIndex(name string) int

func (*FeedsMonitor) LastCheck added in v1.0.7

func (fm *FeedsMonitor) LastCheck() int64

func (*FeedsMonitor) LastCheckStr added in v1.0.7

func (fm *FeedsMonitor) LastCheckStr() string

func (*FeedsMonitor) LastMonit added in v1.0.6

func (fm *FeedsMonitor) LastMonit() int64

func (*FeedsMonitor) Location added in v1.0.6

func (fm *FeedsMonitor) Location() *time.Location

func (*FeedsMonitor) SaveFeedsData

func (fm *FeedsMonitor) SaveFeedsData() error

func (*FeedsMonitor) Start

func (fm *FeedsMonitor) Start()

func (*FeedsMonitor) UpdateFollowers added in v1.0.6

func (fm *FeedsMonitor) UpdateFollowers()

Jump to

Keyboard shortcuts

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