新增QQ机器人
恢复酷Q机器人功能
This commit is contained in:
@@ -204,7 +204,7 @@ public class RedisTools {
|
||||
|
||||
}
|
||||
|
||||
private static class Consumer extends JedisPubSub {
|
||||
protected static class Consumer extends JedisPubSub {
|
||||
@Override
|
||||
public void onPMessage(String pattern, String channel, String message) {
|
||||
super.onPMessage(pattern, channel, message);
|
||||
@@ -238,7 +238,7 @@ public class RedisTools {
|
||||
System.out.println("onMessage: channel=" + channel + " msg=" + message);
|
||||
}
|
||||
|
||||
private void system(String type, String value) {
|
||||
public static void system(String type, String value) {
|
||||
try {
|
||||
String exec = null;
|
||||
switch (type) {
|
||||
@@ -265,23 +265,24 @@ public class RedisTools {
|
||||
|
||||
|
||||
|
||||
private void bot(String value) {
|
||||
public static void bot(String value) {
|
||||
switch (value) {
|
||||
case "getip":
|
||||
JSONObject json = JSONObject.parseObject(Tools.get("https://api.asilu.com/ip/"));
|
||||
String ip = json.getString("ip");
|
||||
RedisTools.set(1, "msg_" + System.currentTimeMillis(), "服务器IP:\n" + ip);
|
||||
QQBotManager.getInstance().sendMessage("服务器IP:\n" + ip);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
public static void processOut(InputStream inputStream) {
|
||||
|
||||
String tmp, str = "null";
|
||||
String tmp;
|
||||
StringBuilder str = new StringBuilder("null");
|
||||
try {
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
|
||||
while ((tmp = reader.readLine()) != null) {
|
||||
str += tmp + "\n";
|
||||
str.append(tmp).append("\n");
|
||||
}
|
||||
reader.close();
|
||||
inputStream.close();
|
||||
@@ -289,7 +290,7 @@ public class RedisTools {
|
||||
e.printStackTrace();
|
||||
}
|
||||
System.out.println("cmd > " + str);
|
||||
RedisTools.set(1, "msg_" + System.currentTimeMillis(), str);
|
||||
QQBotManager.getInstance().sendMessage(str.toString());
|
||||
System.out.println("线程结束");
|
||||
}
|
||||
public static void main(String[] args) {
|
||||
|
||||
Reference in New Issue
Block a user