pttbbs

package
v0.0.0-...-b34ddb9 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ArticleAuthor = "作者"
	ArticleTitle  = "標題"

	AllPostBrdName = "ALLPOST"
)
View Source
const (
	FileLocal = 1 << iota
	FileMarked
	FileDigest
	FileBottom
	FileSolved
)

Non-mail file modes

View Source
const (
	FileRead = 1 << iota

	FileReplied
	FileMulti
)

Mail file modes

View Source
const (
	SelectPart SelectMethod = `articlepart`
	SelectHead              = `articlehead`
	SelectTail              = `articletail`
)
View Source
const (
	BoardGroup  uint32 = 0x00000008
	BoardOver18        = 0x01000000
)

Variables

View Source
var (
	ArticleFirstLineRegexp = regexp.MustCompile(`^(.+?): (.+) (.+?): (.+?)\n$`)
	ArticleMetaLineRegexp  = regexp.MustCompile(`^(.+?): (.+)\n$`)

	QuotePrefixStrings     = []string{": ", "> "}
	SignaturePrefixStrings = []string{"※", "==>"}

	ArticlePushPrefixStrings = []string{"推 ", "噓 ", "→ "}
)
View Source
var (
	ErrInvalidAid = errors.New("invalid aid")
)
View Source
var (
	ErrNotFound = errors.New("not found")
)

Functions

func BrdNameFromAllPostTitle

func BrdNameFromAllPostTitle(title string) (string, bool)

BrdNameFromAllPostTitle returns the board name parsed from the post title in ALLPOST board.

func IsValidArticleFileName

func IsValidArticleFileName(filename string) bool

func IsValidBrdName

func IsValidBrdName(brdname string) bool

func IsValidUserID

func IsValidUserID(userID string) bool

func MatchPrefixBytesToStrings

func MatchPrefixBytesToStrings(str []byte, patts []string) bool

func ParseArticleFirstLine

func ParseArticleFirstLine(line []byte) (tag1, val1, tag2, val2 []byte, ok bool)

func ParseArticleMetaLine

func ParseArticleMetaLine(line []byte) (tag, val []byte, ok bool)

func ParseFileNameTime

func ParseFileNameTime(filename string) (time.Time, error)

func Subject

func Subject(subject string) string

Types

type Aid

type Aid uint64

func ParseAid

func ParseAid(s string) (Aid, error)

func (Aid) Filename

func (aid Aid) Filename() string

func (Aid) String

func (aid Aid) String() string

type Article

type Article struct {
	Offset    int
	FileName  string
	Date      string
	Recommend int
	FileMode  int
	Owner     string
	Title     string
	Modified  time.Time
}

type ArticlePart

type ArticlePart struct {
	CacheKey string
	FileSize int
	Offset   int
	Length   int
	Content  []byte
}

type Board

type Board struct {
	Bid      BoardID
	IsBoard  bool
	Over18   bool
	Hidden   bool
	BrdName  string
	Title    string
	Class    string
	BM       string
	Parent   int
	Nuser    int
	NumPosts int
	Children []BoardID
}

func OneBoard

func OneBoard(boards []Board, err error) (Board, error)

func (Board) Ref

func (b Board) Ref() BoardRef

type BoardID

type BoardID uint32

type BoardRef

type BoardRef interface {
	// contains filtered or unexported methods
}

func BoardRefByBid

func BoardRefByBid(bid BoardID) BoardRef

func BoardRefByName

func BoardRefByName(name string) BoardRef

func BoardRefsByBid

func BoardRefsByBid(bids []BoardID) []BoardRef

type GrpcRemotePtt

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

func NewGrpcRemotePtt

func NewGrpcRemotePtt(boarddAddr string) (*GrpcRemotePtt, error)

func (*GrpcRemotePtt) GetArticleList

func (p *GrpcRemotePtt) GetArticleList(ref BoardRef, offset, length int) ([]Article, error)

func (*GrpcRemotePtt) GetArticleSelect

func (p *GrpcRemotePtt) GetArticleSelect(ref BoardRef, meth SelectMethod, filename, cacheKey string, offset, maxlen int) (*ArticlePart, error)

func (*GrpcRemotePtt) GetBoards

func (p *GrpcRemotePtt) GetBoards(brefs ...BoardRef) ([]Board, error)

func (*GrpcRemotePtt) GetBottomList

func (p *GrpcRemotePtt) GetBottomList(ref BoardRef) ([]Article, error)

func (*GrpcRemotePtt) Hotboards

func (p *GrpcRemotePtt) Hotboards() ([]Board, error)

func (*GrpcRemotePtt) Search

func (p *GrpcRemotePtt) Search(ref BoardRef, preds []SearchPredicate, offset, length int) ([]Article, int, error)

type Pttbbs

type Pttbbs interface {
	GetBoards(refs ...BoardRef) ([]Board, error)
	GetArticleList(ref BoardRef, offset, length int) ([]Article, error)
	GetBottomList(ref BoardRef) ([]Article, error)
	GetArticleSelect(ref BoardRef, meth SelectMethod, filename, cacheKey string, offset, maxlen int) (*ArticlePart, error)
	Hotboards() ([]Board, error)
	Search(ref BoardRef, preds []SearchPredicate, offset, length int) (articles []Article, totalPosts int, err error)
}

type SearchPredicate

type SearchPredicate interface {
	// contains filtered or unexported methods
}

func WithAuthor

func WithAuthor(author string) SearchPredicate

func WithExactTitle

func WithExactTitle(title string) SearchPredicate

func WithRecommend

func WithRecommend(n int) SearchPredicate

func WithTitle

func WithTitle(title string) SearchPredicate

type SelectMethod

type SelectMethod string

Jump to

Keyboard shortcuts

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