-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 9f3357b
Showing
27 changed files
with
1,185 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
### Maven template | ||
target/ | ||
pom.xml.tag | ||
pom.xml.releaseBackup | ||
pom.xml.versionsBackup | ||
pom.xml.next | ||
release.properties | ||
dependency-reduced-pom.xml | ||
buildNumber.properties | ||
.mvn/timing.properties | ||
# https://github.com/takari/maven-wrapper#usage-without-binary-jar | ||
.mvn/wrapper/maven-wrapper.jar | ||
|
||
### Java template | ||
# Compiled class file | ||
*.class | ||
|
||
# Log file | ||
*.log | ||
|
||
# BlueJ files | ||
*.ctxt | ||
|
||
# Mobile Tools for Java (J2ME) | ||
.mtj.tmp/ | ||
|
||
# Package Files # | ||
*.jar | ||
*.war | ||
*.nar | ||
*.ear | ||
*.zip | ||
*.tar.gz | ||
*.rar | ||
|
||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml | ||
hs_err_pid* | ||
|
||
### Example user template template | ||
### Example user template | ||
|
||
# IntelliJ project files | ||
.idea | ||
*.iml | ||
out | ||
gen | ||
### Kotlin template | ||
# Compiled class file | ||
*.class | ||
|
||
# Log file | ||
*.log | ||
|
||
# BlueJ files | ||
*.ctxt | ||
|
||
# Mobile Tools for Java (J2ME) | ||
.mtj.tmp/ | ||
|
||
# Package Files # | ||
*.jar | ||
*.war | ||
*.nar | ||
*.ear | ||
*.zip | ||
*.tar.gz | ||
*.rar | ||
|
||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml | ||
hs_err_pid* | ||
|
||
/bots | ||
/cache | ||
/conf | ||
/config | ||
/data | ||
/plugins | ||
*/test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<parent> | ||
<groupId>org.example</groupId> | ||
<artifactId>MiraiLSys</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>Lsys-GetPic</artifactId> | ||
|
||
<properties> | ||
<maven.compiler.source>8</maven.compiler.source> | ||
<maven.compiler.target>8</maven.compiler.target> | ||
</properties> | ||
|
||
</project> |
52 changes: 52 additions & 0 deletions
52
Lsys-GetPic/src/main/java/cn/kloping/lsys/getPic/Loader.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package cn.kloping.lsys.getPic; | ||
|
||
import cn.kloping.lsys.Resource; | ||
import cn.kloping.lsys.entitys.InvokeGroup; | ||
import cn.kloping.lsys.entitys.Request; | ||
import cn.kloping.lsys.entitys.Result; | ||
import cn.kloping.lsys.entitys.User; | ||
import cn.kloping.lsys.workers.Methods; | ||
import cn.kloping.url.UrlUtils; | ||
import com.alibaba.fastjson.JSON; | ||
import com.alibaba.fastjson.JSONObject; | ||
import kotlin.jvm.functions.Function2; | ||
|
||
import java.io.UnsupportedEncodingException; | ||
import java.net.URLEncoder; | ||
|
||
public class Loader { | ||
public static final String baseUrl = "http://49.232.209.180:20041/api/search/pic?keyword=%s&num=2&type=duit"; | ||
|
||
public static final InvokeGroup invokeGroup = new InvokeGroup("getPic"); | ||
|
||
static { | ||
invokeGroup.getInvokes().put("发张.*", "getPicOne"); | ||
invokeGroup.getInvokesAfter().put("发张.*", new String[]{"<Image = $1>", "获取失败"}); | ||
} | ||
|
||
public static final Function2<User, Request, Result> fun1 = (user, request) -> { | ||
String name = request.getStr().substring(request.getOStr().indexOf(".")); | ||
try { | ||
String names = URLEncoder.encode(name, "utf-8"); | ||
JSONObject jo = JSON.parseObject(UrlUtils.getStringFromHttpUrl(false, String.format(baseUrl, names))); | ||
String picUrl = jo.getJSONArray("data").getString(0); | ||
return new Result(new Object[]{picUrl}, 0); | ||
} catch (UnsupportedEncodingException e) { | ||
e.printStackTrace(); | ||
} | ||
return new Result(new Object[]{}, 1); | ||
}; | ||
|
||
public static final Runnable runnable = () -> { | ||
if (!Resource.conf.getInvokeGroups().containsKey("getPic")) | ||
Resource.conf.getInvokeGroups().put("getPic", invokeGroup); | ||
}; | ||
|
||
public static void load() { | ||
Resource.loadConfAfter.add(runnable); | ||
|
||
Methods.invokes.put("getPicOne", fun1); | ||
|
||
Resource.i1(); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
Lsys-GetPic/src/main/java/cn/kloping/lsys/getPic/PluginMain.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package cn.kloping.lsys.getPic; | ||
|
||
import net.mamoe.mirai.console.extension.PluginComponentStorage; | ||
import net.mamoe.mirai.console.plugin.PluginManager; | ||
import net.mamoe.mirai.console.plugin.jvm.JavaPlugin; | ||
import net.mamoe.mirai.console.plugin.jvm.JvmPluginDescriptionBuilder; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
public class PluginMain extends JavaPlugin { | ||
public static final PluginMain INSTANCE = new PluginMain(); | ||
|
||
private PluginMain() { | ||
super(new JvmPluginDescriptionBuilder("cn.kloping.lsys.getPic.PluginMain", "0.1") | ||
.name("插件_4 Author => HRS LSys GetPic Loaded") | ||
.info("插件") | ||
.author("HRS") | ||
.build()); | ||
} | ||
|
||
@Override | ||
public void onLoad(@NotNull PluginComponentStorage $this$onLoad) { | ||
if (!Utils.isExits()) { | ||
getLogger().error("欲使用GetPic插件 必须安装 Lsys 插件"); | ||
getLogger().error("欲使用GetPic插件 必须安装 Lsys 插件"); | ||
getLogger().error("欲使用GetPic插件 必须安装 Lsys 插件"); | ||
PluginManager.INSTANCE.disablePlugin(INSTANCE); | ||
return; | ||
} | ||
Loader.load(); | ||
} | ||
|
||
@Override | ||
public void onEnable() { | ||
getLogger().info(""); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
Lsys-GetPic/src/main/java/cn/kloping/lsys/getPic/Utils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package cn.kloping.lsys.getPic; | ||
|
||
import net.mamoe.mirai.console.plugin.Plugin; | ||
import net.mamoe.mirai.console.plugin.PluginManager; | ||
import net.mamoe.mirai.console.plugin.description.PluginDescription; | ||
import net.mamoe.mirai.console.plugin.loader.PluginLoader; | ||
|
||
public class Utils { | ||
public static boolean isExits() { | ||
for (Plugin plugin : PluginManager.INSTANCE.getPlugins()) { | ||
PluginLoader<Plugin, PluginDescription> loader = (PluginLoader<Plugin, PluginDescription>) plugin.getLoader(); | ||
String id = loader.getPluginDescription(plugin).getId(); | ||
if (id.equals("cn.kloping.Lsys")) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
...-GetPic/src/main/resources/META-INF/services/net.mamoe.mirai.console.plugin.jvm.JvmPlugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
cn.kloping.lsys.getPic.PluginMain |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<parent> | ||
<artifactId>MiraiLSys</artifactId> | ||
<groupId>org.example</groupId> | ||
<version>1.0-SNAPSHOT</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>Lsys-GetSong</artifactId> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.projectlombok</groupId> | ||
<artifactId>lombok</artifactId> | ||
<version>1.18.20</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
<properties> | ||
<maven.compiler.source>8</maven.compiler.source> | ||
<maven.compiler.target>8</maven.compiler.target> | ||
</properties> | ||
|
||
</project> |
114 changes: 114 additions & 0 deletions
114
Lsys-GetSong/src/main/java/cn/kloping/lsys/getSong/Loader.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
package cn.kloping.lsys.getSong; | ||
|
||
import cn.kloping.lsys.Resource; | ||
import cn.kloping.lsys.entitys.InvokeGroup; | ||
import cn.kloping.lsys.entitys.Request; | ||
import cn.kloping.lsys.entitys.Result; | ||
import cn.kloping.lsys.entitys.User; | ||
import cn.kloping.lsys.workers.Methods; | ||
import cn.kloping.url.UrlUtils; | ||
import com.alibaba.fastjson.JSON; | ||
import com.alibaba.fastjson.JSONObject; | ||
import kotlin.jvm.functions.Function2; | ||
|
||
import java.io.UnsupportedEncodingException; | ||
import java.net.URLEncoder; | ||
|
||
public class Loader { | ||
public static final String baseUrl = "http://49.232.209.180:20041/api/search/song?keyword=%s&type=%s"; | ||
private static final Function2<User, Request, Result> pointKugou = (user, request) -> { | ||
try { | ||
int i = request.getOStr().indexOf("."); | ||
String name = request.getStr().substring(i).trim(); | ||
name = URLEncoder.encode(name, "utf-8"); | ||
JSONObject jo = getSong(name, "kugou"); | ||
return new Result(new Object[]{ | ||
"MusicShare", | ||
"KugouMusic", | ||
jo.getString("media_name"), | ||
jo.getString("author_name"), | ||
jo.getString("songUrl"), | ||
jo.getString("imgUrl"), | ||
jo.getString("songUrl") | ||
}, 0); | ||
} catch (UnsupportedEncodingException e) { | ||
e.printStackTrace(); | ||
return new Result(new Object[]{}, 1); | ||
} | ||
}; | ||
private static final Function2<User, Request, Result> pointQQ = (user, request) -> { | ||
try { | ||
int i = request.getOStr().indexOf("."); | ||
String name = request.getStr().substring(i).trim(); | ||
name = URLEncoder.encode(name, "utf-8"); | ||
JSONObject jo = getSong(name, "kugou"); | ||
return new Result(new Object[]{ | ||
"MusicShare", | ||
"QQMusic", | ||
jo.getString("media_name"), | ||
jo.getString("author_name"), | ||
jo.getString("songUrl"), | ||
jo.getString("imgUrl"), | ||
jo.getString("songUrl") | ||
}, 0); | ||
} catch (UnsupportedEncodingException e) { | ||
e.printStackTrace(); | ||
return new Result(new Object[]{}, 1); | ||
} | ||
}; | ||
private static final Function2<User, Request, Result> pointWy = (user, request) -> { | ||
try { | ||
int i = request.getOStr().indexOf("."); | ||
String name = request.getStr().substring(i).trim(); | ||
name = URLEncoder.encode(name, "utf-8"); | ||
JSONObject jo = getSong(name, "kugou"); | ||
return new Result(new Object[]{ | ||
"MusicShare", | ||
"NeteaseCloudMusic", | ||
jo.getString("media_name"), | ||
jo.getString("author_name"), | ||
jo.getString("songUrl"), | ||
jo.getString("imgUrl"), | ||
jo.getString("songUrl") | ||
}, 0); | ||
} catch (UnsupportedEncodingException e) { | ||
e.printStackTrace(); | ||
return new Result(new Object[]{}, 1); | ||
} | ||
}; | ||
|
||
public static final InvokeGroup invokeGroup = new InvokeGroup("getSong"); | ||
|
||
static { | ||
invokeGroup.getInvokes().put("酷狗点歌.*", "pointKugou"); | ||
invokeGroup.getInvokes().put("QQ点歌.*", "pointQQ"); | ||
invokeGroup.getInvokes().put("网易点歌.*", "pointWy"); | ||
invokeGroup.getInvokes().put("点歌系统", "method"); | ||
//======================== | ||
invokeGroup.getInvokesAfter().put("酷狗点歌.*", new String[]{"<$1 = $2, $3, $4, http://49.232.209.180:20041/, $6, $7>", "<At = ?>点歌失败"}); | ||
invokeGroup.getInvokesAfter().put("QQ点歌.*", new String[]{"<$1 = $2, $3, $4, http://49.232.209.180:20041/, $6, $7>", "<At = ?>点歌失败"}); | ||
invokeGroup.getInvokesAfter().put("网易点歌.*", new String[]{"<$1 = $2, $3, $4, http://49.232.209.180:20041/, $6, $7>", "<At = ?>点歌失败"}); | ||
invokeGroup.getInvokesAfter().put("点歌系统", new String[]{"<At = ?>\n酷狗点歌 歌名\n网易点歌 歌名\nQQ点歌 歌名"}); | ||
} | ||
|
||
public static final Runnable runnable = () -> { | ||
if (!Resource.conf.getInvokeGroups().containsKey(invokeGroup.getId())) | ||
Resource.conf.getInvokeGroups().put(invokeGroup.getId(), invokeGroup); | ||
}; | ||
|
||
public static void load() { | ||
Resource.loadConfAfter.add(runnable); | ||
|
||
Methods.invokes.put("pointKugou", pointKugou); | ||
Methods.invokes.put("pointQQ", pointQQ); | ||
Methods.invokes.put("pointWy", pointWy); | ||
|
||
Resource.i1(); | ||
} | ||
|
||
public static JSONObject getSong(String keyword, String type) { | ||
String urlStr = String.format(baseUrl, keyword, type); | ||
String jsonStr = UrlUtils.getStringFromHttpUrl(false, urlStr); | ||
return JSON.parseObject(jsonStr).getJSONArray("data").getJSONObject(0); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
Lsys-GetSong/src/main/java/cn/kloping/lsys/getSong/PluginMain.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package cn.kloping.lsys.getSong; | ||
|
||
import net.mamoe.mirai.console.extension.PluginComponentStorage; | ||
import net.mamoe.mirai.console.plugin.PluginManager; | ||
import net.mamoe.mirai.console.plugin.jvm.JavaPlugin; | ||
import net.mamoe.mirai.console.plugin.jvm.JvmPluginDescriptionBuilder; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
public class PluginMain extends JavaPlugin { | ||
public static final PluginMain INSTANCE = new PluginMain(); | ||
|
||
private PluginMain() { | ||
super(new JvmPluginDescriptionBuilder("cn.kloping.lsys.getSong.PluginMain", "0.1") | ||
.name("插件_5 Author => HRS LSys GetSong Loaded") | ||
.info("插件") | ||
.author("HRS") | ||
.build()); | ||
} | ||
|
||
@Override | ||
public void onLoad(@NotNull PluginComponentStorage $this$onLoad) { | ||
if (!Utils.isExits()) { | ||
getLogger().error("欲使用GetSong插件 必须安装 Lsys 插件"); | ||
getLogger().error("欲使用GetSong插件 必须安装 Lsys 插件"); | ||
getLogger().error("欲使用GetSong插件 必须安装 Lsys 插件"); | ||
PluginManager.INSTANCE.disablePlugin(INSTANCE); | ||
return; | ||
} | ||
Loader.load(); | ||
} | ||
|
||
@Override | ||
public void onEnable() { | ||
getLogger().info(""); | ||
} | ||
} |
Oops, something went wrong.