dvach

package
v0.0.0-...-077edd7 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckFileExtension

func CheckFileExtension(filename string, req SourceType) bool

CheckFileExtension returns true if filename is user's selected type

func ParseKeywords

func ParseKeywords(s string) func(string) bool

ParseKeywords retruns function to validate keywords

Types

type APIController

type APIController struct {
	APIWorker
}

APIController for accessing external api

func NewAPIController

func NewAPIController(cnt *controller.Controller, snd telegram.Sender, req Requester) *APIController

NewAPIController constructor of APIController

type APIRequester

type APIRequester struct {
	Requests *RequestURL
}

APIRequester gets data from 2ch

func NewRequester

func NewRequester(u *RequestURL) *APIRequester

NewRequester constructor for APIRequester

func (*APIRequester) GetAllThreads

func (r *APIRequester) GetAllThreads(board string) ListResponse

GetAllThreads returns list of all threads on board

func (*APIRequester) GetResourceURL

func (r *APIRequester) GetResourceURL(path string) string

GetResourceURL converts relative resource path to absolute

func (*APIRequester) GetThread

func (r *APIRequester) GetThread(board, threadID string) ThreadData

GetThread returns list of posts in the thread with id = threadID

type APIWorker

type APIWorker interface {
	InitiateSending()
}

APIWorker for working with external api

type APIWorkerDvach

type APIWorkerDvach struct {
	Sender    telegram.Sender
	Requester Requester
	// contains filtered or unexported fields
}

APIWorkerDvach represents struct to work with external api

func NewAPIWorkerDvach

func NewAPIWorkerDvach(cnt *controller.Controller, snd telegram.Sender, req Requester) *APIWorkerDvach

NewAPIWorkerDvach constructor for APIWorkerDvach

func (*APIWorkerDvach) InitiateSending

func (dw *APIWorkerDvach) InitiateSending()

InitiateSending loads data from server and sending it to users

type File

type File struct {
	Name string `json:"name"`
	Path string `json:"path"`
	Size int    `json:"size"`
}

File constains file data

type ListResponse

type ListResponse struct {
	Board   string   `json:"board"`
	Threads []Thread `json:"threads"`
}

ListResponse contains struct to be returned when reading all threads

type Post

type Post struct {
	Comment   string `json:"comment"`
	Date      string `json:"date"`
	Timestamp uint64 `json:"timestamp"`
	Files     []File `json:"files"`
}

Post contains post data

type RequestURL

type RequestURL struct {
	AllThreadsURL string
	ThreadURL     string
	ResourceURL   string
}

RequestURL describes endpoints of external api

type Requester

type Requester interface {
	GetAllThreads(board string) ListResponse
	GetThread(board, threadID string) ThreadData
	GetResourceURL(path string) string
}

Requester gets data from external sources

type SourceType

type SourceType struct {
	Image bool
	Gif   bool
	Webm  bool
}

SourceType specify user's file extensions choice

func ParseTypes

func ParseTypes(s string) SourceType

ParseTypes returns types from s as [.img.gif.webm]

type Thread

type Thread struct {
	Comment   string  `json:"comment"`
	Lasthit   int64   `json:"lasthit"`
	ID        uint64  `json:"num"`
	PostCount int     `json:"posts_count"`
	Score     float64 `json:"score"`
	Subject   string  `json:"subject"`
	Timestamp uint64  `json:"timestamp"`
	Views     int     `json:"views"`
}

Thread contains thread header

type ThreadData

type ThreadData struct {
	ThreadPosts []ThreadPost `json:"threads"`
}

ThreadData contains every thread data

type ThreadPost

type ThreadPost struct {
	Posts []Post `json:"posts"`
}

ThreadPost stores info about thread's posts

type UserRequest

type UserRequest struct {
	User    *logic.User
	Request SourceType
}

UserRequest stores information about user and it's requested file types in thread

Directories

Path Synopsis
mock
requester
Package mock_dvach is a generated GoMock package.
Package mock_dvach is a generated GoMock package.
sender
Package mock_telegram is a generated GoMock package.
Package mock_telegram is a generated GoMock package.

Jump to

Keyboard shortcuts

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