新增摸鱼模块
测试大头菜
This commit is contained in:
55
src/main/java/com/yutou/qqbot/models/Commands/Moyu.java
Normal file
55
src/main/java/com/yutou/qqbot/models/Commands/Moyu.java
Normal file
@@ -0,0 +1,55 @@
|
||||
package com.yutou.qqbot.models.Commands;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.yutou.qqbot.QQBotManager;
|
||||
import com.yutou.qqbot.interfaces.DownloadInterface;
|
||||
import com.yutou.qqbot.models.Model;
|
||||
import com.yutou.qqbot.utlis.HttpTools;
|
||||
import net.mamoe.mirai.event.events.MessageEvent;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class Moyu extends Model {
|
||||
@Override
|
||||
public boolean isUserPublic() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getUsePowers() {
|
||||
return new String[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModelName() {
|
||||
return "摸鱼提醒";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMessage(Long qq, MessageEvent event, boolean isGroup) {
|
||||
super.onMessage(qq, event, isGroup);
|
||||
if(msg.equals(QQGroupCommands.QQ_MOYU)){
|
||||
send(qq);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTime(Long qq, String time) {
|
||||
super.onTime(qq, time);
|
||||
if("08:00:00".equals(time)){
|
||||
send(qq);
|
||||
}
|
||||
}
|
||||
|
||||
private void send(Long qq){
|
||||
String ret = HttpTools.get("https://api.j4u.ink/proxy/remote/moyu.json");
|
||||
JSONObject json=JSONObject.parseObject(ret);
|
||||
HttpTools.download(json.getJSONObject("data").getString("moyu_url"), "moyu.jpg", new DownloadInterface() {
|
||||
@Override
|
||||
public void onDownload(File file) {
|
||||
super.onDownload(file);
|
||||
QQBotManager.getInstance().sendMessage(file,qq,"");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user