actions

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2021 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AvailableFeeds = []models.MangaFeed{
	{
		Code: 1,
		Name: "Manga Reader",
		URL:  "http://manga-reader.fun",
	},
	{
		Code: 2,
		Name: "Manganelo",
		URL:  "https://manganelo.com",
	},
	{
		Code: 3,
		Name: "Manga Eden",
		URL:  "https://mangaeden.com",
	},
	{
		Code: 4,
		Name: "Kissmanga",
		URL:  "https://kissmanga.org",
	},
	{
		Code: 5,
		Name: "Mangadex",
		URL:  "https://mangadex.org",
	},
}

AvailableFeeds defines information for all current available manga feeds.

Functions

func AddFeedSubscription

func AddFeedSubscription(db *models.DatabaseConfig, chatID int64, feed models.MangaFeed) error

AddFeedSubscription method creates a new record in the manga_feed collection for a specific Chat. It checks the collection for any previous feed subscriptions, if the chat already have one it gets replaced, otherwise a new subscription is created. No Chat should have more than one subscription at a time.

func GetChatMangaFeed

func GetChatMangaFeed(db *models.DatabaseConfig, chatID int64) int

GetChatMangaFeed method returns the Manga Feed code that a Chat is currently cubscribed to. If the chat is not subscribed to any feeds the method defaults to feed 1 (Manga Reader). It returns 0 (invalid feed) if the DatabaseConfig parameter is nil or if any unhandled errors occured while querying the collection.

func GetChatSubscriptions

func GetChatSubscriptions(db *models.DatabaseConfig, chatID int64) ([]*models.Subscription, error)

GetChatSubscriptions method returns a slice of subscriptions attached to a specific chat ID. This receives a DatabaseConfig struct and a chatID parameter. It might return an error if the DatabaseConfig parameter is nil or if any error is returned by querying the database.

func GetMangaUpdates

func GetMangaUpdates(job *models.Job, bot *tb.Bot)

GetMangaUpdates function runs a goroutine every 6h. The goroutine queries the subscription collection and looks for new chapters. If a new chapter is found, a message is sent to the Chat that got subscribed to the title.

func RemoveMangaSubscription

func RemoveMangaSubscription(db *models.DatabaseConfig, subscriptionID string) error

RemoveMangaSubscription method deletes a subscription using the ID of said subscription. This receives a DatabaseConfig struct and a subscriptionID parameter. It might return an error if the DatabaseConfig parameter is nil or if any error is returned by querying the database.

Types

type MangaFeedInterface

type MangaFeedInterface interface {
	QueryManga(string) *models.ApiQuerySuggestions
	ViewManga() string
	Subscribe(subscription *models.Subscription) error
	GetLastMangaChapter(string) (string, error)
}

MangaFeedInterface defines the interface to all methods in the different manga sources.

func NewMangaInterface

func NewMangaInterface(src int, db *models.DatabaseConfig) MangaFeedInterface

NewMangaInterface function creates a new MangaFeedInterface interface ready to use.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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