基于 graphql 的 宝可梦查询插件
-
QueryPokemon
宝可梦查询插件
效果
安装方法
- 将插件放入 plugins 文件夹
- 运行一次或在 data 文件夹创建 bot.good.QueryPokemon 文件夹
- 将 release 中的 query-script.zip 解压并放入 bot.good.QueryPokemon 中
- 在管理员前提下, 发送 #enable 和 #enable all this
- 若 jdk 版本大于 11 则需在
plugin-shared-libraries/libraries.txt
追加以下内容
org.openjdk.nashorn:nashorn-core:15.4
query
命令需要使用 chatcommand 插件作为前置
使用方法
支持命令
- #图鉴 名称/id [第几个形态]
- #道具 名称/id
- #招式 名称/id
- #特性 名称/id
自定义
data/bot.good.QueryPokemon/ 目录下的 *.query 文件是模板文件, 可修改格式
-
请问一下为啥输入#enable this all后会显示“没有该指令”
-
@ASIMOV 写文档的时候写漂了
应该是 #enable all this -
报红了
2022-08-16 23:57:43 E/bot.good.QueryPokemon: 初始化配置失败 2022-08-16 23:57:43 E/bot.good.QueryPokemon: java.lang.NullPointerException: Cannot invoke "javax.script.ScriptEngine.createBindings()" because "bot.good.QueryExecutable.engine" is null java.lang.NullPointerException: Cannot invoke "javax.script.ScriptEngine.createBindings()" because "bot.good.QueryExecutable.engine" is null at QueryPokemon-0.0.1.jar//bot.good.QueryExecutable.<clinit>(QueryExecutable.kt:91) at QueryPokemon-0.0.1.jar//bot.good.QueryPokemon.onEnable(QueryPokemon.kt:57) at net.mamoe.mirai.console.internal.plugin.JvmPluginInternal.internalOnEnable$mirai_console(JvmPluginInternal.kt:131) at net.mamoe.mirai.console.internal.plugin.BuiltInJvmPluginLoaderImpl.enable(BuiltInJvmPluginLoaderImpl.kt:278) at net.mamoe.mirai.console.internal.plugin.BuiltInJvmPluginLoaderImpl.enable(BuiltInJvmPluginLoaderImpl.kt:35) at net.mamoe.mirai.console.plugin.jvm.JvmPluginLoader$BuiltIn.enable(JvmPluginLoader.kt) at net.mamoe.mirai.console.plugin.jvm.JvmPluginLoader$BuiltIn.enable(JvmPluginLoader.kt:50) at net.mamoe.mirai.console.plugin.PluginManager.enablePlugin(PluginManager.kt:173) at net.mamoe.mirai.console.internal.plugin.PluginManagerImpl.enableAllLoadedPlugins$mirai_console(PluginManagerImpl.kt:178) at net.mamoe.mirai.console.internal.MiraiConsoleImplementationBridge.doStart$mirai_console(MiraiConsoleImplementationBridge.kt:235) at net.mamoe.mirai.console.MiraiConsoleImplementation$Companion.start(MiraiConsoleImplementation.kt:464) at net.mamoe.mirai.console.terminal.MiraiConsoleTerminalLoader.startAsDaemon(MiraiConsoleTerminalLoader.kt:168) at net.mamoe.mirai.console.terminal.MiraiConsoleTerminalLoader.startAsDaemon$default(MiraiConsoleTerminalLoader.kt:167) at net.mamoe.mirai.console.terminal.MiraiConsoleTerminalLoader.main(MiraiConsoleTerminalLoader.kt:52) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:568) at org.itxtech.mcl.Utility.bootJars(Utility.java:89) at org.itxtech.mcl.Utility.bootJars(Utility.java:79) at org.itxtech.mcl.Utility.bootMirai(Utility.java:101) at org.itxtech.mcl.module.builtin.Boot.boot(Boot.java:109) at org.itxtech.mcl.module.ModuleManager.phaseBoot(ModuleManager.java:148) at org.itxtech.mcl.Loader.lambda$start$4(Loader.java:189) at org.itxtech.mcl.Loader.tryCatching(Loader.java:146) at org.itxtech.mcl.Loader.start(Loader.java:189) at org.itxtech.mcl.Loader.main(Loader.java:79)
-
@JustinHuangber 要在libraries添加 nashorn 引擎,见安装第5点
-
@whiterasbk 已经加了依赖了
-
@JustinHuangber 已解决, 下载 最新 release 下的 QueryPokemon-0.0.1.jar 即可
-
@whiterasbk 文字能正常发出来,但图片报红了
2022-08-17 18:30:37 I/bot.good.QueryPokemon: using jsdelivr for improving static resource access speed 2022-08-17 18:30:38 E/bot.good.QueryPokemon: accessing url: https://cdn.jsdelivr.net/gh/PokeAPI/sprites@2.0.0/sprites/pokemon/1.png 2022-08-17 18:30:38 E/bot.good.QueryPokemon: java.net.UnknownHostException: 请求的名称有效,但是找不到请求的类型的数据。 (raw.githubusercontent.com) java.net.UnknownHostException: 请求的名称有效,但是找不到请求的类型的数据。 (raw.githubusercontent.com) at java.base/java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method) at java.base/java.net.InetAddress$PlatformNameService.lookupAllHostAddr(InetAddress.java:933) at java.base/java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1519) at java.base/java.net.InetAddress$NameServiceAddresses.get(InetAddress.java:852) at java.base/java.net.InetAddress.getAllByName0(InetAddress.java:1509) at java.base/java.net.InetAddress.getAllByName(InetAddress.java:1367) at java.base/java.net.InetAddress.getAllByName(InetAddress.java:1301) at QueryPokemon-0.0.1.jar//okhttp3.Dns$1.lookup(Dns.java:39) at QueryPokemon-0.0.1.jar//okhttp3.internal.http.RouteSelector.resetNextInetSocketAddress(RouteSelector.java:173) at QueryPokemon-0.0.1.jar//okhttp3.internal.http.RouteSelector.nextProxy(RouteSelector.java:139) at QueryPokemon-0.0.1.jar//okhttp3.internal.http.RouteSelector.next(RouteSelector.java:81) at QueryPokemon-0.0.1.jar//okhttp3.internal.http.StreamAllocation.findConnection(StreamAllocation.java:172) at QueryPokemon-0.0.1.jar//okhttp3.internal.http.StreamAllocation.findHealthyConnection(StreamAllocation.java:123) at QueryPokemon-0.0.1.jar//okhttp3.internal.http.StreamAllocation.newStream(StreamAllocation.java:93) at QueryPokemon-0.0.1.jar//okhttp3.internal.http.HttpEngine.connect(HttpEngine.java:296) at QueryPokemon-0.0.1.jar//okhttp3.internal.http.HttpEngine.sendRequest(HttpEngine.java:248) at QueryPokemon-0.0.1.jar//okhttp3.RealCall.getResponse(RealCall.java:243) at QueryPokemon-0.0.1.jar//okhttp3.RealCall$ApplicationInterceptorChain.proceed(RealCall.java:201) at QueryPokemon-0.0.1.jar//okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:163) at QueryPokemon-0.0.1.jar//okhttp3.RealCall.execute(RealCall.java:57) at QueryPokemon-0.0.1.jar//bot.good.UtilsKt.openStreamOnClient(utils.kt:252) at QueryPokemon-0.0.1.jar//bot.good.FormatKt.formatMessage(Format.kt:145) at QueryPokemon-0.0.1.jar//bot.good.FormatKt.formatMessage(Format.kt:238) at QueryPokemon-0.0.1.jar//bot.good.QueryCommand.query(cmd.kt:263) at QueryPokemon-0.0.1.jar//bot.good.QueryCommand.access$query(cmd.kt:9) at QueryPokemon-0.0.1.jar//bot.good.QueryCommand$query$1.invokeSuspend(cmd.kt) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106) at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:570) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:749) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664)
-
不加个权限最大的机器人主人吗
-
@JustinHuangber 可能是图片连接挂了
解决方案有两个- 找到data/bot.good.QueryPokemon/preload-script/script.js的79~85行
修改为
if (localSpritesPath != null) { return transferUrl2Local(link, localSpritesPath) } else { return link }
这样就会从github官方走
2. 到 这里
下载 sprites 资源文件 并解压到任意路径(不能有空格和中文)
最后 在配置中 local_sprites_folder 项 填入正确路径
这样图片会走本地上传 - 找到data/bot.good.QueryPokemon/preload-script/script.js的79~85行
-
@greatwo2 可能会在后续的版本中修改插件的权限管理逻辑
-
@whiterasbk 换成本地路径已解决,谢谢
-
怎么设置管理员,我没权限呀咋
-
![QZX6QU~{
W7L_%E(CG
YY]9.png](/assets/uploads/files/1660963024659-qzx6qu-96-w7l_-e-cg-96-yy-9.png) 为什么搜皮卡丘都没有 -
@w1945512171 当前版本并无管理员配置,要获取权限,必须由QQ群的管理员手动 输入 #enable 和 #enable all this,之后每个指令由一般群员就可直接触发
-
@w1945512171 图片看不了
-
查询出错: Failed to connect to beta.pokeapi.co/172.67.153.110:443 提示这个怎么处理?
-
@Baikele 请提供后台报错信息
-
2022-09-29 20:26:42 V/Bot.3047289397: Group(200252932) <- 已在本群开启插件
2022-09-29 20:26:43 E/bot.good.QueryPokemon: java.net.ConnectException: Failed to connect to beta.pokeapi.co/104.21.74.24:443
java.net.ConnectException: Failed to connect to beta.pokeapi.co/104.21.74.24:443
at mirai-api-http-2.6.2.jar//okhttp3.internal.connection.RealConnection.connectSocket(RealConnection.kt:297)
at mirai-api-http-2.6.2.jar//okhttp3.internal.connection.RealConnection.connect(RealConnection.kt:207)
at mirai-api-http-2.6.2.jar//okhttp3.internal.connection.ExchangeFinder.findConnection(ExchangeFinder.kt:226)
at mirai-api-http-2.6.2.jar//okhttp3.internal.connection.ExchangeFinder.findHealthyConnection(ExchangeFinder.kt:106)
at mirai-api-http-2.6.2.jar//okhttp3.internal.connection.ExchangeFinder.find(ExchangeFinder.kt:74)
at mirai-api-http-2.6.2.jar//okhttp3.internal.connection.RealCall.initExchange$okhttp(RealCall.kt:255)
at mirai-api-http-2.6.2.jar//okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.kt:32)
at mirai-api-http-2.6.2.jar//okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
at mirai-api-http-2.6.2.jar//okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.kt:95)
at mirai-api-http-2.6.2.jar//okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
at mirai-api-http-2.6.2.jar//okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:83)
at mirai-api-http-2.6.2.jar//okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
at mirai-api-http-2.6.2.jar//okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:76)
at mirai-api-http-2.6.2.jar//okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
at mirai-api-http-2.6.2.jar//okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:201)
at mirai-api-http-2.6.2.jar//okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:517)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.base/java.lang.Thread.run(Unknown Source)
Caused by: java.net.ConnectException: Connection timed out: no further information
at java.base/sun.nio.ch.Net.pollConnect(Native Method)
at java.base/sun.nio.ch.Net.pollConnectNow(Unknown Source)
at java.base/sun.nio.ch.NioSocketImpl.timedFinishConnect(Unknown Source)
at java.base/sun.nio.ch.NioSocketImpl.connect(Unknown Source)
at java.base/java.net.SocksSocketImpl.connect(Unknown Source)
at java.base/java.net.Socket.connect(Unknown Source)
at mirai-api-http-2.6.2.jar//okhttp3.internal.platform.Platform.connectSocket(Platform.kt:128)
at mirai-api-http-2.6.2.jar//okhttp3.internal.connection.RealConnection.connectSocket(RealConnection.kt:295)查询10次可能就能成功一次
-
@986162244 可能你得开个代理,pokeapi网站有可能对请求ip进行限流,在官网上有建议api调用者对请求结果进行缓存,但是这个插件没有实现