-
Notifications
You must be signed in to change notification settings - Fork 0
java——robot
殷泽凌 edited this page Mar 30, 2019
·
1 revision
java没有js的那种动态不是很能搞事,所以java是没有robot的对象的,用于代替的是三个方法
void setSendGroupMsg(BiConsumer sendGroupMsg) ;//获取发送信息到群的方法
void setSendDiscussMsg(BiConsumer sendDiscussMsg);//获取发送信息到讨论组的方法
void setSendPersonMsg(BiConsumer sendPersonMsg) ;//获取发送信息到个人的方法
使用方法有点曲折,依赖于Java8的api,BiConsumer方法
import java.util.function.BiConsumer;
public class HelloBang{
private BiConsumer sendGroupMsg;
private BiConsumer sendDiscussMsg;
private BiConsumer sendPersonMsg;
public void setSendGroupMsg(BiConsumer sendGroupMsg) {
this.sendGroupMsg = sendGroupMsg;
}
public void setSendDiscussMsg(BiConsumer sendDiscussMsg) {
this.sendDiscussMsg = sendDiscussMsg;
}
public void setSendPersonMsg(BiConsumer sendPersonMsg) {
this.sendPersonMsg = sendPersonMsg;
}
public String check(){
return "hello bang";
}
public void operate(){
sendGroupMsg.accept("123456","hello bang");//发送信息hello bang到123456的群
sendDiscussMsg.accept("123456","hello bang");//发送信息hello bang到123456的讨论组
sendPersonMsg.accept("123456","hello bang");//发送信息hello bang到123456的QQ号
}
}
不难的,我不会骗你的