<file_sep>
/**
 * Some of them should be written as function, such as the option 
 * of http request. In general, it also means that you can change 
 * not only properties' value but also their NAMEs. Of course you
 * can change all properties' names if nessesary.
 */

exports.default = {

  // Request option for login
  loginOpt: () => {
    return {
      url: 'http://acm.hdu.edu.cn/userloginex.php?action=login',
      formData: {
        // User infomation
        username: 'username',
        userpass: '<PASSWORD>',
        login: 'Sign In'
      }
    }
  },
  // Request option for submit
  submitOpt: (problemID, code, cookie) => {
    return {
      url: 'http://acm.hdu.edu.cn/submit.php?action=submit',
      headers: {
        cookie: cookie
      },
      formData: {
        check: 0,
        problemid: problemID,
        language: 0,
        usercode: code
      }
    }
  },
  
  // Problem ID, 1000-???
  problemStart: 1000,
  problemEnd: 1010,

  // Max async limit when submit codes
  asyncLimit: 1,

  // Submit interval(:ms)
  interval: 20000,

  // What's the format of code names
  fileNameFormat: (problemID) => `${problemID}.cpp`,

  // where are the codes
  path: './cpp/'

}<file_sep># autoAC

万能AC机，刷OJ专用。理论上支持所有OJ，只要网站没有验证码之类的提交限制

## 用法

安装依赖

``` bash
npm install
```

将要提交的代码存入程序目录下一个文件夹里（如'cpp')

将config.example.js改名为config.js

按文件中的说明修改配置信息

比如第一个配置项

``` javascript
// Request option for login
loginOpt: () => {
  return {
    url: 'http://acm.hdu.edu.cn/userloginex.php?action=login',
    formData: {
      // User infomation
      username: 'username',
      userpass: '<PASSWORD>',
      login: 'Sign In'
    }
  }
}
```

样例给的是杭电OJ的登录示例

为了灵活把整个登录请求的信息都放在了配置文件里，方便修改。

必须动态返回的配置项写成了函数的形式，比如

``` javascript
// What's the format of code names
fileNameFormat: (problemID) => `${problemID}.cpp`
```  

用模板字符串给出一个题号到文件名的映射，找到题号对应的代码文件

启动程序
``` bash
➜  npm run post
```<file_sep>const Acmachine = require('./Acmachine.js').default
const config = require('./config.js').default

new Acmachine(config).run()