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

Commit fd36e4d

Browse files
committed
Support validate code
1 parent 459f122 commit fd36e4d

26 files changed

+489
-124
lines changed

.github/workflows/schedule.yml

+3
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ jobs:
4040
with:
4141
distribution: 'temurin'
4242
java-version: '17'
43+
44+
- name: "Setup tesseract-ocr"
45+
run: "sudo apt install tesseract-ocr -y && mv config/tessdata action/config/tessdata"
4346

4447
# 缓存信息,当缓存发生变化时,请修改key值
4548
- name: "Cache autocard cache file"

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,5 @@ cache/
3939

4040
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
4141
hs_err_pid*
42+
test_*.properties
43+
code/

.idea/.gitignore

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/compiler.xml

+14
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/encodings.xml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/jarRepositories.xml

+20
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

+12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/runConfigurations.xml

+10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/vcs.xml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

+26-3
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,27 @@
3131
|dmg |MacOS |
3232
|exe |Win |
3333

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

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

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

124-
**STEP 5 运行程序**
145+
**STEP 6 运行程序**
125146

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

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

242263
## 八、更新记录
264+
### v1.4.7
265+
2022年5月7日,学校引入图片验证码,特发布此次更新支持验证码识别。同时修复了相关issue的BUG。
243266
### v1.4.6
244267
修复了相关[issue](https://github.com/GCS-ZHN/AutoCard/issues/11),支持了设置最大重试次数。
245268
### v1.4.5

action/autocard.jar

22.7 MB
Binary file not shown.

config/tessdata/eng.traineddata

22.4 MB
Binary file not shown.

pom.xml

+16-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<groupId>org.gcszhn</groupId>
66
<artifactId>autocard</artifactId>
7-
<version>1.4.6</version>
7+
<version>1.4.7</version>
88
<packaging>jar</packaging>
99

1010
<name>Auto Heathy Report for Zhejiang University</name>
@@ -111,6 +111,21 @@
111111
<artifactId>mail</artifactId>
112112
<version>1.4.7</version>
113113
</dependency>
114+
115+
<!-- https://mvnrepository.com/artifact/net.java.dev.jna/jna -->
116+
<dependency>
117+
<groupId>net.java.dev.jna</groupId>
118+
<artifactId>jna</artifactId>
119+
<version>5.10.0</version>
120+
</dependency>
121+
122+
<!-- https://mvnrepository.com/artifact/net.sourceforge.tess4j/tess4j -->
123+
<dependency>
124+
<groupId>net.sourceforge.tess4j</groupId>
125+
<artifactId>tess4j</artifactId>
126+
<version>5.1.0</version>
127+
</dependency>
128+
114129
<!--lombok插件-->
115130
<dependency>
116131
<groupId>org.projectlombok</groupId>

src/main/java/org/gcszhn/autocard/service/AutoCardJob.java

+9-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,15 @@ public static void execute(
5353
String dingtalkURL = dataMap.getString("dingtalkurl");
5454
String dingtalkSecret = dataMap.getString("dingtalksecret");
5555
int maxTrial = Optional.ofNullable(dataMap.getString("maxtrial"))
56-
.map((String value)->Integer.parseInt(value))
56+
.map((String value)-> {
57+
try{
58+
if (value.equals("")) return DEFAULT_MAX_TRIAL;
59+
return Integer.parseInt(value);
60+
} catch (NumberFormatException e) {
61+
LogUtils.printMessage("无效的整数格式", LogUtils.Level.ERROR);
62+
return DEFAULT_MAX_TRIAL;
63+
}
64+
})
5765
.orElse(DEFAULT_MAX_TRIAL);
5866
//开启随机延迟,这样可以避免每次打卡时间过于固定
5967
try {

0 commit comments

Comments
 (0)