Documentation ¶
Overview ¶
Package client provides a client for interacting with vecchiochan.
It includes functionality for creating new threads and posting replies to existing threads, and allows for custom http.Client, logger, logging behavior, and User-Agent header.
Index ¶
- Variables
- type Config
- type Reply
- func (r Reply) GetBoard() string
- func (r Reply) GetBody() string
- func (r Reply) GetEmail() string
- func (r Reply) GetEmbed() string
- func (r Reply) GetFiles() []string
- func (r Reply) GetName() string
- func (r Reply) GetPassword() string
- func (r Reply) GetSage() bool
- func (r Reply) GetSpoiler() bool
- func (r Reply) GetSubject() string
- func (r Reply) GetThread() int
- type Thread
- func (t Thread) GetBoard() string
- func (t Thread) GetBody() string
- func (t Thread) GetEmail() string
- func (t Thread) GetEmbed() string
- func (t Thread) GetFiles() []string
- func (t Thread) GetName() string
- func (t Thread) GetPassword() string
- func (t Thread) GetSage() bool
- func (t Thread) GetSpoiler() bool
- func (t Thread) GetSubject() string
- func (t Thread) GetThread() int
- type VecchioClient
Constants ¶
This section is empty.
Variables ¶
var DefaultConfig = Config{ Client: &http.Client{Timeout: 30 * time.Second}, Logger: log.New(os.Stderr, "", log.LstdFlags), UserAgent: "", Verbose: false, }
DefaultConfig provides default values for a VecchioClient.
Functions ¶
This section is empty.
Types ¶
type Config ¶
Config is used to customize the creation of a VecchioClient.
It holds configurations for the underlying HTTP client, logger, user-agent, and logging verbosity.
When Verbose is set to true, HTTP response codes as well as the submitted form and response are logged.
type Reply ¶
type Reply struct { Thread int // ID of the thread to reply to (required) Board string // Board where the reply is to be posted (e.g., 'b') (required) Name string // Name of the poster Email string // Email of the poster Spoiler bool // Marks attached files as spoiler Body string // The message of the reply Embed string // URL for an embedded media link (YouTube, Spotify...) Password string // Password used to delete or edit the reply Sage bool // Replaces email with 'rabbia' and prevents bumping the thread Files []string // Paths of the files to attach to the reply }
Reply represents a response to a thread on a specific board.
It includes details such as the thread ID, board name, and message of the reply.
Thread and Board are the only mandatory fields checked by the client but keep in mind that since each board has its own settings, more fields may be required (such as Body).
func (Reply) GetPassword ¶
GetPassword returns the password for editing or deleting the reply.
func (Reply) GetSpoiler ¶
GetSpoiler returns whether the attached files are to be marked as spoiler.
func (Reply) GetSubject ¶
GetSubject returns the subject of the reply (empty for replies).
type Thread ¶
type Thread struct { Board string // Board where the thread is to be posted (e.g., 'b') (required) Name string // Name of the poster Email string // Email of the poster Subject string // Subject of the thread Spoiler bool // Marks attached files as spoiler Body string // The message of the thread Embed string // URL for an embedded media link (YouTube, Spotify...) Password string // Password used to delete or edit the thread Sage bool // Replaces email with 'rabbia' and prevents bumping the thread Files []string // Paths of the files to attach to the thread }
Thread represents a thread on a specific board.
It includes details such as the board name, and message of the thread.
Board is the only mandatory field checked by the client but keep in mind that since each board has its own settings, more fields may be required (such as Body).
func (Thread) GetFiles ¶
GetFiles returns a list of paths of the files to be attached to the thread.
func (Thread) GetPassword ¶
GetPassword returns the password for editing or deleting the thread.
func (Thread) GetSpoiler ¶
GetSpoiler returns whether the attached files are to be marked as spoiler.
func (Thread) GetSubject ¶
GetSubject returns the subject of the thread.
type VecchioClient ¶
type VecchioClient struct {
// contains filtered or unexported fields
}
VecchioClient is a client for interacting with vecchiochan.
It allows for posting new threads and replies.
func NewVecchioClient ¶
func NewVecchioClient() *VecchioClient
NewVecchioClient creates a new VecchioClient with default configuration.
It uses a default HTTP client, logger, and user-agent and only base logging will be shown unless otherwise configured.
See NewVecchioClientWithConfig to pass a custom configuration.
func NewVecchioClientWithConfig ¶
func NewVecchioClientWithConfig(config Config) *VecchioClient
NewVecchioClientWithConfig creates a new VecchioClient using the provided configuration.
If any field in the config is nil or empty, it will fall back to the corresponding default value.
If no custom configuration is needed calling NewVecchioClient instead is enough.
func (*VecchioClient) NewThread ¶
func (c *VecchioClient) NewThread(thread Thread) (int, error)
NewThread submits a new thread to vecchiochan.
The thread argument should contain all the necessary information for a new thread.
It returns the id of the newly-created thread or an error if the operation fails.
func (*VecchioClient) PostReply ¶
func (c *VecchioClient) PostReply(reply Reply) (int, error)
PostReply submits a reply to an existing thread on vecchiochan.
The reply argument should contain all the necessary information for a reply.
It returns the id of the submitted reply or an error if the operation fails.