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