Documentation ¶
Index ¶
- func CheckFileExtension(filename string, req SourceType) bool
- func ParseKeywords(s string) func(string) bool
- type APIController
- type APIRequester
- type APIWorker
- type APIWorkerDvach
- type File
- type ListResponse
- type Post
- type RequestURL
- type Requester
- type SourceType
- type Thread
- type ThreadData
- type ThreadPost
- type UserRequest
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 ¶
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 ListResponse ¶
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 ¶
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 ¶
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