dcgo

package module
v0.0.0-...-d9bcf20 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2020 License: MIT Imports: 19 Imported by: 1 module, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

dcgo PkgGoDev codecov

고로 맨든 디시인사이드 비공식 라이브러리

기능

  • 세션
    • 기존 세션 쿠키(PHPSESSID)를 사용한 로그인
    • TOTP 키를 사용한 2차 인증 로그인 (키 얻는 방법)
  • 갤로그
    • 방명록 작성
    • 방명록 조회
    • 방명록 관리
  • 갤러리
    • 글 목록 조회
    • 글 작성
      • 이미지 업로드
    • 글 조회
    • 글 투표 (추천/비추천)
    • 댓글 조회
    • 댓글 작성
      • 디시콘 댓글 작성

예제

더 많은 예제는 저장소의 examples 디렉터리를 확인하세요

package main

import (
  "fmt"
  
  "github.com/pkg/errors"
  "github.com/dcgoo/dcgo"
)

func main() {
  client := dcgo.New()
  username := os.Getenv("USERNAME")
  password := os.Getenv("PASSWORD")

  if err := client.LoginWithCredentials(username, password, ""); err != nil {
    panic(errors.Wrap(err, "로그인 중 오류가 발생했습니다"))
  }

  fmt.Printf("성공적으로 %s(%s) 계정으로 로그인했습니다\n",
    client.Gallog.Nickname,
    client.Gallog.Username)
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrHTTPUnexcepted 서버가 반환한 값이 예측하지 못한 값이라면 발생하는 오류
	ErrHTTPUnexcepted = errors.New("서버가 예측하지 못한 값을 반환했습니다")

	// ErrStructUninitialized 초기화되지 않은 구조 사용시 발생하는 오류
	ErrStructUninitialized = errors.New("초기화되지 않은 구조입니다")
)
View Source
var (
	// ErrGallogNotFound 존재하지 않는 갤로그에 접근 했을 때 발생하는 오류
	ErrGallogNotFound = errors.New("존재하지 않는 갤로그입니다")

	// ErrGallogDeleted 삭제된 갤로그에 접근했을 때 했을 때 발생하는 오류
	ErrGallogDeleted = errors.New("삭제된 갤로그입니다")

	// ErrGallogRested 휴면된 갤로그에 접근했을 했을 때 발생하는 오류
	ErrGallogRested = errors.New("휴면된 갤로그입니다")

	// ErrGallogBlocked 차단된 갤로그에 접근했을 때 발생하는 오류
	ErrGallogBlocked = errors.New("차단된 갤로그입니다")
)
View Source
var (
	// ErrSessionInvalid 현재 세션 정보가 유효하지 않을 때 발생하는 오류
	ErrSessionInvalid = errors.New("유효하지 않은 세션입니다")

	// ErrSessionInvalidInput 입력한 아이디 또는 비밀번호가 일치하지 않아
	// 인증을 처리할 수 없을 때 발생하는 오류
	ErrSessionInvalidInput = errors.New("유효하지 않은 아이디 또는 비밀번호입니다")

	// ErrSessionInvalidTOTP 입력한 TOTP 코드가 일치하지 않아
	// 인증을 처리할 수 없을 때 발생하는 오류
	ErrSessionInvalidTOTP = errors.New("유효하지 않은 TOTP 코드입니다")

	// ErrSessionRequireTOTP TOTP(2차 인증)로 잠겨있는 계정이나 TOTP 토큰이
	// 제공되지 않아 생성할 수 없을 때 발생하는 오류
	ErrSessionRequireTOTP = errors.New("TOTP 인증이 필요합니다")
)
View Source
var (
	// ErrGalleryBanned 갤러리 도메인에서 짧은 시간에 많은 요청을 보내거나 잘못된 접근으로
	// 일시적으로 차단될 시 빈 페이지가 반환 됐을 때 차단으로 판단하고 발생하는 오류
	ErrGalleryBanned = errors.New("일시적으로 갤러리 접근이 차단되었습니다")
)

Functions

This section is empty.

Types

type Article

type Article struct {
	Client  *Client
	Gallery *Gallery

	ID      int64  // 번호
	Subject string // 제목
	Content string // 내용

	Username      string // 작성자 아이디 또는 아이피
	Nickname      string // 작성자 닉네임
	Password      string // 비밀번호
	FixedNickname bool   // 고정닉인지?

	Comments      int64      // 댓글 수
	Views         int64      // 조회 수
	VoteUp        int64      // 추천 수
	VoteUpByFixed int64      // 추천 수 (고닉)
	VoteDown      int64      // 비추천 수
	Recommended   bool       // 개념글인지?
	CreatedAt     *time.Time // 작성 시간

	Files          []ArticleFile // 업로드된 또는 될 파일들
	FilesToContent bool          // 업로드 후 파일을 내용에 추가할지?
	WaitUntil      *time.Time    // 업로드할 때 대기할 시간 (전송될 때까지)
}

Article 갤러리 글 작성 데이터

func (*Article) Create

func (a *Article) Create() (*Article, error)

Create 새로운 글을 만든 뒤 복사된 글 구조를 반환합니다

func (*Article) Delete

func (a *Article) Delete() error

Delete 글을 삭제합니다

func (*Article) URL

func (a *Article) URL() string

URL 메소드는 글의 주소를 반환합니다

func (*Article) Update

func (a *Article) Update() error

Update 메소드는 글 정보를 갱신합니다

func (*Article) Vote

func (a *Article) Vote(upvote bool) error

Vote 글을 추천 또는 비추천 합니다

type ArticleFile

type ArticleFile struct {
	Name string
	Data []byte
}

ArticleFile 갤러리 글 작성 시 포함되는 파일 데이터

type Client

type Client struct {
	Gallog *Gallog // 인증된 갤로그
	// contains filtered or unexported fields
}

Client 디시인사이드 객체

func New

func New() *Client

New 새로운 클라이언트를 만듭니다

func (*Client) Cookie

func (c *Client) Cookie(name string) *http.Cookie

Cookie 메소드는 쿠키 값을 가져옵니다

func (*Client) Do

func (c *Client) Do(req *http.Request) (*Response, error)

Do 메소드는 HTTP 요청을 보내고 응답을 받아옵니다

func (*Client) Get

func (c *Client) Get(url string, header http.Header) (*Response, error)

Get 메소드로 HTTP 요청을 보내고 응답을 받아옵니다

func (*Client) LoggedIn

func (c *Client) LoggedIn() error

LoggedIn 유효한 세션인지 확인합니다

func (*Client) Login

func (c *Client) Login(totpCode string) error

Login 메소드는 기존 계정 정보를 사용해 로그인을 시도합니다

func (*Client) LoginWithCredentials

func (c *Client) LoginWithCredentials(username, password, totpCode string) error

LoginWithCredentials 메소드는 계정 정보 저장하고 사용해 로그인을 시도합니다

func (*Client) LoginWithSession

func (c *Client) LoginWithSession(sessionID string) error

LoginWithSession 세션 아이디로 클라이언트의 로그인을 시도합니다

func (*Client) NewGallery

func (c *Client) NewGallery(id string, minor bool) *Gallery

NewGallery 메소드는 새로운 갤러리 객체를 만듭니다

func (*Client) NewGallog

func (c *Client) NewGallog(username string) *Gallog

NewGallog 메소드는 새로운 갤로그 객체를 만듭니다

func (*Client) Post

func (c *Client) Post(url string, header http.Header, data io.Reader) (*Response, error)

Post 메소드로 HTTP 요청을 보내고 응답을 받아옵니다

func (*Client) PostForm

func (c *Client) PostForm(url string, header http.Header, data string) (*Response, error)

PostForm 메소드로 HTTP 요청을 보내고 응답을 받아옵니다

func (*Client) Session

func (c *Client) Session() string

Session 메소드는 현재 세션 아이디를 반환합니다

func (*Client) SetCookie

func (c *Client) SetCookie(name string, value string)

SetCookie 메소드는 쿠키 값을 설정합니다

func (*Client) TOTP

func (c *Client) TOTP(totp string)

TOTP 메소드는 TOTP 키를 설정합니다

type Gallery struct {
	Client *Client

	ID   string // 게시판 아이디
	Name string // 이름

	Minor                 bool      // 마이너 갤러리인지?
	MinorDescription      string    // 마이너 갤러리 설명
	MinorCreatedAt        time.Time // 마이너 갤러리 개설일
	MinorManager          string    // 마이너 갤러리 매니저(주딱)
	MinorManagerSubs      []string  // 마이너 갤러리 부매니저(파딱)
	IsMinorManagerAbsence bool      // 마이너 갤러리 매니저가 부재 상태인지?
}

Gallery 갤러리 객체

func (*Gallery) List

func (g *Gallery) List(page int, recommended bool) ([]*Article, error)

List 갤러리의 게시글 목록을 가져옵니다

func (*Gallery) NewArticle

func (g *Gallery) NewArticle(id int64) *Article

NewArticle 새로운 글 구조를 생성합니다 글을 작성하고 싶다면 생성된 구조의 Create() 메소드를 사용해야합니다

func (*Gallery) Update

func (g *Gallery) Update() error

Update 갤러리 정보를 갱신합니다

type Gallog

type Gallog struct {
	Client *Client

	Username string
	Nickname string
	Fixed    bool

	Visitors      int
	VisitorsToday int
}

Gallog 갤로그 객체

func (*Gallog) Update

func (g *Gallog) Update() error

Update 갤로그 정보를 갱신합니다

func (*Gallog) WriteGuestbook

func (g *Gallog) WriteGuestbook(text string, secret bool) error

WriteGuestbook 방명록을 작성합니다

type Response

type Response struct {
	Data     *http.Response    // 기존 응답 구조
	Bytes    []byte            // 반환된 바이트
	String   string            // 반환된 문자열
	Document *goquery.Document // 변환된 도큐먼트
}

Response 웹 요청 응답

func (*Response) Cookie

func (r *Response) Cookie(name string) *http.Cookie

Cookie 메소드는 특정 이름을 가진 쿠키를 반환합니다

Jump to

Keyboard shortcuts

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