新增摸鱼模块
测试大头菜
This commit is contained in:
parent
d35b1bdc42
commit
4cbcba6b6e
@ -5,6 +5,7 @@ import com.yutou.qqbot.models.Animal.TurnipProphet;
|
||||
import com.yutou.qqbot.models.Commands.BaiduDown;
|
||||
import com.yutou.qqbot.models.Commands.Bangumi;
|
||||
import com.yutou.qqbot.models.Commands.BTDownload;
|
||||
import com.yutou.qqbot.models.Commands.Moyu;
|
||||
import com.yutou.qqbot.models.Commands.System.*;
|
||||
import com.yutou.qqbot.models.Model;
|
||||
import com.yutou.qqbot.models.WebSign.BiliBiliMangeSign;
|
||||
@ -51,6 +52,7 @@ public class QQBotManager {
|
||||
Model.classList.add(GetSeTu.class);
|
||||
Model.classList.add(BTDownload.class);
|
||||
Model.classList.add(BiliBiliMangeSign.class);
|
||||
Model.classList.add(Moyu.class);
|
||||
}
|
||||
private static QQBotManager botManager = null;
|
||||
private Bot bot;
|
||||
|
@ -64,10 +64,12 @@ public class TurnipProphet extends Model {
|
||||
@Override
|
||||
public void onMessage(Long qq, MessageEvent event, boolean isGroup) {
|
||||
super.onMessage(qq, event, isGroup);
|
||||
System.out.println("测试大头菜");
|
||||
user = qq;
|
||||
sendQQ = qq;
|
||||
if (isGroup) {
|
||||
if (!event.getMessage().serializeToMiraiCode().contains("[mirai:at:2476945931]")) {
|
||||
System.out.println("没有@?");
|
||||
return;
|
||||
}
|
||||
user = event.getSource().getFromId();
|
||||
@ -75,7 +77,7 @@ public class TurnipProphet extends Model {
|
||||
int money = -1;
|
||||
try {
|
||||
if (isGroup) {
|
||||
msg = msg.replace("@2476945931", "");
|
||||
msg = msg.replace("@2476945931", "").trim();
|
||||
}
|
||||
money = Integer.parseInt(msg.trim());
|
||||
} catch (Exception e) {
|
||||
@ -88,6 +90,7 @@ public class TurnipProphet extends Model {
|
||||
}
|
||||
|
||||
private void showData() {
|
||||
System.out.println("发送数据");
|
||||
String redisKey = user + "_turnip";
|
||||
String data = RedisTools.get(redisKey);
|
||||
if (StringUtils.isEmpty(data)) {
|
||||
|
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,"");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -33,6 +33,7 @@ public abstract class Model implements ModelInterface {
|
||||
public final static String QQ_TOOLS_IDEA_URL = "!idea_url";
|
||||
|
||||
public final static String QQ_BANGUMI_INFO = "!保存动画信息>";
|
||||
public final static String QQ_MOYU = "!摸鱼";
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user