Skip to content

Commit

Permalink
4.2/重写指令解析器/暂时移除strictCommand配置项
Browse files Browse the repository at this point in the history
  • Loading branch information
Dituon committed Aug 7, 2022
1 parent 9d8ad5e commit 60f49d5
Show file tree
Hide file tree
Showing 8 changed files with 83 additions and 106 deletions.
28 changes: 18 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ java 编写,**未使用任何第三方库** :轻量,高效。

5. 使用 **戳一戳**`30%` 的概率触发; 或发送 `pet @xxx`

> `key @xxx` 可返回指定图片 例如 `kiss @xxx`
> `pet key @xxx` `key @xxx` 可返回指定图片 例如 `pet kiss @xxx` `kiss @xxx`
> 可通过发送的图片生成Petpet `kiss [图片]`
> 可通过发送的图片生成Petpet `kiss [图片]`, **支持GIF**
> 可使用 `pet`指令 获取 `keyList`
Expand All @@ -52,7 +52,6 @@ content:
respondSelfNudge: false #响应机器人发出的戳一戳
keyListFormat: FORWARD #keyList响应格式
fuzzy: false #模糊匹配用户名
strictCommand: true #严格匹配模式
synchronized: false #消息事件同步锁
headless: true #使用headless模式
Expand Down Expand Up @@ -136,14 +135,20 @@ content:
> 例 (配置项为`true`时): `kiss @田所浩二`(响应) `kiss 浩二`(响应)
<br/>
- **strictCommand**: `true`
[//]: # (- **strictCommand**: `true`)

> 严格匹配指令, 默认为`true`
>
> ~~人话: 可以省略key后的空格~~
>
> 例 (配置项为`false`时): `kiss 田所`(响应) `kiss田所`(响应)
<br/>
[//]: # ()
[//]: # (> 严格匹配指令, 默认为`true`)

[//]: # (> )

[//]: # (> ~~人话: 可以省略key后的空格~~)

[//]: # (> )

[//]: # (> 例 &#40;配置项为`false`时&#41;: `kiss 田所`&#40;响应&#41; `kiss田所`&#40;响应&#41;)

[//]: # (<br/>)

- **synchronized**: `false`

Expand Down Expand Up @@ -465,6 +470,9 @@ content:
- 自动更新下载速度慢?
> 修改`Petpet.yml``repositoryUrl`的值为`'https://ghproxy.com/https://raw.githubusercontent.com/Dituon/petpet/main'`(高速镜像)
- 自动更新后 读取`data.json`出错?
> 自动更新时网络出错导致, 删除出错的文件 重新获取即可
## 分享你的作品

如果你想分享自定义的 Petpet, **欢迎Pr**
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ apply plugin: "java"


group = 'xmmt.dituon'
version = '4.1-M2'
version = '4.2'

repositories {
maven { url 'https://maven.aliyun.com/repository/public' }
Expand Down
1 change: 0 additions & 1 deletion config/xmmt.dituon.petpet/PetPet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ content:
cachePoolSize: 10000
keyListFormat: FORWARD
fuzzy: false
strictCommand: true
synchronized: false
headless: true
autoUpdate: true
Expand Down
2 changes: 1 addition & 1 deletion index.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": 4.1,
"version": 4.2,
"dataList": [
"key_list",
"up_symmetry",
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/xmmt/dituon/plugin/DataUpdater.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ public static void autoUpdate() {
public static void updateData() {
System.out.println("开始更新PetData");
UpdateIndex index = UpdateIndex.getUpdate(
Objects.requireNonNull(getUrlText(Petpet.pluginPetService.repositoryUrl + "/index.json")));
Objects.requireNonNull(getUrlText(Petpet.service.repositoryUrl + "/index.json")));
List<String> newPetList = index.getDataList();
for (String pet : newPetList) {
if (Petpet.pluginPetService.getDataMap().containsKey(pet)
|| Petpet.pluginPetService.updateIgnore.contains(pet)) continue;
if (Petpet.service.getDataMap().containsKey(pet)
|| Petpet.service.updateIgnore.contains(pet)) continue;
String petDataPath = "/data/xmmt.dituon.petpet/" + pet;
if (!saveAs(petDataPath, "data.json")) {
System.out.println("无法从远程仓库下载PetData: " + petDataPath);
Expand All @@ -55,16 +55,16 @@ public static void updateData() {
}

System.out.println("PetData更新完毕, 正在重新加载");
Petpet.pluginPetService.readData(Petpet.dataFolder);
Petpet.service.readData(Petpet.dataFolder);
}

public static boolean checkUpdate() {
UpdateIndex update = UpdateIndex.getUpdate(
Objects.requireNonNull(getUrlText(Petpet.pluginPetService.repositoryUrl + "/index.json")));
Objects.requireNonNull(getUrlText(Petpet.service.repositoryUrl + "/index.json")));
if (Petpet.VERSION != update.getVersion())
System.out.println("PetpetPlugin可更新到最新版本: " + update.getVersion() + " (当前版本 " + Petpet.VERSION + ")");
for (String pet : update.getDataList()) {
if (Petpet.pluginPetService.getDataMap().containsKey(pet)) continue;
if (Petpet.service.getDataMap().containsKey(pet)) continue;
System.out.println("发现新增PetData");
return false;
}
Expand All @@ -89,7 +89,7 @@ private static String getUrlText(String url) {
}

private static boolean saveAs(String path, String fileName) {
try (InputStream ins = new URL(Petpet.pluginPetService.repositoryUrl + path + '/' + fileName).openStream()) {
try (InputStream ins = new URL(Petpet.service.repositoryUrl + path + '/' + fileName).openStream()) {
Path target = Paths.get(new File(".").getCanonicalPath() + path, fileName);
Files.createDirectories(target.getParent());
Files.copy(ins, target, StandardCopyOption.REPLACE_EXISTING);
Expand Down
Loading

0 comments on commit 60f49d5

Please sign in to comment.