client

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2019 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrorNotLogged = "Not logged in"

ErrorNotLogged not logged in

View Source
var Langs = map[string]string{
	"43": "GNU GCC C11 5.1.0",
	"52": "Clang++17 Diagnostics",
	"42": "GNU G++11 5.1.0",
	"50": "GNU G++14 6.4.0",
	"54": "GNU G++17 7.3.0",
	"2":  "Microsoft Visual C++ 2010",
	"59": "Microsoft Visual C++ 2017",
	"9":  "C# Mono 5.18",
	"28": "D DMD32 v2.083.1",
	"32": "Go 1.11.4",
	"12": "Haskell GHC 8.6.3",
	"36": "Java 1.8.0_162",
	"48": "Kotlin 1.3.10",
	"19": "OCaml 4.02.1",
	"3":  "Delphi 7",
	"4":  "Free Pascal 3.0.2",
	"51": "PascalABC.NET 3.4.2",
	"13": "Perl 5.20.1",
	"6":  "PHP 7.2.13",
	"7":  "Python 2.7.15",
	"31": "Python 3.7.2",
	"40": "PyPy 2.7 (6.0.0)",
	"41": "PyPy 3.5 (6.0.0)",
	"8":  "Ruby 2.0.0p645",
	"49": "Rust 1.31.1",
	"20": "Scala 2.12.8",
	"34": "JavaScript V8 4.8.0",
	"55": "Node.js 9.4.0",
}

Langs generated by ^[\s\S]*?value="(.+?)"[\s\S]*?>([\s\S]+?)<[\s\S]*?$

"\1": "\2",
View Source
var LangsExt = map[string]string{
	"GNU C11":               "c",
	"Clang++17 Diagnostics": "cpp",
	"GNU C++0x":             "cpp",
	"GNU C++":               "cpp",
	"GNU C++11":             "cpp",
	"GNU C++14":             "cpp",
	"GNU C++17":             "cpp",
	"MS C++":                "cpp",
	"MS C++ 2017":           "cpp",
	"Mono C#":               "cs",
	"D":                     "d",
	"Go":                    "go",
	"Haskell":               "hs",
	"Kotlin":                "kt",
	"Ocaml":                 "ml",
	"Delphi":                "pas",
	"FPC":                   "pas",
	"PascalABC.NET":         "pas",
	"Perl":                  "pl",
	"PHP":                   "php",
	"Python 2":              "py",
	"Python 3":              "py",
	"PyPy 2":                "py",
	"PyPy 3":                "py",
	"Ruby":                  "rb",
	"Rust":                  "rs",
	"JavaScript":            "js",
	"Node.js":               "js",
	"Q#":                    "qs",
	"Java":                  "java",
	"Java 6":                "java",
	"Java 7":                "java",
	"Java 8":                "java",
	"Java 9":                "java",
	"Tcl":                   "tcl",
	"F#":                    "fs",
	"Befunge":               "bf",
	"Pike":                  "pike",
	"Io":                    "io",
	"Factor":                "factor",
	"Cobol":                 "cbl",
	"Secret_171":            "secret_171",
	"Ada":                   "adb",
	"FALSE":                 "f",
	"":                      "txt",
}

LangsExt language's ext

Functions

func ToGym added in v0.7.0

func ToGym(URL, contestID string) string

ToGym if length of contestID >= 6, replace contest to gym

Types

type Client

type Client struct {
	Jar            *cookiejar.Jar  `json:"cookies"`
	Username       string          `json:"username"`
	Ftaa           string          `json:"ftaa"`
	Bfaa           string          `json:"bfaa"`
	LastSubmission *SaveSubmission `json:"last_submission"`
	// contains filtered or unexported fields
}

Client codeforces client

func New

func New(path string) *Client

New client

func (*Client) Clone added in v0.7.0

func (c *Client) Clone(username, rootPath string, ac bool) (err error)

Clone all ac codes of all contests

func (*Client) GetLangList

func (c *Client) GetLangList(url string) (langs map[string]string, err error)

GetLangList get language list from url (require login)

func (*Client) Login

func (c *Client) Login(username, password string) (err error)

Login codeforces with username(handler) and password

func (*Client) ParseContest

func (c *Client) ParseContest(contestID, rootPath string, race bool) (err error)

ParseContest parse for contest

func (*Client) ParseContestProblem

func (c *Client) ParseContestProblem(contestID, problemID, path string) (samples int, err error)

ParseContestProblem parse contest problem

func (*Client) ParseProblem

func (c *Client) ParseProblem(URL, path string) (samples int, err error)

ParseProblem parse problem to path

func (*Client) PullCode added in v0.4.0

func (c *Client) PullCode(contestID, submissionID, path, ext string, rename bool) (filename string, err error)

PullCode pull problem's code to path

func (*Client) PullContest added in v0.4.0

func (c *Client) PullContest(contestID, problemID, rootPath string, ac bool) (err error)

PullContest pull all latest codes or ac codes of contest's problem

func (*Client) RaceContest added in v0.3.0

func (c *Client) RaceContest(contestID string) (err error)

RaceContest wait for contest starting

func (*Client) StatisContest

func (c *Client) StatisContest(contestID string) (problems []StatisInfo, err error)

StatisContest get contest problems statis

func (*Client) SubmitContest

func (c *Client) SubmitContest(contestID, problemID, langID, source string) (err error)

SubmitContest submit problem in contest (and block util pending)

func (*Client) WatchSubmission added in v0.2.0

func (c *Client) WatchSubmission(contestID string, n int, line bool) (submissions []Submission, err error)

WatchSubmission n is the number of submissions

type SaveSubmission added in v0.5.6

type SaveSubmission struct {
	ContestID    string `json:"contest_id"`
	SubmissionID string `json:"submission_id"`
}

SaveSubmission save it in session

type StatisInfo

type StatisInfo struct {
	ID     string
	Name   string
	IO     string
	Limit  string
	Passed string
	State  string
}

StatisInfo statis information

type Submission added in v0.2.0

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

Submission submit state

func (*Submission) ParseID added in v0.2.0

func (s *Submission) ParseID() string

ParseID formatter

func (*Submission) ParseMemory added in v0.2.0

func (s *Submission) ParseMemory() string

ParseMemory formatter

func (*Submission) ParseStatus added in v0.2.0

func (s *Submission) ParseStatus() string

ParseStatus with color

func (*Submission) ParseTime added in v0.2.0

func (s *Submission) ParseTime() string

ParseTime formatter

Jump to

Keyboard shortcuts

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