You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
103 lines
2.4 KiB
103 lines
2.4 KiB
package main
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"jschan/app"
|
|
"jschan/app/models"
|
|
)
|
|
|
|
func main() {
|
|
|
|
jschanClient := jschan.NewClient("https://fatchan.org")
|
|
ctx := context.Background()
|
|
|
|
loginOptions := &jschan.PostLoginOptions{
|
|
Username: "",
|
|
Password: "",
|
|
Twofactor: "",
|
|
}
|
|
err := jschanClient.Login(ctx, loginOptions)
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
}
|
|
if jschanClient.SessionCookie != "" {
|
|
fmt.Printf("Logged in as user %s\n", loginOptions.Username)
|
|
if _, err := jschanClient.GetCSRFToken(ctx); err != nil {
|
|
fmt.Println(err)
|
|
}
|
|
}
|
|
|
|
overboardOptions := &jschan.GetOverboardOptions{
|
|
IncludeDefault: true,
|
|
}
|
|
res, err := jschanClient.GetOverboardCatalog(ctx, overboardOptions)
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
return
|
|
}
|
|
fmt.Printf("Fetched overboard catalog with %d threads\n", len(res.Threads))
|
|
|
|
getCatalogOptions := &jschan.GetCatalogOptions{
|
|
Board: "t",
|
|
}
|
|
res2, err2 := jschanClient.GetCatalog(ctx, getCatalogOptions)
|
|
if err2 != nil {
|
|
fmt.Println(err2)
|
|
return
|
|
}
|
|
fmt.Printf("Fetched board %s catalog with %d threads\n", getCatalogOptions.Board, len(res2))
|
|
|
|
getThreadOptions := &jschan.GetThreadOptions{
|
|
Board: "t",
|
|
ThreadId: 1392,
|
|
}
|
|
res3, err3 := jschanClient.GetThread(ctx, getThreadOptions)
|
|
if err3 != nil {
|
|
fmt.Println(err3)
|
|
return
|
|
}
|
|
fmt.Printf("Fetched /%s/ thread %d with %d replies\n", getThreadOptions.Board, getThreadOptions.ThreadId, len(res3.Replies))
|
|
|
|
getLogsListOptions := &jschan.GetLogsListOptions{
|
|
Board: "t",
|
|
}
|
|
res4, err4 := jschanClient.GetLogsList(ctx, getLogsListOptions)
|
|
if err4 != nil {
|
|
fmt.Println(err4)
|
|
return
|
|
}
|
|
fmt.Printf("Fetched /%s/ logs with %d entries\n", getLogsListOptions.Board, len(res4))
|
|
|
|
getLogsOptions := &jschan.GetLogsOptions{
|
|
Board: "t",
|
|
Date: models.LogDate{
|
|
Year: 2022,
|
|
Month: 11,
|
|
Day: 02,
|
|
},
|
|
}
|
|
res5, err5 := jschanClient.GetLogs(ctx, getLogsOptions)
|
|
if err5 != nil {
|
|
fmt.Println(err5)
|
|
return
|
|
}
|
|
fmt.Printf("Fetched /%s/ logs for date %s with %d entries\n", getLogsOptions.Board, getLogsOptions.Date.String(), len(res5))
|
|
|
|
// makePostOptions := &jschan.MakePostOptions{
|
|
// Board: "test",
|
|
// Thread: 277,
|
|
// Name: "Test",
|
|
// Message: ">test",
|
|
// Email: "sage",
|
|
// PostPassword: "123",
|
|
// Files: []string{"./image.png", "./image.png"},
|
|
// }
|
|
// err6 := jschanClient.MakePost(ctx, makePostOptions)
|
|
// if err6 != nil {
|
|
// fmt.Println(err)
|
|
// return
|
|
// }
|
|
|
|
return
|
|
}
|
|
|