nlr-devteam / grasspictures Goto Github PK
View Code? Open in Web Editor NEW在 QQ 群聊中接入草图的服务
Home Page: https://grass.nlrdev.top/apps
License: GNU Affero General Public License v3.0
在 QQ 群聊中接入草图的服务
Home Page: https://grass.nlrdev.top/apps
License: GNU Affero General Public License v3.0
JvmPlugin.getDataFolder()
而不是直接硬编码绝对路径, 以及变量名命名不规范and more...
File directory = new File(INSTANCE.getDataFolder(), "cache/grasspic/");
// .....
File savedImage = new File(directory, id);
Files.copy(/**/, savedImage.toPath());
return savedImage;
mirai 是多线程模型, 需要考虑并发执行的情况
其他建议:
new Thread
Thread.stop
而是使用 中断 Thread.interrupt
并发:
if (nextAreYou.remove(m.getSender().getId()) == null) return;
指的是
<User>
泛型: see mamoe/mirai#585
如果最后都要检查是不是 null, 我建议不如干脆直接抛出一个 RuntimeException
GrassPictures/src/main/java/cn/whitrayhb/grasspics/Cooler.java
Lines 9 to 39 in 1f154bb
通用的实现方法是创建一个 Map</*id*/ Long, /* timestamp */ Long>
然后 lock 方法直接 put(id, System.currentTimeMillis())
isLocked(long id) {
Long value = map.get(id);
if (value == null) return false;
return System.currentTimeMills() - value <= 1000L;
}
重启过,问题没有解决。
后台输出显示:(个人信息已作处理)
2023-04-30 13:32:57 V/Bot.xxxxxxxxxx: [Bot(xxxxxxxxxx)] 秋水(xxxxxxxxxx) -> 生草
2023-04-30 13:32:59 V/Bot.xxxxxxxxxx: Group(xxxxxxxxxx) <- [mirai:quote:[mirai:source:ids=[100926], internalIds=[370393661], from group xxxxxxxxxx to xxxxxxxxxx at 1682832777], content=生草]您指定的图片不存在!
并没有“图片下载失败”之类的报错
经过咨询相关人员后得知,机器人并未被ban或者被限流
控制台输出:
2023-04-30 13:41:26 W/stderr: org.json.JSONException: Expected a ',' or '}' at 11 [character 12 line 1]
2023-04-30 13:41:26 W/stderr: at GrassPictures-1.2.0.mirai2.jar[private]//org.json.JSONTokener.syntaxError(JSONTokener.java:501)
2023-04-30 13:41:26 W/stderr: at GrassPictures-1.2.0.mirai2.jar[private]//org.json.JSONObject.<init>(JSONObject.java:264)
2023-04-30 13:41:26 W/stderr: at GrassPictures-1.2.0.mirai2.jar[private]//org.json.JSONObject.<init>(JSONObject.java:404)
2023-04-30 13:41:26 W/stderr: at GrassPictures-1.2.0.mirai2.jar//cn.whitrayhb.grasspics.commands.PostGrassPic.lambda$postToPublicChannel$1(PostGrassPic.java:92)
2023-04-30 13:41:26 W/stderr: at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
2023-04-30 13:41:26 W/stderr: at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
2023-04-30 13:41:26 W/stderr: at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
2023-04-30 13:41:26 W/stderr: at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
2023-04-30 13:41:26 W/stderr: at java.base/java.lang.Thread.run(Thread.java:833)
2023-02-11 10:17:19 W/草图插件: Exception in executing command [mirai:source:ids=[164576], internalIds=[-331462555], from group 3291584316 to 182850795 at 1676081839][mirai:quote:[mirai:source:ids=[164574], internalIds=[294937614], from 3466938657 to 182850795 at 1676081805], content=<not yet initialized>] 草图投稿
java.lang.IllegalArgumentException: message is empty
at net.mamoe.mirai.internal.contact.AbstractUserKt.sendMessageImpl(AbstractUser.kt:258)
at net.mamoe.mirai.internal.contact.CommonGroupImpl.sendMessage$suspendImpl(GroupImpl.kt:219)
at net.mamoe.mirai.internal.contact.CommonGroupImpl.sendMessage(GroupImpl.kt)
at net.mamoe.mirai.console.command.MemberCommandSender.sendMessage$suspendImpl(CommandSender.kt:687)
at net.mamoe.mirai.console.command.MemberCommandSender.sendMessage(CommandSender.kt)
at net.mamoe.mirai.console.command.MemberCommandSender$sendMessage$4.invoke(CommandSender.kt)
at net.mamoe.mirai.console.command.MemberCommandSender$sendMessage$4.invoke(CommandSender.kt)
at kotlin.coroutines.intrinsics.IntrinsicsKt__IntrinsicsJvmKt$createCoroutineUnintercepted$$inlined$createCoroutineFromSuspendFunction$IntrinsicsKt__IntrinsicsJvmKt$1.invokeSuspend(IntrinsicsJvm.kt:205)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlin.coroutines.ContinuationKt.startCoroutine(Continuation.kt:115)
at me.him188.kotlin.jvm.blocking.bridge.internal.RunSuspendKt.$runSuspend$(RunSuspend.kt:18)
at net.mamoe.mirai.console.command.MemberCommandSender.sendMessage(CommandSender.kt)
at GrassPictures-1.1.9.mirai2.jar//cn.whitrayhb.grasspics.commands.PostGrassPic.onCommand(PostGrassPic.java:209)
at net.mamoe.mirai.console.command.java.JRawCommand$overloads$1$invokeSuspend$$inlined$runBIO$1.invoke(CoroutineUtils.kt:23)
at kotlinx.coroutines.InterruptibleKt.runInterruptibleInExpectedContext(Interruptible.kt:51)
at kotlinx.coroutines.InterruptibleKt.access$runInterruptibleInExpectedContext(Interruptible.kt:1)
at kotlinx.coroutines.InterruptibleKt$runInterruptible$2.invokeSuspend(Interruptible.kt:43)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
at kotlinx.coroutines.internal.LimitedDispatcher.run(LimitedDispatcher.kt:42)
at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:95)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:570)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664)
E/草图插件: 图片下载失败!
一直超时,但是官网是能看到的
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.