管理员模块:支持this关键词标识本群
This commit is contained in:
parent
9d88fef157
commit
ccdca908cf
@ -23,16 +23,16 @@ public class AdminMessage extends Message {
|
||||
private static final String MODEL_SHOW = "!查看模块";
|
||||
private static final String MODEL_DEL = "!删除模块";
|
||||
|
||||
public static final String SYSTEM_RESTART_QQ="!重启qq";
|
||||
public static final String SYSTEM_RESTART_TOOLS="!重启服务";
|
||||
public static final String SYSTEM_RESTART_QQ = "!重启qq";
|
||||
public static final String SYSTEM_RESTART_TOOLS = "!重启服务";
|
||||
|
||||
public static final String SYSTEM_UPDATE_QQ="!更新qq";
|
||||
public static final String SYSTEM_UPDATE_NAS="!更新服务";
|
||||
public static final String SYSTEM_UPDATE_QQ = "!更新qq";
|
||||
public static final String SYSTEM_UPDATE_NAS = "!更新服务";
|
||||
|
||||
|
||||
private static final String SHOW="!列表";
|
||||
private static final String HELP="!help";
|
||||
private static final String SIGN="!签到";
|
||||
private static final String SHOW = "!列表";
|
||||
private static final String HELP = "!help";
|
||||
private static final String SIGN = "!签到";
|
||||
}
|
||||
|
||||
public AdminMessage(Long qq, String msg) {
|
||||
@ -40,7 +40,7 @@ public class AdminMessage extends Message {
|
||||
String[] msgGroup = msg.replace("!", "!").split(" ");
|
||||
|
||||
switch (msgGroup[0]) {
|
||||
case QQCommands.HELP -> QQBotManager.getInstance().sendMessage(qq,Model.getCommands(QQCommands.class).toString());
|
||||
case QQCommands.HELP -> QQBotManager.getInstance().sendMessage(qq, Model.getCommands(QQCommands.class).toString());
|
||||
case QQCommands.POWER_ADD -> {
|
||||
if (msgGroup.length == 1) {
|
||||
StringBuilder builder = Model.getCommands(Model.QQGroupCommands.class);
|
||||
@ -84,7 +84,7 @@ public class AdminMessage extends Message {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
for (Class<?> aClass : Model.classList) {
|
||||
try {
|
||||
Model model= (Model) aClass.getDeclaredConstructor().newInstance();
|
||||
Model model = (Model) aClass.getDeclaredConstructor().newInstance();
|
||||
builder.append("[").append(model.getModelName()).append("]");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@ -97,9 +97,9 @@ public class AdminMessage extends Message {
|
||||
if (msgGroup.length <= 2) {
|
||||
addModel(msgGroup[1], null);
|
||||
} else {
|
||||
if("this".equals(msgGroup[1])){
|
||||
addModel(sendQQ+"",msgGroup[2]);
|
||||
}else {
|
||||
if ("this".equals(msgGroup[1])) {
|
||||
addModel(sendQQ + "", msgGroup[2]);
|
||||
} else {
|
||||
addModel(msgGroup[1], msgGroup[2]);
|
||||
}
|
||||
}
|
||||
@ -109,9 +109,9 @@ public class AdminMessage extends Message {
|
||||
if (msgGroup.length == 1) {
|
||||
QQBotManager.getInstance().sendMessage(qq, "使用方法:" + QQCommands.MODEL_SHOW + " [qqnumber]");
|
||||
} else {
|
||||
String qqGroup=msgGroup[1];
|
||||
if("this".equals(qqGroup)){
|
||||
qqGroup=sendQQ+"";
|
||||
String qqGroup = msgGroup[1];
|
||||
if ("this".equals(qqGroup)) {
|
||||
qqGroup = sendQQ + "";
|
||||
}
|
||||
List<String> list = QQNumberManager.getManager().getUseModel(Long.parseLong(qqGroup));
|
||||
StringBuilder builder = new StringBuilder();
|
||||
@ -125,9 +125,9 @@ public class AdminMessage extends Message {
|
||||
if (msgGroup.length == 1) {
|
||||
QQBotManager.getInstance().sendMessage(qq, "使用方法:" + QQCommands.MODEL_DEL + " [qqnumber] 模块 用&分割");
|
||||
} else {
|
||||
String qqGroup=msgGroup[1];
|
||||
if("this".equals(qqGroup)){
|
||||
qqGroup=sendQQ+"";
|
||||
String qqGroup = msgGroup[1];
|
||||
if ("this".equals(qqGroup)) {
|
||||
qqGroup = sendQQ + "";
|
||||
}
|
||||
if (msgGroup.length <= 2) {
|
||||
delModel(qqGroup, null);
|
||||
@ -137,71 +137,71 @@ public class AdminMessage extends Message {
|
||||
}
|
||||
}
|
||||
case QQCommands.SHOW -> {
|
||||
List<Long> users=QQNumberManager.getManager().getNumber();
|
||||
StringBuilder builder=new StringBuilder();
|
||||
List<Long> users = QQNumberManager.getManager().getNumber();
|
||||
StringBuilder builder = new StringBuilder();
|
||||
for (Long user : users) {
|
||||
builder.append(user).append(":\n");
|
||||
List<String> modelPower=QQNumberManager.getManager().getUseModel(user);
|
||||
List<String> modelPower = QQNumberManager.getManager().getUseModel(user);
|
||||
builder.append("模块(").append(modelPower.size()).append("):\n");
|
||||
for (String model : modelPower) {
|
||||
builder.append(model).append("\n");
|
||||
}
|
||||
List<String> list=QQNumberManager.getManager().getPower(user);
|
||||
List<String> list = QQNumberManager.getManager().getPower(user);
|
||||
builder.append("权限(").append(list.size()).append("):\n");
|
||||
for (String power : list) {
|
||||
builder.append(power).append("\n");
|
||||
}
|
||||
builder.append("\n");
|
||||
}
|
||||
QQBotManager.getInstance().sendMessage(qq,builder.toString());
|
||||
QQBotManager.getInstance().sendMessage(qq, builder.toString());
|
||||
}
|
||||
case QQCommands.SYSTEM_RESTART_QQ -> {
|
||||
QQBotManager.getInstance().sendMessage(qq,"正在重启机器人");
|
||||
QQBotManager.getInstance().sendMessage(qq, "正在重启机器人");
|
||||
System.out.println("结束进程");
|
||||
AppTools.exec("cd /home/yutou/public/servier/qqbot && ./start.sh",null,true,false);
|
||||
AppTools.exec("cd /home/yutou/public/servier/qqbot && ./start.sh", null, true, false);
|
||||
}
|
||||
case QQCommands.SYSTEM_RESTART_TOOLS ->{
|
||||
QQBotManager.getInstance().sendMessage(qq,"正在重启服务");
|
||||
case QQCommands.SYSTEM_RESTART_TOOLS -> {
|
||||
QQBotManager.getInstance().sendMessage(qq, "正在重启服务");
|
||||
System.out.println("结束进程");
|
||||
AppTools.exec("cd /home/yutou/public/servier/tools && ./start.sh",null,true,false);
|
||||
AppTools.exec("cd /home/yutou/public/servier/tools && ./start.sh", null, true, false);
|
||||
}
|
||||
case QQCommands.SYSTEM_UPDATE_QQ ->{
|
||||
QQBotManager.getInstance().sendMessage(qq,"正在更新qq");
|
||||
case QQCommands.SYSTEM_UPDATE_QQ -> {
|
||||
QQBotManager.getInstance().sendMessage(qq, "正在更新qq");
|
||||
System.out.println("结束进程");
|
||||
AppTools.exec("cd /root/git/QQBot && ./update.sh",null,true,false);
|
||||
AppTools.exec("cd /root/git/QQBot && ./update.sh", null, true, false);
|
||||
}
|
||||
case QQCommands.SYSTEM_UPDATE_NAS ->{
|
||||
QQBotManager.getInstance().sendMessage(qq,"正在更新NAS服务");
|
||||
case QQCommands.SYSTEM_UPDATE_NAS -> {
|
||||
QQBotManager.getInstance().sendMessage(qq, "正在更新NAS服务");
|
||||
System.out.println("结束进程");
|
||||
AppTools.exec("cd /root/git/nas-service && ./update.sh",null,true,false);
|
||||
AppTools.exec("cd /root/git/nas-service && ./update.sh", null, true, false);
|
||||
}
|
||||
|
||||
case QQCommands.SIGN -> {
|
||||
boolean sign=true;
|
||||
boolean sign = true;
|
||||
Log.i("开始签到");
|
||||
try{
|
||||
try {
|
||||
new Tsdm().tsdmSign();
|
||||
}catch (Exception e){
|
||||
sign=false;
|
||||
QQBotManager.getInstance().sendMessage(qq,"tsdm签到失败:"+AppTools.getExceptionString(e));
|
||||
} catch (Exception e) {
|
||||
sign = false;
|
||||
QQBotManager.getInstance().sendMessage(qq, "tsdm签到失败:" + AppTools.getExceptionString(e));
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
new BaiHeHui().sign();
|
||||
}catch (Exception e){
|
||||
sign=false;
|
||||
QQBotManager.getInstance().sendMessage(qq,"百合会签到失败:"+AppTools.getExceptionString(e));
|
||||
} catch (Exception e) {
|
||||
sign = false;
|
||||
QQBotManager.getInstance().sendMessage(qq, "百合会签到失败:" + AppTools.getExceptionString(e));
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
new NicePT().sign();
|
||||
}catch (Exception e){
|
||||
sign=false;
|
||||
QQBotManager.getInstance().sendMessage(qq,"NicePT签到失败:"+AppTools.getExceptionString(e));
|
||||
} catch (Exception e) {
|
||||
sign = false;
|
||||
QQBotManager.getInstance().sendMessage(qq, "NicePT签到失败:" + AppTools.getExceptionString(e));
|
||||
e.printStackTrace();
|
||||
}
|
||||
if(sign){
|
||||
QQBotManager.getInstance().sendMessage(qq,"签到任务完成");
|
||||
if (sign) {
|
||||
QQBotManager.getInstance().sendMessage(qq, "签到任务完成");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -259,20 +259,22 @@ public class AdminMessage extends Message {
|
||||
}
|
||||
|
||||
private void delModel(String qq, String model) {
|
||||
boolean flag=false;
|
||||
try {
|
||||
if (model == null) {
|
||||
List<String> list = QQNumberManager.getManager().getUseModel(Long.parseLong(qq));
|
||||
for (String power : list) {
|
||||
QQNumberManager.getManager().delUseModel(Long.parseLong(qq), Class.forName(power));
|
||||
flag=QQNumberManager.getManager().delUseModel(Long.parseLong(qq), Class.forName(power));
|
||||
}
|
||||
} else {
|
||||
for (String power : model.split("&")) {
|
||||
QQNumberManager.getManager().delUseModel(Long.parseLong(qq), Class.forName(power));
|
||||
flag=QQNumberManager.getManager().delUseModel(Long.parseLong(qq), Class.forName(power));
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
QQBotManager.getInstance().sendMessage(sendQQ, flag ? "删除成功" : "删除失败");
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user