Skip to content

Commit 8d7387c

Browse files
✨ auto verify add friend
1 parent 6171924 commit 8d7387c

File tree

5 files changed

+50
-6
lines changed

5 files changed

+50
-6
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
- [x] 自动拉人进群
1212
- [x] 群新增成员监听并发送欢迎语
1313
- [x] 图灵AI自动回复
14+
- [x] 自动同意添加好友
1415

1516
## Show
1617

@@ -40,6 +41,12 @@ autoReply: # 自动回复配置
4041
nickNames: # 自动回复名单, 可配置多个, 群回复需要@
4142
- Bot567
4243
prefix: 【~(≧▽≦)~】 # 自动回复小尾巴
44+
45+
autoVerify: # 自动添加好友验证
46+
enable: true # 是否启用
47+
passMessage: # 验证信息包含以下列表时自动通过
48+
- Java
49+
- Github
4350
```
4451
4552
## Quick Start

src/main/java/io/github/biezhi/wechat/MyBot.java

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,19 @@
33
import io.github.biezhi.wechat.ai.tuling.Tuling;
44
import io.github.biezhi.wechat.api.annotation.Bind;
55
import io.github.biezhi.wechat.api.constant.Config;
6+
import io.github.biezhi.wechat.api.constant.custom.AutoVerify;
67
import io.github.biezhi.wechat.api.constant.custom.LoverPrattle;
78
import io.github.biezhi.wechat.api.enums.AccountType;
89
import io.github.biezhi.wechat.api.enums.MsgType;
910
import io.github.biezhi.wechat.api.model.Account;
1011
import io.github.biezhi.wechat.api.model.WeChatMessage;
1112
import io.github.biezhi.wechat.job.PrattleJobEngine;
1213
import io.github.biezhi.wechat.prattle.PrattleInfoReqUtil;
14+
import io.github.biezhi.wechat.utils.DateUtils;
1315
import io.github.biezhi.wechat.utils.StringUtils;
1416
import lombok.extern.slf4j.Slf4j;
1517

18+
import java.util.Set;
1619
import java.util.regex.Matcher;
1720
import java.util.regex.Pattern;
1821

@@ -120,15 +123,24 @@ private boolean autoReplyLover(WeChatMessage message) {
120123
/**
121124
* 好友验证消息
122125
*/
123-
/* @Bind(msgType = MsgType.ADD_FRIEND)
126+
@Bind(msgType = MsgType.ADD_FRIEND)
124127
public void addFriend(WeChatMessage message) {
125128
log.info("收到好友验证消息: {}", message.getText());
126-
if (message.getText().contains("java")) {
127-
this.api().verify(message.getRaw().getRecommend());
129+
AutoVerify autoVerify = this.customConfig().getAutoVerify();
130+
if (autoVerify.isEnable()) {
131+
Set<String> passMessage = autoVerify.getPassMessage();
132+
if (passMessage != null && passMessage.size() > 0 && passMessage.contains(message.getText())) {
133+
DateUtils.sendSleep();
134+
this.api().verify(message.getRaw().getRecommend());
135+
}
128136
}
129-
}*/
137+
}
138+
139+
/**
140+
* 可使用文件助手调试
141+
* Account account = api().getAccountByName("文件传输助手");
142+
*/
130143
public void sendPrattle() {
131-
// Account account = api().getAccountByName("文件传输助手");
132144
LoverPrattle loverPrattle = this.customConfig().getLoverPrattle();
133145
if (loverPrattle != null) {
134146
String prattle = PrattleInfoReqUtil.reducePrattle(this.customConfig().getLoverPrattle());
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package io.github.biezhi.wechat.api.constant.custom;
2+
3+
import lombok.Data;
4+
5+
import java.util.Set;
6+
7+
/**
8+
* @author ybd
9+
* @date 19-7-6
10+
* @contact yangbingdong1994@gmail.com
11+
*/
12+
@Data
13+
public class AutoVerify {
14+
private boolean enable = false;
15+
16+
private Set<String> passMessage;
17+
}

src/main/java/io/github/biezhi/wechat/api/constant/custom/CustomConfig.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,6 @@ public class CustomConfig {
1515
private LoverPrattle loverPrattle;
1616

1717
private AutoReply autoReply;
18+
19+
private AutoVerify autoVerify;
1820
}

src/main/resources/config.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,10 @@ autoReply:
1212
tulingApiKey: b24b376ec0444b418035720785a8cde4
1313
nickNames:
1414
- Bot567
15-
prefix: 【~(≧▽≦)~】
15+
prefix: 【~(≧▽≦)~】
16+
17+
autoVerify:
18+
enable: true
19+
passMessage:
20+
- Java
21+
- Github

0 commit comments

Comments
 (0)