imb_4chan

package
v0.0.0-...-921f456 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseBoards

func ParseBoards(body []byte) []imageboard.Board

func ParseCatalog

func ParseCatalog(body []byte) *u.OrderedMap[int, imageboard.Thread]

func ParseThread

func ParseThread(body []byte, threadNumber int) (imageboard.Thread, error)

Types

type Board4chan

type Board4chan struct {
	Acronym  string
	Title    string
	Worksafe bool

	Threads *u.OrderedMap[int, imageboard.Thread]
}

func NewBoard4chan

func NewBoard4chan(board *Board4chanResponse) *Board4chan

func (Board4chan) GetAcronym

func (b Board4chan) GetAcronym() string

func (*Board4chan) GetThreads

func (b *Board4chan) GetThreads() *u.OrderedMap[int, imageboard.Thread]

func (Board4chan) GetTitle

func (b Board4chan) GetTitle() string

func (Board4chan) IsWorksafe

func (b Board4chan) IsWorksafe() bool

func (*Board4chan) RemoveThread

func (b *Board4chan) RemoveThread(postId int) bool

type Board4chanResponse

type Board4chanResponse struct {
	Acronym         string     `json:"board"`             // always, 	The directory the board is located in. 	Any string
	Title           string     `json:"title"`             // always, 	The readable title at the top of the board. 	Any string
	Worksafe        int        `json:"ws_board"`          // always, 	Is the board worksafe 	1 or 0
	PerPage         int32      `json:"per_page"`          // always, 	How many threads are on a single index page 	Any positive integer
	Pages           int32      `json:"pages"`             // always, 	How many index pages does the board have 	Any positive integer
	MaxFilesize     int32      `json:"max_filesize"`      // always, 	Maximum file size allowed for non .webm attachments (in KB) 	Any positive integer
	MaxWebmFilesize int32      `json:"max_webm_filesize"` // always, 	Maximum file size allowed for .webm attachments (in KB) 	Any positive integer
	MaxCommentChars int32      `json:"max_comment_chars"` // always, 	Maximum number of characters allowed in a post comment 	Any positive integer
	MaxWebmDuration int32      `json:"max_webm_duration"` // always, 	Maximum duration of a .webm attachment (in seconds) 	Any positive integer
	BumpLimit       int32      `json:"bump_limit"`        // always, 	Maximum number of replies allowed to a thread before the thread stops bumping 	Any positive integer
	ImageLimit      int32      `json:"image_limit"`       // always, 	Maximum number of image replies per thread before image replies are discarded 	Any positive integer
	Cooldowns       []Cooldown `json:"cooldowns"`         // always,
	MetaDescription int32      `json:"meta_description"`  // always, 	SEO meta description content for a board 	Any string

	Spoilers       int32             `json:"spoilers"`         // only if enabled, 	Are spoilers enabled 	1 or 0
	CustomSpoilers int32             `json:"custom_spoilers"`  // only if enabled, 	How many custom spoilers does the board have 	Any positive integer
	IsArchived     int32             `json:"is_archived"`      // only if enabled, 	Are archives enabled for the board 	1 or 0
	BoardFlags     map[string]string `json:"board_flags"`      // only if enabled, 	Array of flag codes mapped to flag names
	CountryFlags   int32             `json:"country_flags"`    // only if enabled, 	Are flags showing the poster's country enabled on the board 	1 or 0
	UserIds        int32             `json:"user_ids"`         // only if enabled, 	Are poster ID tags enabled on the board 	1 or 0
	Oekaki         int32             `json:"oekaki"`           // only if enabled, 	Can users submit drawings via browser the Oekaki app 	1 or 0
	SjisTags       int32             `json:"sjis_tags"`        // only if enabled, 	Can users submit sjis drawings using the [sjis] tags 	1 or 0
	CodeTags       int32             `json:"code_tags"`        // only if enabled, 	Board supports code syntax highlighting using the [code] tags 	1 or 0
	MathTags       int32             `json:"math_tags"`        // only if enabled, 	Board supports [math] TeX and [eqn] tags 	1 or 0
	TextOnly       int32             `json:"text_only"`        // only if enabled, 	Is image posting disabled for the board 	1 or 0
	ForcedAnon     int32             `json:"forced_anon"`      // only if enabled, 	Is the name field disabled on the board 	1 or 0
	WebmAudio      int32             `json:"webm_audio"`       // only if enabled, 	Are webms with audio allowed? 	1 or 0
	RequireSubject int32             `json:"require_subject"`  // only if enabled, 	Do OPs require a subject 	1 or 0
	MinImageWidth  int32             `json:"min_image_width"`  // only if enabled, 	What is the minimum image width (in pixels) 	Any positive integer
	MinImageHeight int32             `json:"min_image_height"` // only if enabled, 	What is the minimum image height (in pixels) 	Any positive integer
}

type Boards4chanResponse

type Boards4chanResponse struct {
	Boards []*Board4chanResponse `json:"boards"`
}

type Catalog4chanResponse

type Catalog4chanResponse struct {
	Page    int32 `json:"page"`
	Threads []*Thread4chanResponse
}

type Cooldown

type Cooldown struct {
	Threads int32 `json:"threads"`
	Replies int32 `json:"replies"`
	Images  int32 `json:"images"`
}

type File4chan

type File4chan struct {
	Tim           string
	Filename      string
	Ext           string
	Fsize         int64
	Md5           string
	W             int
	H             int
	TnW           int32
	TnH           int32
	Deleted       bool
	Spoiler       bool
	CustomSpoiler int32
}

func (File4chan) GetCustomSpoiler

func (f File4chan) GetCustomSpoiler() int32

func (File4chan) GetExt

func (f File4chan) GetExt() string

func (File4chan) GetFilename

func (f File4chan) GetFilename() string

func (File4chan) GetFilesize

func (f File4chan) GetFilesize() int64

func (File4chan) GetHeight

func (f File4chan) GetHeight() int

func (File4chan) GetTim

func (f File4chan) GetTim() string

func (File4chan) GetWidth

func (f File4chan) GetWidth() int

func (File4chan) IsDeleted

func (f File4chan) IsDeleted() bool

func (File4chan) IsSpoiler

func (f File4chan) IsSpoiler() bool

type Imageboard4chan

type Imageboard4chan struct {
	Name           string
	Configurations *imageboard.ImageboardConfigurations
	MyBoards       *u.OrderedMap[string, imageboard.Board]
	Boards         *u.OrderedMap[string, imageboard.Board]
}

func (*Imageboard4chan) GetBoards

func (ib *Imageboard4chan) GetBoards() *u.OrderedMap[string, imageboard.Board]

func (Imageboard4chan) GetCatalogURI

func (ib Imageboard4chan) GetCatalogURI(b imageboard.Board) string

func (Imageboard4chan) GetConfigurations

func (ib Imageboard4chan) GetConfigurations() *imageboard.ImageboardConfigurations

func (Imageboard4chan) GetDeletedURI

func (ib Imageboard4chan) GetDeletedURI() string

func (Imageboard4chan) GetImageURL

func (ib Imageboard4chan) GetImageURL(boardAcronym string, tim string, ext string) string

func (*Imageboard4chan) GetMyBoards

func (ib *Imageboard4chan) GetMyBoards() *u.OrderedMap[string, imageboard.Board]

func (Imageboard4chan) GetName

func (ib Imageboard4chan) GetName() string

func (Imageboard4chan) GetSpoilerURI

func (ib Imageboard4chan) GetSpoilerURI() string

func (Imageboard4chan) GetThreadURI

func (ib Imageboard4chan) GetThreadURI(b imageboard.Board, threadNumber int) string

func (Imageboard4chan) GetThumbnailURL

func (ib Imageboard4chan) GetThumbnailURL(boardAcronym string, tim string, ext string) string

func (*Imageboard4chan) Initialize

func (ib *Imageboard4chan) Initialize()

func (*Imageboard4chan) RequestBoards

func (ib *Imageboard4chan) RequestBoards() ([]imageboard.Board, error)

func (Imageboard4chan) RequestCatalog

func (ib Imageboard4chan) RequestCatalog(board imageboard.Board) (*u.OrderedMap[int, imageboard.Thread], error)

func (Imageboard4chan) RequestPosts

func (ib Imageboard4chan) RequestPosts(b imageboard.Board, threadNumber int) (imageboard.Thread, error)

func (*Imageboard4chan) SetBoards

func (ib *Imageboard4chan) SetBoards(boardMap *u.OrderedMap[string, imageboard.Board])

func (*Imageboard4chan) SetMyBoards

func (ib *Imageboard4chan) SetMyBoards(boardMap *u.OrderedMap[string, imageboard.Board])

type Post4chan

type Post4chan struct {
	OP     bool
	Number int

	Time        int64
	TimeEST_EDT string

	Name             string
	Subject          string
	RawComment       string
	SanitizedComment string

	Trip              string
	UserId            string
	Capcode           string
	Country           string
	TrollCountry      string
	CountryName       string
	IdBackgroundColor u.Color
	IdTextColor       u.Color

	NumPosts  int
	QuotedBy  []int
	RepliedTo []int
	Files     []imageboard.File
}

func NewPost4chan

func NewPost4chan(post *Post4chanResponse, threadNumber int, op bool) *Post4chan

func (Post4chan) GetEmbed

func (p Post4chan) GetEmbed() string

func (Post4chan) GetFiles

func (p Post4chan) GetFiles() []imageboard.File

func (Post4chan) GetIdBackgroundColor

func (p Post4chan) GetIdBackgroundColor() u.Color

func (Post4chan) GetIdTextColor

func (p Post4chan) GetIdTextColor() u.Color

func (Post4chan) GetName

func (p Post4chan) GetName() string

func (Post4chan) GetNumPosts

func (p Post4chan) GetNumPosts() int

func (Post4chan) GetNumReplies

func (p Post4chan) GetNumReplies() int

func (Post4chan) GetNumber

func (p Post4chan) GetNumber() int

func (Post4chan) GetQuotedBy

func (p Post4chan) GetQuotedBy() []int

func (Post4chan) GetRawComment

func (p Post4chan) GetRawComment() string

func (Post4chan) GetRepliedTo

func (p Post4chan) GetRepliedTo() []int

func (Post4chan) GetSubject

func (p Post4chan) GetSubject() string

func (Post4chan) GetTime

func (p Post4chan) GetTime() int64

func (Post4chan) GetTrip

func (p Post4chan) GetTrip() string

func (Post4chan) GetUserId

func (p Post4chan) GetUserId() string

func (Post4chan) HasFiles

func (p Post4chan) HasFiles() bool

func (Post4chan) IsEmbed

func (p Post4chan) IsEmbed() bool

func (Post4chan) IsOP

func (p Post4chan) IsOP() bool

func (*Post4chan) SetIdBackgroundColor

func (p *Post4chan) SetIdBackgroundColor(color u.Color)

func (*Post4chan) SetIdTextColor

func (p *Post4chan) SetIdTextColor(color u.Color)

func (*Post4chan) SetNumPosts

func (p *Post4chan) SetNumPosts(numPosts int)

func (*Post4chan) SetQuotedBy

func (p *Post4chan) SetQuotedBy(posts []int)

func (*Post4chan) SetRawComment

func (p *Post4chan) SetRawComment(comment string)

func (*Post4chan) SetRepliedTo

func (p *Post4chan) SetRepliedTo(posts []int)

type Post4chanResponse

type Post4chanResponse struct {
	Number        int    `json:"no"`             //always, 	The numeric post ID 	any positive integer
	Resto         int32  `json:"resto"`          //always, 	For replies: this is the ID of the thread being replied to. For OP: this value is zero 	0 or Any positive integer
	Sticky        int    `json:"sticky"`         //OP only, if thread is currently stickied 	If the thread is being pinned to the top of the page 	1 or not set
	Closed        int    `json:"closed"`         //OP only, if thread is currently closed 	If the thread is closed to replies 	1 or not set
	Now           string `json:"now"`            //always, 	MM/DD/YY(Day)HH:MM (:SS on some boards), EST/EDT timezone 	string
	Time          int64  `json:"time"`           //always, 	UNIX timestamp the post was created 	UNIX timestamp
	Name          string `json:"name"`           //always, 	Name user posted with. Defaults to Anonymous 	any string
	Trip          string `json:"trip"`           //if post has tripcode, 	The user's tripcode, in format: !tripcode or !!securetripcode 	any string
	Id            string `json:"id"`             //if post has ID, 	The poster's ID 	any 8 characters
	Capcode       string `json:"capcode"`        //if post has capcode, 	The capcode identifier for a post 	Not set, mod, admin, admin_highlight, manager, developer, founder
	Country       string `json:"country"`        //if country flags, are enabled 	Poster's ISO 3166-1 alpha-2 country code 	2 character string or XX if unknown
	TrollCountry  string `json:"troll_country"`  //if troll country flags, are enabled 	Poster's country name 	Name of any country
	CountryName   string `json:"country_name"`   //if country flags, are enabled 	Poster's country name 	Name of any country
	Subject       string `json:"sub"`            //OP only, if subject was included 	OP Subject text 	any string
	Comment       string `json:"com"`            //if comment was included, 	Comment (HTML escaped) 	any HTML escaped string
	Tim           int64  `json:"tim"`            //always, if post has attachment 	Unix timestamp + microtime that an image was uploaded 	integer
	Filename      string `json:"filename"`       //always, if post has attachment 	Filename as it appeared on the poster's device 	any string
	Ext           string `json:"ext"`            //always, if post has attachment 	Filetype 	.jpg, .png, .gif, .pdf, .swf, .webm
	Fsize         int64  `json:"fsize"`          //always, if post has attachment 	Size of uploaded file in bytes 	any integer
	Md5           string `json:"md5"`            //always, if post has attachment 	24 character, packed base64 MD5 hash of file
	W             int    `json:"w"`              //always, if post has attachment 	Image width dimension 	any integer
	H             int    `json:"h"`              //always, if post has attachment 	Image height dimension 	any integer
	TnW           int32  `json:"tn_w"`           //always, if post has attachment 	Thumbnail image width dimension 	any integer
	TnH           int32  `json:"tn_h"`           //always, if post has attachment 	Thumbnail image height dimension 	any integer
	Filedeleted   int    `json:"filedeleted"`    //if post had attachment and attachment is deleted, 	If the file was deleted from the post 	1 or not set
	Spoiler       int    `json:"spoiler"`        //if post has attachment and attachment is spoilered, 	If the image was spoilered or not 	1 or not set
	CustomSpoiler int32  `json:"custom_spoiler"` //if post has attachment and attachment is spoilered, 	The custom spoiler ID for a spoilered image 	1-10 or not set
	TotalReplies  int    `json:"replies"`        //OP only, 	Number of replies minus the number of previewed replies 	any integer
	Images        int    `json:"images"`         //OP only, 	Number of image replies minus the number of previewed image replies 	any integer
	Bumplimit     int    `json:"bumplimit"`      //OP only, only if bump limit has been reached 	If a thread has reached bumplimit, it will no longer bump 	1 or not set
	Imagelimit    int    `json:"imagelimit"`     //OP only, only if image limit has been reached 	If an image has reached image limit, no more image replies can be made 	1 or not set
	LastModified  int32  `json:"last_modified"`  //OP only, 	The UNIX timestamp marking the last time the thread was modified (post added/modified/deleted, thread closed/sticky settings modified) 	UNIX Timestamp
	Tag           string `json:"tag"`            //OP only, 	Total number of image replies to a thread 	any integer
	SemanticUrl   string `json:"semantic_url"`   //OP only, 	SEO URL slug for thread 	string
	Since4pass    int32  `json:"since4pass"`     //if poster put 'since4pass' in the options field, 	Year 4chan pass bought 	any 4 digit year
	UniqueIps     int32  `json:"unique_ips"`
	MImg          int32  `json:"m_img"` //OP only, /f/ only 	The category of .swf upload 	Game, Loop, etc..
	Archived      int32  `json:"archived"`
	ArchivedOn    int32  `json:"archived_on"`
	TailSize      int32  `json:"tail_size"`
	OmittedPosts  int32  `json:"omitted_posts"`  //OP only, 	Number of unique posters in a thread 	any integer
	OmittedImages int32  `json:"omitted_images"` //any post that has a mobile-optimized image, 	Mobile optimized image exists for post 	1 or not set

	LastReplies []*Post4chanResponse `json:"last_replies"` //catalog OP only, 	JSON representation of the most recent replies to a thread 	array of JSON post objects
}

type Thread4chan

type Thread4chan struct {
	Number int
	Sticky bool
	Closed bool

	Time        int64
	TimeEST_EDT string

	Name             string
	Subject          string
	RawComment       string
	SanitizedComment string

	Trip              string
	UserId            string
	Capcode           string
	Country           string
	TrollCountry      string
	CountryName       string
	IdBackgroundColor u.Color
	IdTextColor       u.Color

	TotalReplies int
	TotalImages  int
	Bumplimit    bool
	Imagelimit   bool
	LastModified int32

	Posts *u.OrderedMap[int, imageboard.Post]
	Files []imageboard.File
}

func NewThread4chan

func NewThread4chan(thread *Thread4chanResponse) *Thread4chan

func NewThread4chanFromPost

func NewThread4chanFromPost(post *Post4chanResponse) *Thread4chan

func (Thread4chan) GetEmbed

func (t Thread4chan) GetEmbed() string

func (Thread4chan) GetFiles

func (t Thread4chan) GetFiles() []imageboard.File

func (Thread4chan) GetName

func (t Thread4chan) GetName() string

func (Thread4chan) GetNumber

func (t Thread4chan) GetNumber() int

func (*Thread4chan) GetPosts

func (t *Thread4chan) GetPosts() *u.OrderedMap[int, imageboard.Post]

func (Thread4chan) GetRawComment

func (t Thread4chan) GetRawComment() string

func (Thread4chan) GetSanitizedComment

func (t Thread4chan) GetSanitizedComment() string

func (Thread4chan) GetSubject

func (t Thread4chan) GetSubject() string

func (Thread4chan) GetTotalImages

func (t Thread4chan) GetTotalImages() int

func (Thread4chan) GetTotalReplies

func (t Thread4chan) GetTotalReplies() int

func (Thread4chan) GetTrip

func (t Thread4chan) GetTrip() string

func (Thread4chan) GetUserId

func (t Thread4chan) GetUserId() string

func (Thread4chan) HasFiles

func (t Thread4chan) HasFiles() bool

func (Thread4chan) IsClosed

func (t Thread4chan) IsClosed() bool

func (Thread4chan) IsEmbed

func (t Thread4chan) IsEmbed() bool

func (Thread4chan) IsSticky

func (t Thread4chan) IsSticky() bool

func (*Thread4chan) SetIdBackgroundColor

func (t *Thread4chan) SetIdBackgroundColor(color u.Color)

func (*Thread4chan) SetIdTextColor

func (t *Thread4chan) SetIdTextColor(color u.Color)

func (*Thread4chan) SetRawComment

func (t *Thread4chan) SetRawComment(rawComment string)

type Thread4chanResponse

type Thread4chanResponse struct {
	Number        int    `json:"no"`             //always, 	The numeric post ID 	any positive integer
	Resto         int32  `json:"resto"`          //always, 	For replies: this is the ID of the thread being replied to. For OP: this value is zero 	0 or Any positive integer
	Sticky        int    `json:"sticky"`         //OP only, if thread is currently stickied 	If the thread is being pinned to the top of the page 	1 or not set
	Closed        int    `json:"closed"`         //OP only, if thread is currently closed 	If the thread is closed to replies 	1 or not set
	Now           string `json:"now"`            //always, 	MM/DD/YY(Day)HH:MM (:SS on some boards), EST/EDT timezone 	string
	Time          int64  `json:"time"`           //always, 	UNIX timestamp the post was created 	UNIX timestamp
	Name          string `json:"name"`           //always, 	Name user posted with. Defaults to Anonymous 	any string
	Trip          string `json:"trip"`           //if post has tripcode, 	The user's tripcode, in format: !tripcode or !!securetripcode 	any string
	Id            string `json:"id"`             //if post has ID, 	The poster's ID 	any 8 characters
	Capcode       string `json:"capcode"`        //if post has capcode, 	The capcode identifier for a post 	Not set, mod, admin, admin_highlight, manager, developer, founder
	Country       string `json:"country"`        //if country flags, are enabled 	Poster's ISO 3166-1 alpha-2 country code 	2 character string or XX if unknown
	TrollCountry  string `json:"troll_country"`  //if troll country flags, are enabled 	Poster's country name 	Name of any country
	CountryName   string `json:"country_name"`   //if country flags, are enabled 	Poster's country name 	Name of any country
	Subject       string `json:"sub"`            //OP only, if subject was included 	OP Subject text 	any string
	Comment       string `json:"com"`            //if comment was included, 	Comment (HTML escaped) 	any HTML escaped string
	Tim           int64  `json:"tim"`            //always, if post has attachment 	Unix timestamp + microtime that an image was uploaded 	integer
	Filename      string `json:"filename"`       //always, if post has attachment 	Filename as it appeared on the poster's device 	any string
	Ext           string `json:"ext"`            //always, if post has attachment 	Filetype 	.jpg, .png, .gif, .pdf, .swf, .webm
	Fsize         int64  `json:"fsize"`          //always, if post has attachment 	Size of uploaded file in bytes 	any integer
	Md5           string `json:"md5"`            //always, if post has attachment 	24 character, packed base64 MD5 hash of file
	W             int    `json:"w"`              //always, if post has attachment 	Image width dimension 	any integer
	H             int    `json:"h"`              //always, if post has attachment 	Image height dimension 	any integer
	TnW           int32  `json:"tn_w"`           //always, if post has attachment 	Thumbnail image width dimension 	any integer
	TnH           int32  `json:"tn_h"`           //always, if post has attachment 	Thumbnail image height dimension 	any integer
	Filedeleted   int    `json:"filedeleted"`    //if post had attachment and attachment is deleted, 	If the file was deleted from the post 	1 or not set
	Spoiler       int    `json:"spoiler"`        //if post has attachment and attachment is spoilered, 	If the image was spoilered or not 	1 or not set
	CustomSpoiler int32  `json:"custom_spoiler"` //if post has attachment and attachment is spoilered, 	The custom spoiler ID for a spoilered image 	1-10 or not set
	TotalReplies  int    `json:"replies"`        //OP only, 	Number of replies minus the number of previewed replies 	any integer
	Images        int    `json:"images"`         //OP only, 	Number of image replies minus the number of previewed image replies 	any integer
	Bumplimit     int    `json:"bumplimit"`      //OP only, only if bump limit has been reached 	If a thread has reached bumplimit, it will no longer bump 	1 or not set
	Imagelimit    int    `json:"imagelimit"`     //OP only, only if image limit has been reached 	If an image has reached image limit, no more image replies can be made 	1 or not set
	LastModified  int32  `json:"last_modified"`  //OP only, 	Total number of replies to a thread 	any integer
	Tag           string `json:"tag"`            //OP only, /f/ only,The category of .swf upload 	Game, Loop, etc..
	SemanticUrl   string `json:"semantic_url"`   //OP only, 	The UNIX timestamp marking the last time the thread was modified (post added/modified/deleted, thread closed/sticky settings modified) 	UNIX Timestamp
	Since4pass    int32  `json:"since4pass"`     //if poster put 'since4pass' in the options field 	Year 4chan pass bought 	any 4 digit year
	UniqueIps     int32  `json:"unique_ips"`     //OP only, 	SEO URL slug for thread 	string
	MImg          int32  `json:"m_img"`          //any post that has a mobile-optimized image 	Mobile optimized image exists for post 	1 or not set
	Archived      int32  `json:"archived"`
	ArchivedOn    int32  `json:"archived_on"`
	TailSize      int32  `json:"tail_size"`
	OmittedPosts  int32  `json:"omitted_posts"`
	OmittedImages int32  `json:"omitted_images"`

	LastReplies []*Post4chanResponse `json:"last_replies"` //catalog OP only, 	JSON representation of the most recent replies to a thread 	array of JSON post objects
}

type ThreadPosts4chanResponse

type ThreadPosts4chanResponse struct {
	Posts []*Post4chanResponse `json:"posts"`
}

Jump to

Keyboard shortcuts

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