buaaclock

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2022 License: MIT Imports: 12 Imported by: 0

README

buaa-clock

北航每日打卡程序,不能代替例行防疫,引发的问题本人概不负责。

子命令

clock

clock 子命令可以完成一次打卡操作,示例命令如下:

$ buaa-clock clock --username=by2101111 --password=password --retry=20
选项 含义
username 用户学号
password 用户密码
retry 未登录成功重试次数
timing

timing 子命令可以在每天的 17:10 自动执行打卡命令,但是需要保持程序后台运行。示例命令如下:

$ buaa-clock timing --config=config.yml
选项 含义
config 配置文件路径

配置文件示例如下:

url:
  # 登录 URL
  login: https://xxx.xxx.xxxx
  # 获取信息 URL
  info: https://xxx.xxx.xxxx
  # 打卡 URL
  save: https://xxx.xxx.xxxx

users:
    # 用户账号
  - username: by2101111
    # 用户密码
    password: password
    # 是否在校,1在校,0不在校,如果为 1,reason 和 note 字段无效
    boarder: "1"
    # 不在校理由
    reasen: "2"
    # 理由为其他时,填充的原因
    note: "回家"

    # 下面4个字段为打卡地址,如果不指定为北航学院路
    address: ""
    area: ""
    city: ""
    province: ""

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Clock

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

func NewClock

func NewClock(configs ...Config) *Clock

func (*Clock) Exec

func (c *Clock) Exec() error

type Config

type Config struct {
	LoginURL string
	InfoURL  string
	SaveURL  string

	Retry int

	UserName string
	Password string

	// Whether to stay at school, "1" means yes, "0" means no
	Boarder string

	// If you are not staying at school, the reasons you need
	// to choose from "1" to "6" are "Temporary absence from school",
	// "Returning home during summer and winter vacations",
	// "Overseas research and study",
	// "Off-campus business trip or internship",
	// "Sick leave, leave of absence or leave of absence from school",
	// and "Other".
	NotBoarderReasen string

	// The reason for leaving school is other reasons that need to be filled in.
	NotBoarderNote string

	// Clocking BoarderAddress
	BoarderAddress  string
	BoarderArea     string
	BoarderCity     string
	BoarderProvince string

	NotBoarderAddress  string
	NotBoarderArea     string
	NotBoarderCity     string
	NotBoarderProvince string
}

type ExponentialBackoff

type ExponentialBackoff struct {
	// InitialInterval is the initial time interval for backoff algorithm.
	InitialInterval time.Duration

	// MaxBackoffTime is the maximum time duration for backoff algorithm. It limits
	// the maximum sleep time.
	MaxBackoffTime time.Duration

	// Multiplier is a multiplier number of the backoff algorithm.
	Multiplier float64

	// MaxRetryCount is the maximum number of retry count.
	MaxRetryCount int
	// contains filtered or unexported fields
}

ExponentialBackoff is a retry mechanism for retrying some calls.

func NewExponentialBackoff

func NewExponentialBackoff(config ...RetryConfig) *ExponentialBackoff

NewExponentialBackoff creates a ExponentialBackoff with default values.

func (*ExponentialBackoff) Retry

func (e *ExponentialBackoff) Retry(f func() error) error

Retry is the core logic of the retry mechanism. If the calling function returns nil as an error, then the Retry method is terminated with returning nil. Otherwise, if all function calls are returned error, then the method returns this error.

type RetryConfig

type RetryConfig struct {
	// InitialInterval defines the initial time interval for backoff algorithm.
	//
	// Optional. Default: 1 * time.Second
	InitialInterval time.Duration

	// MaxBackoffTime defines maximum time duration for backoff algorithm. When
	// the algorithm is reached this time, rest of the retries will be maximum
	// 32 seconds.
	//
	// Optional. Default: 32 * time.Second
	MaxBackoffTime time.Duration

	// Multiplier defines multiplier number of the backoff algorithm.
	//
	// Optional. Default: 2.0
	Multiplier float64

	// MaxRetryCount defines maximum retry count for the backoff algorithm.
	//
	// Optional. Default: 10
	MaxRetryCount int
	// contains filtered or unexported fields
}

Config defines the config for addon.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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