Skip to content
This repository has been archived by the owner on Dec 4, 2023. It is now read-only.

Commit

Permalink
Support validate code
Browse files Browse the repository at this point in the history
  • Loading branch information
GCS-ZHN committed May 7, 2022
1 parent 459f122 commit fd36e4d
Show file tree
Hide file tree
Showing 26 changed files with 489 additions and 124 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/schedule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ jobs:
with:
distribution: 'temurin'
java-version: '17'

- name: "Setup tesseract-ocr"
run: "sudo apt install tesseract-ocr -y && mv config/tessdata action/config/tessdata"

# 缓存信息,当缓存发生变化时,请修改key值
- name: "Cache autocard cache file"
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,5 @@ cache/

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
test_*.properties
code/
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions .idea/runConfigurations.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 26 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,27 @@
|dmg |MacOS |
|exe |Win |

**STEP 3 下载作者提供的发行版**
**STEP 3 安装tesseract-ocr**
该项目基于tesseract-ocr做验证码识别,需要在系统环境中安装tesseract-ocr引擎,可以参考[tesseract-ocr主页](https://tesseract-ocr.github.io/tessdoc/Home.html)。安装配置完成可以正常使用`tesseract`命令。
```
(base) [admin@Sat May 07-22:06:17 autocard]$ tesseract
Usage:
tesseract --help | --help-extra | --version
tesseract --list-langs
tesseract imagename outputbase [options...] [configfile...]
OCR options:
-l LANG[+LANG] Specify language(s) used for OCR.
NOTE: These options must occur before any configfile.
Single options:
--help Show this help message.
--help-extra Show extra help for advanced users.
--version Show version information.
--list-langs List available languages for tesseract engine.
```

**STEP 4 下载作者提供的发行版**

[gitee](https://gitee.com/GCSZHN/AutoCard/releases/)[github](https://github.com/GCS-ZHN/AutoCard/releases)的项目发行版页面,下载最新的发行版(autocard-XXX.zip,XXX为版本号)。并解压。可以看到解压后目录结构如下
```txt
Expand All @@ -42,8 +62,9 @@
----config/
------application.json ## 用户配置,如账号密码等
------log4j2.xml ## 日志配置,不用修改
------tessdata/ ## 放置OCR模型数据
```
**STEP 4 修改application.json**
**STEP 5 修改application.json**

用任意文本编辑器打开config目录下的application.json,配置下列信息。
```json
Expand Down Expand Up @@ -121,7 +142,7 @@ cron表达式是用于定时任务的经典表达式,该参数允许用户自
```
delay参数为true时,每次执行任务会随机延时0~1800秒,这样的好处在于每天打卡时间不固定。

**STEP 5 运行程序**
**STEP 6 运行程序**

需要通过命令行来运行程序,在Windows下,常见的命令行是cmd和powershell,打开方式“WIN + R”,输入"cmd"或"powershell",确定即可。linux服务器打开即是shell命令行页面(To小白:如何连接Linux服务器请自行百度一下,拥有服务器用户名、密码、IP、端口,通过ssh客户端访问)。

Expand Down Expand Up @@ -240,6 +261,8 @@ powershell build.ps1 ## windows
若打卡题目被更新或者你的任何信息情况有变化(如返校),请先手动打卡一次。本项目仅供学习参考。使用时请确保信息的正确性。滥用造成的后果请自行承担。

## 八、更新记录
### v1.4.7
2022年5月7日,学校引入图片验证码,特发布此次更新支持验证码识别。同时修复了相关issue的BUG。
### v1.4.6
修复了相关[issue](https://github.com/GCS-ZHN/AutoCard/issues/11),支持了设置最大重试次数。
### v1.4.5
Expand Down
Binary file modified action/autocard.jar
Binary file not shown.
Binary file added config/tessdata/eng.traineddata
Binary file not shown.
17 changes: 16 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>org.gcszhn</groupId>
<artifactId>autocard</artifactId>
<version>1.4.6</version>
<version>1.4.7</version>
<packaging>jar</packaging>

<name>Auto Heathy Report for Zhejiang University</name>
Expand Down Expand Up @@ -111,6 +111,21 @@
<artifactId>mail</artifactId>
<version>1.4.7</version>
</dependency>

<!-- https://mvnrepository.com/artifact/net.java.dev.jna/jna -->
<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna</artifactId>
<version>5.10.0</version>
</dependency>

<!-- https://mvnrepository.com/artifact/net.sourceforge.tess4j/tess4j -->
<dependency>
<groupId>net.sourceforge.tess4j</groupId>
<artifactId>tess4j</artifactId>
<version>5.1.0</version>
</dependency>

<!--lombok插件-->
<dependency>
<groupId>org.projectlombok</groupId>
Expand Down
10 changes: 9 additions & 1 deletion src/main/java/org/gcszhn/autocard/service/AutoCardJob.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,15 @@ public static void execute(
String dingtalkURL = dataMap.getString("dingtalkurl");
String dingtalkSecret = dataMap.getString("dingtalksecret");
int maxTrial = Optional.ofNullable(dataMap.getString("maxtrial"))
.map((String value)->Integer.parseInt(value))
.map((String value)-> {
try{
if (value.equals("")) return DEFAULT_MAX_TRIAL;
return Integer.parseInt(value);
} catch (NumberFormatException e) {
LogUtils.printMessage("无效的整数格式", LogUtils.Level.ERROR);
return DEFAULT_MAX_TRIAL;
}
})
.orElse(DEFAULT_MAX_TRIAL);
//开启随机延迟,这样可以避免每次打卡时间过于固定
try {
Expand Down
Loading

0 comments on commit fd36e4d

Please sign in to comment.