新增图片视频压缩,指定群监听

This commit is contained in:
wenxin 2024-12-02 21:23:59 +08:00
parent 68fe006b2a
commit dc6ce30ec7
14 changed files with 2092 additions and 39 deletions

View File

@ -0,0 +1,30 @@
{
"deviceInfoVersion": 3,
"data": {
"display": "MIRAI.539626.001",
"product": "mirai",
"device": "mirai",
"board": "mirai",
"brand": "mamoe",
"model": "mirai",
"bootloader": "unknown",
"fingerprint": "mamoe/mirai/mirai:10/MIRAI.200122.001/5055987:user/release-keys",
"bootId": "59745C91-0242-65B0-00D4-8E3290FCFC49",
"procVersion": "Linux version 3.0.31-SG5coicS (android-build@xxx.xxx.xxx.xxx.com)",
"baseBand": "",
"version": {
"incremental": "5891938",
"release": "10",
"codename": "REL"
},
"simInfo": "T-Mobile",
"osType": "android",
"macAddress": "02:00:00:00:00:00",
"wifiBSSID": "02:00:00:00:00:00",
"wifiSSID": "<unknown ssid>",
"imsiMd5": "bc67549307e94f006b05ce79d1913800",
"imei": "866001451756366",
"apn": "wifi",
"androidId": "f5dc3e012955d466"
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,300 @@
08:27:46.151 [main] INFO o.s.b.a.l.ConditionEvaluationReportLoggingListener -
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
08:27:46.227 [main] ERROR o.s.boot.SpringApplication - Application run failed
java.lang.IllegalStateException: Failed to execute ApplicationRunner
at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:762)
at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:749)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:314)
at org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:136)
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:141)
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:90)
at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:124)
at org.springframework.test.context.web.ServletTestExecutionListener.setUpRequestContextIfNecessary(ServletTestExecutionListener.java:190)
at org.springframework.test.context.web.ServletTestExecutionListener.prepareTestInstance(ServletTestExecutionListener.java:132)
at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:248)
at org.springframework.test.context.junit.jupiter.SpringExtension.postProcessTestInstance(SpringExtension.java:138)
at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$invokeTestInstancePostProcessors$8(ClassBasedTestDescriptor.java:363)
at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.executeAndMaskThrowable(ClassBasedTestDescriptor.java:368)
at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$invokeTestInstancePostProcessors$9(ClassBasedTestDescriptor.java:363)
at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:179)
at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1708)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
at java.base/java.util.stream.StreamSpliterators$WrappingSpliterator.forEachRemaining(StreamSpliterators.java:310)
at java.base/java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:735)
at java.base/java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:734)
at java.base/java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:762)
at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.invokeTestInstancePostProcessors(ClassBasedTestDescriptor.java:362)
at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$instantiateAndPostProcessTestInstance$6(ClassBasedTestDescriptor.java:283)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.instantiateAndPostProcessTestInstance(ClassBasedTestDescriptor.java:282)
at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$testInstancesProvider$4(ClassBasedTestDescriptor.java:272)
at java.base/java.util.Optional.orElseGet(Optional.java:364)
at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$testInstancesProvider$5(ClassBasedTestDescriptor.java:271)
at org.junit.jupiter.engine.execution.TestInstancesProvider.getTestInstances(TestInstancesProvider.java:31)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$prepare$0(TestMethodTestDescriptor.java:102)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.prepare(TestMethodTestDescriptor.java:101)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.prepare(TestMethodTestDescriptor.java:66)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$prepare$2(NodeTestTask.java:123)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.prepare(NodeTestTask.java:123)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:90)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:35)
at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:54)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:107)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:88)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:54)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:67)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:52)
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:114)
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:86)
at org.junit.platform.launcher.core.DefaultLauncherSession$DelegatingLauncher.execute(DefaultLauncherSession.java:86)
at org.apache.maven.surefire.junitplatform.LazyLauncher.execute(LazyLauncher.java:56)
at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.execute(JUnitPlatformProvider.java:184)
at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.invokeAllTests(JUnitPlatformProvider.java:148)
at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.invoke(JUnitPlatformProvider.java:122)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:385)
at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:162)
at org.apache.maven.surefire.booter.ForkedBooter.run(ForkedBooter.java:507)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:495)
Caused by: net.mamoe.mirai.network.BotAuthorizationException: BotAuthorization(BotAuthorization.byQRCode()) threw an exception during authorization process. See cause below.
at net.mamoe.mirai.internal.network.components.SsoProcessorImpl.login(SsoProcessor.kt:263)
at net.mamoe.mirai.internal.network.handler.CommonNetworkHandler$StateConnecting$startState$2.invokeSuspend(CommonNetworkHandler.kt:247)
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:750)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664)
Suppressed: net.mamoe.mirai.internal.network.handler.NetworkHandlerSupport$StateSwitchingException: State is switched from StateConnecting to StateClosed
Caused by: net.mamoe.mirai.internal.network.handler.NetworkHandlerSupport$StateSwitchingException: State is switched from StateConnecting to StateClosed
at net.mamoe.mirai.internal.network.handler.NetworkHandlerSupport.setStateImpl$mirai_core(NetworkHandlerSupport.kt:352)
at net.mamoe.mirai.internal.network.impl.netty.NettyNetworkHandler.handlePipelineException(NettyNetworkHandler.kt:152)
at net.mamoe.mirai.internal.network.impl.netty.NettyNetworkHandler$setupChannelPipeline$1.exceptionCaught(NettyNetworkHandler.kt:72)
at io.netty.channel.AbstractChannelHandlerContext.invokeExceptionCaught(AbstractChannelHandlerContext.java:346)
at io.netty.channel.AbstractChannelHandlerContext.invokeExceptionCaught(AbstractChannelHandlerContext.java:325)
at io.netty.channel.AbstractChannelHandlerContext.fireExceptionCaught(AbstractChannelHandlerContext.java:317)
at io.netty.channel.DefaultChannelPipeline$HeadContext.exceptionCaught(DefaultChannelPipeline.java:1377)
at io.netty.channel.AbstractChannelHandlerContext.invokeExceptionCaught(AbstractChannelHandlerContext.java:346)
at io.netty.channel.AbstractChannelHandlerContext.invokeExceptionCaught(AbstractChannelHandlerContext.java:325)
at io.netty.channel.DefaultChannelPipeline.fireExceptionCaught(DefaultChannelPipeline.java:907)
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.handleReadException(AbstractNioByteChannel.java:125)
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:177)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:788)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:724)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:650)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:562)
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.base/java.lang.Thread.run(Thread.java:1583)
Suppressed: kotlinx.coroutines.TimeoutCancellationException: Timed out waiting for 5000 ms
at (Coroutine boundary.()
at net.mamoe.mirai.internal.network.handler.NetworkHandlerSupport$sendAndExpect$3$1$1.invokeSuspend(NetworkHandlerSupport.kt:127)
at net.mamoe.mirai.internal.network.handler.NetworkHandlerSupport.sendAndExpect(NetworkHandlerSupport.kt:126)
at net.mamoe.mirai.internal.network.components.QRCodeLoginProcessorImpl.queryQRCodeStatus(QRCodeLoginProcessor.kt:99)
at net.mamoe.mirai.internal.network.components.QRCodeLoginProcessorImpl.process0(QRCodeLoginProcessor.kt:127)
at net.mamoe.mirai.internal.network.components.QRCodeLoginProcessorImpl.process(QRCodeLoginProcessor.kt:115)
at net.mamoe.mirai.internal.network.components.SsoProcessorImpl.login(SsoProcessor.kt:279)
at net.mamoe.mirai.internal.network.handler.CommonNetworkHandler$StateConnecting$startState$2.invokeSuspend(CommonNetworkHandler.kt:247)
Caused by: kotlinx.coroutines.TimeoutCancellationException: Timed out waiting for 5000 ms
at kotlinx.coroutines.TimeoutKt.TimeoutCancellationException(Timeout.kt:184)
at kotlinx.coroutines.TimeoutCoroutine.run(Timeout.kt:154)
at kotlinx.coroutines.EventLoopImplBase$DelayedRunnableTask.run(EventLoop.common.kt:508)
at kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.common.kt:284)
at kotlinx.coroutines.DefaultExecutor.run(DefaultExecutor.kt:108)
at java.base/java.lang.Thread.run(Thread.java:1583)
Caused by: net.mamoe.mirai.internal.network.impl.netty.NettyChannelException: An unexpected exception was received from netty pipeline. (context=NetworkHandlerContextImpl(bot=20243037, storage=CombinedComponentStorage {
* main:
ConcurrentComponentStorage(size=3)
*** fallback:
ConcurrentComponentStorage(size=28)
}
), address=msfwifi.3g.qq.com/<unresolved>:8080)
at net.mamoe.mirai.internal.network.impl.netty.NettyNetworkHandler$handlePipelineException$1.invoke(NettyNetworkHandler.kt:46)
at net.mamoe.mirai.internal.network.impl.netty.NettyNetworkHandler$handlePipelineException$1.invoke(NettyNetworkHandler.kt:46)
at net.mamoe.mirai.internal.network.handler.NetworkHandlerSupport.setStateImpl$mirai_core(NetworkHandlerSupport.kt:329)
... 19 common frames omitted
Caused by: java.net.SocketException: Connection reset
at java.base/sun.nio.ch.SocketChannelImpl.throwConnectionReset(SocketChannelImpl.java:401)
at java.base/sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:434)
at io.netty.buffer.PooledByteBuf.setBytes(PooledByteBuf.java:259)
at io.netty.buffer.AbstractByteBuf.writeBytes(AbstractByteBuf.java:1132)
at io.netty.channel.socket.nio.NioSocketChannel.doReadBytes(NioSocketChannel.java:357)
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:151)
... 8 common frames omitted
08:27:46.237 [main] INFO c.alibaba.druid.pool.DruidDataSource - {dataSource-1} closing ...
08:27:46.240 [main] INFO c.alibaba.druid.pool.DruidDataSource - {dataSource-1} closed
08:27:46.241 [main] ERROR o.s.test.context.TestContextManager - Caught exception while allowing TestExecutionListener [org.springframework.test.context.web.ServletTestExecutionListener@51cd7ffc] to prepare test instance [com.linxyun.homework.HomeworkApplicationTests@10508ba6]
java.lang.IllegalStateException: Failed to load ApplicationContext
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:98)
at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:124)
at org.springframework.test.context.web.ServletTestExecutionListener.setUpRequestContextIfNecessary(ServletTestExecutionListener.java:190)
at org.springframework.test.context.web.ServletTestExecutionListener.prepareTestInstance(ServletTestExecutionListener.java:132)
at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:248)
at org.springframework.test.context.junit.jupiter.SpringExtension.postProcessTestInstance(SpringExtension.java:138)
at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$invokeTestInstancePostProcessors$8(ClassBasedTestDescriptor.java:363)
at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.executeAndMaskThrowable(ClassBasedTestDescriptor.java:368)
at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$invokeTestInstancePostProcessors$9(ClassBasedTestDescriptor.java:363)
at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:179)
at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1708)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
at java.base/java.util.stream.StreamSpliterators$WrappingSpliterator.forEachRemaining(StreamSpliterators.java:310)
at java.base/java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:735)
at java.base/java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:734)
at java.base/java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:762)
at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.invokeTestInstancePostProcessors(ClassBasedTestDescriptor.java:362)
at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$instantiateAndPostProcessTestInstance$6(ClassBasedTestDescriptor.java:283)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.instantiateAndPostProcessTestInstance(ClassBasedTestDescriptor.java:282)
at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$testInstancesProvider$4(ClassBasedTestDescriptor.java:272)
at java.base/java.util.Optional.orElseGet(Optional.java:364)
at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$testInstancesProvider$5(ClassBasedTestDescriptor.java:271)
at org.junit.jupiter.engine.execution.TestInstancesProvider.getTestInstances(TestInstancesProvider.java:31)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$prepare$0(TestMethodTestDescriptor.java:102)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.prepare(TestMethodTestDescriptor.java:101)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.prepare(TestMethodTestDescriptor.java:66)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$prepare$2(NodeTestTask.java:123)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.prepare(NodeTestTask.java:123)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:90)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:35)
at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:54)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:107)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:88)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:54)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:67)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:52)
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:114)
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:86)
at org.junit.platform.launcher.core.DefaultLauncherSession$DelegatingLauncher.execute(DefaultLauncherSession.java:86)
at org.apache.maven.surefire.junitplatform.LazyLauncher.execute(LazyLauncher.java:56)
at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.execute(JUnitPlatformProvider.java:184)
at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.invokeAllTests(JUnitPlatformProvider.java:148)
at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.invoke(JUnitPlatformProvider.java:122)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:385)
at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:162)
at org.apache.maven.surefire.booter.ForkedBooter.run(ForkedBooter.java:507)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:495)
Caused by: java.lang.IllegalStateException: Failed to execute ApplicationRunner
at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:762)
at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:749)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:314)
at org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:136)
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:141)
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:90)
... 72 common frames omitted
Caused by: net.mamoe.mirai.network.BotAuthorizationException: BotAuthorization(BotAuthorization.byQRCode()) threw an exception during authorization process. See cause below.
at net.mamoe.mirai.internal.network.components.SsoProcessorImpl.login(SsoProcessor.kt:263)
at net.mamoe.mirai.internal.network.handler.CommonNetworkHandler$StateConnecting$startState$2.invokeSuspend(CommonNetworkHandler.kt:247)
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:750)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664)
Suppressed: net.mamoe.mirai.internal.network.handler.NetworkHandlerSupport$StateSwitchingException: State is switched from StateConnecting to StateClosed
Caused by: net.mamoe.mirai.internal.network.handler.NetworkHandlerSupport$StateSwitchingException: State is switched from StateConnecting to StateClosed
at net.mamoe.mirai.internal.network.handler.NetworkHandlerSupport.setStateImpl$mirai_core(NetworkHandlerSupport.kt:352)
at net.mamoe.mirai.internal.network.impl.netty.NettyNetworkHandler.handlePipelineException(NettyNetworkHandler.kt:152)
at net.mamoe.mirai.internal.network.impl.netty.NettyNetworkHandler$setupChannelPipeline$1.exceptionCaught(NettyNetworkHandler.kt:72)
at io.netty.channel.AbstractChannelHandlerContext.invokeExceptionCaught(AbstractChannelHandlerContext.java:346)
at io.netty.channel.AbstractChannelHandlerContext.invokeExceptionCaught(AbstractChannelHandlerContext.java:325)
at io.netty.channel.AbstractChannelHandlerContext.fireExceptionCaught(AbstractChannelHandlerContext.java:317)
at io.netty.channel.DefaultChannelPipeline$HeadContext.exceptionCaught(DefaultChannelPipeline.java:1377)
at io.netty.channel.AbstractChannelHandlerContext.invokeExceptionCaught(AbstractChannelHandlerContext.java:346)
at io.netty.channel.AbstractChannelHandlerContext.invokeExceptionCaught(AbstractChannelHandlerContext.java:325)
at io.netty.channel.DefaultChannelPipeline.fireExceptionCaught(DefaultChannelPipeline.java:907)
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.handleReadException(AbstractNioByteChannel.java:125)
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:177)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:788)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:724)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:650)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:562)
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.base/java.lang.Thread.run(Thread.java:1583)
Suppressed: kotlinx.coroutines.TimeoutCancellationException: Timed out waiting for 5000 ms
at (Coroutine boundary.()
at net.mamoe.mirai.internal.network.handler.NetworkHandlerSupport$sendAndExpect$3$1$1.invokeSuspend(NetworkHandlerSupport.kt:127)
at net.mamoe.mirai.internal.network.handler.NetworkHandlerSupport.sendAndExpect(NetworkHandlerSupport.kt:126)
at net.mamoe.mirai.internal.network.components.QRCodeLoginProcessorImpl.queryQRCodeStatus(QRCodeLoginProcessor.kt:99)
at net.mamoe.mirai.internal.network.components.QRCodeLoginProcessorImpl.process0(QRCodeLoginProcessor.kt:127)
at net.mamoe.mirai.internal.network.components.QRCodeLoginProcessorImpl.process(QRCodeLoginProcessor.kt:115)
at net.mamoe.mirai.internal.network.components.SsoProcessorImpl.login(SsoProcessor.kt:279)
at net.mamoe.mirai.internal.network.handler.CommonNetworkHandler$StateConnecting$startState$2.invokeSuspend(CommonNetworkHandler.kt:247)
Caused by: kotlinx.coroutines.TimeoutCancellationException: Timed out waiting for 5000 ms
at kotlinx.coroutines.TimeoutKt.TimeoutCancellationException(Timeout.kt:184)
at kotlinx.coroutines.TimeoutCoroutine.run(Timeout.kt:154)
at kotlinx.coroutines.EventLoopImplBase$DelayedRunnableTask.run(EventLoop.common.kt:508)
at kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.common.kt:284)
at kotlinx.coroutines.DefaultExecutor.run(DefaultExecutor.kt:108)
at java.base/java.lang.Thread.run(Thread.java:1583)
Caused by: net.mamoe.mirai.internal.network.impl.netty.NettyChannelException: An unexpected exception was received from netty pipeline. (context=NetworkHandlerContextImpl(bot=20243037, storage=CombinedComponentStorage {
* main:
ConcurrentComponentStorage(size=3)
*** fallback:
ConcurrentComponentStorage(size=28)
}
), address=msfwifi.3g.qq.com/<unresolved>:8080)
at net.mamoe.mirai.internal.network.impl.netty.NettyNetworkHandler$handlePipelineException$1.invoke(NettyNetworkHandler.kt:46)
at net.mamoe.mirai.internal.network.impl.netty.NettyNetworkHandler$handlePipelineException$1.invoke(NettyNetworkHandler.kt:46)
at net.mamoe.mirai.internal.network.handler.NetworkHandlerSupport.setStateImpl$mirai_core(NetworkHandlerSupport.kt:329)
... 19 common frames omitted
Caused by: java.net.SocketException: Connection reset
at java.base/sun.nio.ch.SocketChannelImpl.throwConnectionReset(SocketChannelImpl.java:401)
at java.base/sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:434)
at io.netty.buffer.PooledByteBuf.setBytes(PooledByteBuf.java:259)
at io.netty.buffer.AbstractByteBuf.writeBytes(AbstractByteBuf.java:1132)
at io.netty.channel.socket.nio.NioSocketChannel.doReadBytes(NioSocketChannel.java:357)
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:151)
... 8 common frames omitted

67
logs/application.log Normal file
View File

@ -0,0 +1,67 @@
16:18:49.808 [main] INFO c.l.homework.HomeworkApplication - Starting HomeworkApplication using Java 17.0.6 on wenxin with PID 1460 (D:\job\homework\target\classes started by wx_20 in D:\job\homework)
16:18:49.815 [main] INFO c.l.homework.HomeworkApplication - No active profile set, falling back to 1 default profile: "default"
16:18:50.744 [main] INFO o.s.b.w.e.tomcat.TomcatWebServer - Tomcat initialized with port(s): 8080 (http)
16:18:50.751 [main] INFO o.a.coyote.http11.Http11NioProtocol - Initializing ProtocolHandler ["http-nio-8080"]
16:18:50.751 [main] INFO o.a.catalina.core.StandardService - Starting service [Tomcat]
16:18:50.751 [main] INFO o.a.catalina.core.StandardEngine - Starting Servlet engine: [Apache Tomcat/9.0.69]
16:18:50.871 [main] INFO o.a.c.c.C.[.[.[/customService] - Initializing Spring embedded WebApplicationContext
16:18:50.871 [main] INFO o.s.b.w.s.c.ServletWebServerApplicationContext - Root WebApplicationContext: initialization completed in 1018 ms
16:18:50.948 [main] INFO c.a.d.s.b.a.DruidDataSourceAutoConfigure - Init DruidDataSource
16:18:51.042 [main] INFO c.alibaba.druid.pool.DruidDataSource - {dataSource-1} inited
16:18:51.978 [main] INFO o.s.b.a.w.s.WelcomePageHandlerMapping - Adding welcome page: class path resource [static/index.html]
16:18:52.155 [main] INFO o.a.coyote.http11.Http11NioProtocol - Starting ProtocolHandler ["http-nio-8080"]
16:18:52.174 [main] INFO o.s.b.w.e.tomcat.TomcatWebServer - Tomcat started on port(s): 8080 (http) with context path '/customService'
16:18:52.181 [main] INFO c.l.homework.HomeworkApplication - Started HomeworkApplication in 2.684 seconds (JVM running for 3.617)
16:18:52.183 [main] INFO com.linxyun.homework.bot.MyBot - 开始加载需要处理的群和老师
16:18:52.183 [main] INFO com.linxyun.homework.bot.MyBot - 监听指定群群
16:18:52.557 [main] INFO com.linxyun.homework.bot.MyBot - 加载完成
16:19:06.809 [SpringApplicationShutdownHook] INFO c.alibaba.druid.pool.DruidDataSource - {dataSource-1} closing ...
16:19:06.815 [SpringApplicationShutdownHook] INFO c.alibaba.druid.pool.DruidDataSource - {dataSource-1} closed
16:23:01.777 [main] INFO c.l.homework.HomeworkApplication - Starting HomeworkApplication using Java 17.0.6 on wenxin with PID 28404 (D:\job\homework\target\classes started by wx_20 in D:\job\homework)
16:23:01.780 [main] INFO c.l.homework.HomeworkApplication - No active profile set, falling back to 1 default profile: "default"
16:23:02.692 [main] INFO o.s.b.w.e.tomcat.TomcatWebServer - Tomcat initialized with port(s): 8080 (http)
16:23:02.701 [main] INFO o.a.coyote.http11.Http11NioProtocol - Initializing ProtocolHandler ["http-nio-8080"]
16:23:02.701 [main] INFO o.a.catalina.core.StandardService - Starting service [Tomcat]
16:23:02.701 [main] INFO o.a.catalina.core.StandardEngine - Starting Servlet engine: [Apache Tomcat/9.0.69]
16:23:02.821 [main] INFO o.a.c.c.C.[.[.[/customService] - Initializing Spring embedded WebApplicationContext
16:23:02.821 [main] INFO o.s.b.w.s.c.ServletWebServerApplicationContext - Root WebApplicationContext: initialization completed in 996 ms
16:23:02.891 [main] INFO c.a.d.s.b.a.DruidDataSourceAutoConfigure - Init DruidDataSource
16:23:02.975 [main] INFO c.alibaba.druid.pool.DruidDataSource - {dataSource-1} inited
16:23:03.889 [main] INFO o.s.b.a.w.s.WelcomePageHandlerMapping - Adding welcome page: class path resource [static/index.html]
16:23:04.118 [main] INFO o.a.coyote.http11.Http11NioProtocol - Starting ProtocolHandler ["http-nio-8080"]
16:23:04.139 [main] INFO o.s.b.w.e.tomcat.TomcatWebServer - Tomcat started on port(s): 8080 (http) with context path '/customService'
16:23:04.147 [main] INFO c.l.homework.HomeworkApplication - Started HomeworkApplication in 2.629 seconds (JVM running for 3.387)
16:23:04.149 [main] INFO com.linxyun.homework.bot.MyBot - 开始加载需要处理的群和老师
16:23:04.149 [main] INFO com.linxyun.homework.bot.MyBot - 监听指定群群
16:23:04.498 [main] INFO com.linxyun.homework.bot.MyBot - 加载完成
16:23:26.302 [main] INFO o.s.b.a.l.ConditionEvaluationReportLoggingListener -
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
16:23:26.316 [main] ERROR o.s.boot.SpringApplication - Application run failed
java.lang.IllegalStateException: Failed to execute ApplicationRunner
at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:762)
at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:749)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:314)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1303)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1292)
at com.linxyun.homework.HomeworkApplication.main(HomeworkApplication.java:11)
Caused by: net.mamoe.mirai.network.BotAuthorizationException: BotAuthorization(BotAuthorization.byQRCode()) threw an exception during authorization process. See cause below.
at net.mamoe.mirai.internal.network.components.SsoProcessorImpl.login(SsoProcessor.kt:263)
at net.mamoe.mirai.internal.network.handler.CommonNetworkHandler$StateConnecting$startState$2.invokeSuspend(CommonNetworkHandler.kt:247)
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:750)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664)
Suppressed: net.mamoe.mirai.network.WrongPasswordException: Error(bot=Bot(939948263), code=45, title=禁止登录, message=你当前使用的QQ版本过低请前往QQ官网im.qq.com下载最新版QQ后重试。, errorInfo=)
Caused by: net.mamoe.mirai.network.WrongPasswordException: Error(bot=Bot(939948263), code=45, title=禁止登录, message=你当前使用的QQ版本过低请前往QQ官网im.qq.com下载最新版QQ后重试。, errorInfo=)
at net.mamoe.mirai.internal.network.components.SsoProcessorImpl$SlowLoginImpl.doLogin(SsoProcessor.kt:490)
at net.mamoe.mirai.internal.network.components.SsoProcessorImpl$SlowLoginImpl$doLogin$1.invokeSuspend(SsoProcessor.kt)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.internal.ScopeCoroutine.afterResume(Scopes.kt:33)
at kotlinx.coroutines.AbstractCoroutine.resumeWith(AbstractCoroutine.kt:102)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46)
... 5 common frames omitted
16:23:26.358 [main] INFO c.alibaba.druid.pool.DruidDataSource - {dataSource-1} closing ...
16:23:26.364 [main] INFO c.alibaba.druid.pool.DruidDataSource - {dataSource-1} closed

32
pom.xml
View File

@ -67,6 +67,37 @@
<artifactId>lombok</artifactId>
<version>1.18.34</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.11</version>
</dependency>
<!--图片压缩-->
<!-- https://mvnrepository.com/artifact/net.coobird/thumbnailator -->
<dependency>
<groupId>net.coobird</groupId>
<artifactId>thumbnailator</artifactId>
<version>0.4.20</version>
</dependency>
<!--压缩视频-->
<dependency>
<groupId>ws.schild</groupId>
<artifactId>jave-all-deps</artifactId>
<version>3.5.0</version>
</dependency>
<dependency>
<groupId>ws.schild</groupId>
<artifactId>jave-core</artifactId>
<version>3.5.0</version>
</dependency>
<dependency>
<groupId>ws.schild</groupId>
<artifactId>jave-nativebin-win64</artifactId>
<version>3.5.0</version>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
@ -98,7 +129,6 @@
<version>${spring-boot.version}</version>
<configuration>
<mainClass>com.linxyun.homework.HomeworkApplication</mainClass>
<skip>true</skip>
</configuration>
<executions>
<execution>

View File

@ -1,9 +1,13 @@
package com.linxyun.homework.bot;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.linxyun.homework.bot.handler.MyEventHandler;
import com.linxyun.homework.domain.dto.ClassGroupTeacher;
import com.linxyun.homework.domain.po.Class;
import com.linxyun.homework.mapper.ClassMapper;
import com.linxyun.homework.mapper.ClassQqGroupTeacherMapper;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import net.mamoe.mirai.BotFactory;
import net.mamoe.mirai.auth.BotAuthorization;
import net.mamoe.mirai.event.EventChannel;
@ -20,15 +24,19 @@ import java.util.List;
import java.util.Objects;
import java.util.concurrent.CopyOnWriteArrayList;
@Slf4j
@Component
@RequiredArgsConstructor
public class MyBot implements ApplicationRunner {
@Value("${mirai.bot.listening-type}")
private Integer listeningType;
/* 监听对象 */
public static CopyOnWriteArrayList<ClassGroupTeacher> listeningTarget;
public static CopyOnWriteArrayList<Object> listeningTarget;
private final ClassQqGroupTeacherMapper classQqGroupTeacherMapper;
private final ClassMapper classMapper;
private final MyEventHandler myEventHandler;
/* 登录QQ */
@ -38,15 +46,26 @@ public class MyBot implements ApplicationRunner {
@Override
public void run(ApplicationArguments args) {
// 先加载需要处理的群和老师
log.info("开始加载需要处理的群和老师");
getListeningTarget();
log.info("加载完成");
// 启动BOT
runBot();
}
public void getListeningTarget() {
List<ClassGroupTeacher> classGroupTeachers = classQqGroupTeacherMapper.selectClassAndGroupTeacher();
System.out.println(classGroupTeachers);
listeningTarget = new CopyOnWriteArrayList<>(classGroupTeachers);
if (1 == listeningType) {
log.info("监听指定群群");
LambdaQueryWrapper<Class> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.isNotNull(Class::getQqGroupId);
List<Class> ClassList = classMapper.selectList(queryWrapper);
listeningTarget = new CopyOnWriteArrayList<>(ClassList);
} else if (2 == listeningType) {
log.info("监听指定群指定老师");
List<ClassGroupTeacher> classGroupTeachers = classQqGroupTeacherMapper.selectClassAndGroupTeacher();
System.out.println(classGroupTeachers);
listeningTarget = new CopyOnWriteArrayList<>(classGroupTeachers);
}
}
public void runBot() {
@ -61,10 +80,22 @@ public class MyBot implements ApplicationRunner {
.filterIsInstance(GroupMessageEvent.class)
.filter(ev -> {
long groupId = ev.getGroup().getId();
long senderId = ev.getSender().getId();
for (ClassGroupTeacher item : listeningTarget) {
if (groupId == Long.parseLong(item.getQqGroupId()) && senderId == Long.parseLong(item.getTeacherGroupId())) {
return true;
if (1 == listeningType) {
for (Object item : listeningTarget) {
Class clazz = (Class) item;
// 指定群
if (groupId == Long.parseLong(clazz.getQqGroupId())) {
return true;
}
}
} else if (2 == listeningType) {
long senderId = ev.getSender().getId();
for (Object item : listeningTarget) {
ClassGroupTeacher teacher = (ClassGroupTeacher) item;
// 指定群和老师同时满足
if (groupId == Long.parseLong(teacher.getQqGroupId()) && senderId == Long.parseLong(teacher.getTeacherGroupId())) {
return true;
}
}
}
return false;
@ -73,10 +104,10 @@ public class MyBot implements ApplicationRunner {
new Thread(bot::join).start();
}
public static ClassGroupTeacher getClassGroupTeacherByTeacherGroupId(String teacherGroupId) {
return listeningTarget.stream()
.filter(item -> Objects.equals(item.getTeacherGroupId(), teacherGroupId))
.findFirst()
.orElse(null);
}
// public static ClassGroupTeacher getClassGroupTeacherByTeacherGroupId(String teacherGroupId) {
// return listeningTarget.stream()
// .filter(item -> Objects.equals(item.getTeacherGroupId(), teacherGroupId))
// .findFirst()
// .orElse(null);
// }
}

View File

@ -36,7 +36,7 @@ public class MyEventHandler extends SimpleListenerHost {
@NotNull
@EventHandler
public ListeningStatus onMessage(@NotNull GroupMessageEvent event) { // 可以抛出任何异常, 将在 handleException 处理
System.out.println("收到消息: " + event.getMessage());
log.debug("收到消息: " + event.getMessage());
MessageChain messages = event.getMessage();
// 发送人QQ
String teacherId = String.valueOf(event.getSender().getId());
@ -52,6 +52,7 @@ public class MyEventHandler extends SimpleListenerHost {
}
if (message instanceof Image image) {
log.info("图片: " + image.getImageId());
// 如果是表情那就下一个
if (image.isEmoji()) continue;
if (contentBuilder == null) contentBuilder = new StringBuilder();
String url = Image.queryUrl(image);
@ -75,12 +76,12 @@ public class MyEventHandler extends SimpleListenerHost {
}
}
// 插入数据库
ClassGroupTeacher classGroupTeacher = MyBot.getClassGroupTeacherByTeacherGroupId(teacherId);
// ClassGroupTeacher classGroupTeacher = MyBot.getClassGroupTeacherByTeacherGroupId(teacherId);
TeacherQqMsgs teacherQqMsgs = new TeacherQqMsgs();
teacherQqMsgs.setCreateTime(TimeUtils.getCurrentTime());
teacherQqMsgs.setTeacherQqId(teacherId);
teacherQqMsgs.setClassId(classGroupTeacher.getClassId());
teacherQqMsgs.setCourseType(classGroupTeacher.getCourseType());
// teacherQqMsgs.setClassId(classGroupTeacher.getClassId());
// teacherQqMsgs.setCourseType(classGroupTeacher.getCourseType());
Optional.ofNullable(strBuilder).ifPresent(item -> {
String remarks = item.substring(0, item.length() - 3);
log.info("提交的文本: " + remarks);
@ -88,7 +89,7 @@ public class MyEventHandler extends SimpleListenerHost {
});
Optional.ofNullable(contentBuilder).ifPresent(item -> {
String msgContent = item.deleteCharAt(item.length() - 1).toString();
log.info("提交的图片: " + msgContent);
log.info("提交的图片或文件: " + msgContent);
teacherQqMsgs.setMsgContent(msgContent);
});
int row = teacherQqMsgsMapper.insert(teacherQqMsgs);

View File

@ -27,7 +27,10 @@ public class Result<E> {
public static <T> Result<T> error(ErrorCode codeEnum) {
return new Result<>(null, codeEnum.getCode(), codeEnum.getMessage(), false);
}
public static <T> Result<T> error(ErrorCode codeEnum, String message) {
return new Result<>(null, codeEnum.getCode(), message, false);
}
public static <T> Result<T> error(String code, String msg) {

View File

@ -0,0 +1,26 @@
package com.linxyun.homework.common.enums;
import java.util.Arrays;
import java.util.List;
public enum FileType {
IMAGE(Arrays.asList(".jpg", ".jpeg", ".png", ".gif", ".bmp")),
VIDEO(Arrays.asList(".mp4", ".mkv", ".mov", ".avi")),
AUDIO(Arrays.asList(".mp3", ".wav", ".ogg")),
DOCUMENT(Arrays.asList(".pdf", ".doc", ".docx", ".xls", ".xlsx")),
OTHER(Arrays.asList());
private final List<String> extensions;
FileType(List<String> extensions) {
this.extensions = extensions;
}
public static FileType fromExtension(String fileName) {
String extension = fileName.substring(fileName.lastIndexOf(".")).toLowerCase();
return Arrays.stream(values())
.filter(type -> type.extensions.contains(extension))
.findFirst()
.orElse(OTHER);
}
}

View File

@ -60,7 +60,7 @@ public class HomeworkAnswerServiceImpl extends ServiceImpl<HomeworkAnswerMapper,
homeworkAnswer.setContentFileId(answerMsg.getFile()); // 文件资源
} else {
homeworkAnswer.setContentType(0);
homeworkAnswer.setContent(answerMsg.getContent()); // 文字
homeworkAnswer.setContent(answerMsg.getContent().replace("|||", "")); // 文字
}
int row = homeworkAnswerMapper.insert(homeworkAnswer);
if (row < 1) {

View File

@ -1,15 +1,19 @@
package com.linxyun.homework.utils;
import com.alibaba.fastjson2.JSONObject;
import com.linxyun.homework.HomeworkApplication;
import com.linxyun.homework.common.enums.FileType;
import lombok.extern.slf4j.Slf4j;
import net.coobird.thumbnailator.Thumbnails;
import okhttp3.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;
import ws.schild.jave.Encoder;
import ws.schild.jave.EncoderException;
import ws.schild.jave.MultimediaObject;
import ws.schild.jave.encode.AudioAttributes;
import ws.schild.jave.encode.EncodingAttributes;
import ws.schild.jave.encode.VideoAttributes;
import ws.schild.jave.info.VideoSize;
import java.io.*;
@ -21,6 +25,9 @@ public class FileUtils {
@Value("${upload.base-url}")
private String baseUrl;
@Value(value = "${upload.img-quality}")
private Float imgQuality = 1.0f;
/**
* 下载文件到指定目录
* @param fileUrl 文件 URL
@ -68,7 +75,9 @@ public class FileUtils {
* @param fileName 文件名可以用来关联下载到本地的文件
* @return 文件内容的字节数组
*/
public String uploadFileByUrl(String fileUrl, String fileName) {
FileType fileType = FileType.fromExtension(fileName);
// 创建 GET 请求
Request request = new Request.Builder()
.url(fileUrl)
@ -83,18 +92,82 @@ public class FileUtils {
// 获取文件内容作为字节数组
try (ResponseBody responseBody = response.body();
InputStream inputStream = responseBody.byteStream();
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream()) {
byte[] buffer = new byte[4096];
int bytesRead;
InputStream inputStream = responseBody.byteStream()) {
// 读取数据到缓冲区
while ((bytesRead = inputStream.read(buffer)) != -1) {
byteArrayOutputStream.write(buffer, 0, bytesRead);
// 如果是图片进行压缩
if (fileType == FileType.IMAGE) {
try (ByteArrayOutputStream compressedOutputStream = new ByteArrayOutputStream()) {
log.info("压缩图片:" + fileUrl + " 图片质量:" + imgQuality);
// 压缩图片
Thumbnails.of(inputStream)
.outputQuality(imgQuality) // 设置输出质量 (0~1)
.scale(1.0) // 保持原尺寸如需缩放可调整 scale 值或使用 size 方法
.toOutputStream(compressedOutputStream);
// 日志输出原始大小和压缩后大小
log.info("图片原始大小: " + responseBody.contentLength() + " 字节");
log.info("图片压缩后大小: " + compressedOutputStream.size() + " 字节");
// 上传压缩后的图片
return uploadFile(compressedOutputStream.toByteArray(), fileName);
}
} else if (fileType == FileType.VIDEO) {
// 压缩视频
log.info("压缩视频:" + fileUrl);
// 创建视频压缩设置
File tempInputFile = File.createTempFile("video", ".tmp");
try (FileOutputStream fos = new FileOutputStream(tempInputFile)) {
inputStream.transferTo(fos); // 将输入流写入临时文件
}
File compressedVideoFile = new File("compressed_" + fileName);
// 设置视频压缩参数
AudioAttributes audio = new AudioAttributes();
audio.setCodec("libmp3lame");
audio.setBitRate(128000); // 设置音频比特率
audio.setChannels(2);
audio.setSamplingRate(44100);
VideoAttributes video = new VideoAttributes();
video.setCodec("mpeg4"); // 设置视频编解码器
video.setBitRate(1000000); // 设置视频比特率
video.setFrameRate(24); // 设置帧率
video.setSize(new VideoSize(1280, 720)); // 设置分辨率
EncodingAttributes attrs = new EncodingAttributes();
attrs.setAudioAttributes(audio);
attrs.setVideoAttributes(video);
attrs.setOutputFormat("mp4");
Encoder encoder = new Encoder();
encoder.encode(new MultimediaObject(tempInputFile), compressedVideoFile, attrs);
// 压缩完成后将文件转为字节数组上传
try (ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream()) {
try (FileInputStream fis = new FileInputStream(compressedVideoFile)) {
byte[] buffer = new byte[4096];
int bytesRead;
while ((bytesRead = fis.read(buffer)) != -1) {
byteArrayOutputStream.write(buffer, 0, bytesRead);
}
}
// 删除临时文件
tempInputFile.delete();
compressedVideoFile.delete();
// 上传压缩后的文件
log.info("压缩前大小: " + tempInputFile.length() + " 字节");
log.info("压缩后大小: " + compressedVideoFile.length() + " 字节");
return uploadFile(byteArrayOutputStream.toByteArray(), fileName);
}
} else {
// 非图片直接上传
log.info("上传其它文件:" + fileUrl);
return uploadFile(inputStream.readAllBytes(), fileName);
}
return uploadFile(byteArrayOutputStream.toByteArray(), fileName);
}
} catch (IOException e) {
} catch (IOException | EncoderException e) {
log.error("FileUploadTool uploadFileByUrl exception: ", e);
return null;
}
@ -102,6 +175,7 @@ public class FileUtils {
/**
* 使用 OkHttp 上传文件
*
@ -150,4 +224,5 @@ public class FileUtils {
return null;
}
}
}

View File

@ -0,0 +1,3 @@
Manifest-Version: 1.0
Main-Class: com.linxyun.homework.HomeworkApplication

View File

@ -1,12 +1,16 @@
# 应用服务 WEB 访问端口
server:
port: 8080
servlet:
context-path: /customService
spring: #springboot的配置
datasource: #定义数据源
#127.0.0.1为本机测试的ip3306是mysql的端口号。serverTimezone是定义时区照抄就好mysql高版本需要定义这些东西
#useSSL也是某些高版本mysql需要问有没有用SSL连接
# url: jdbc:mysql://127.0.0.1:3306/homeworkor?serverTimezone=GMT%2B8&useSSL=FALSE
url: jdbc:mysql://117.89.254.176:8846/homeworkor?serverTimezone=GMT%2B8&useSSL=FALSE
username: root #数据库用户名root为管理员
password: Home.lxy.com #该数据库用户的密码
# 使用druid数据源
@ -34,6 +38,20 @@ mybatis-plus:
# 这个配置会将执行的sql打印出来在开发或测试的时候可以用
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
logging:
file:
# 输出的log文件名
name: slf4j-test
# 输出的文件的路径
path: ./logs
level:
# 输出级别
root: info
# 特定的mapper下的输出级别
com.example.demo.mapper: debug
# xml配置文件
config: classpath:logback.xml
springdoc:
swagger-ui:
path: /swagger-ui.html
@ -53,7 +71,11 @@ knife4j:
mirai:
bot:
qq: 20243037
# qq: 20243037
qq: 939948263
# 监听类型 1为监听指定群的聊天消息 2为监听指定群指定QQ的聊天消息
listening-type: 1
upload:
base-url: http://www.linxyun.com
# 图片压缩质量 0~1
img-quality: 0.8

View File

@ -0,0 +1,25 @@
<configuration>
<property name="LOG_PATH" value="logs"/>
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${LOG_PATH}/application.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${LOG_PATH}/application.%d{yyyy-MM-dd}.log</fileNamePattern>
<maxHistory>30</maxHistory>
</rollingPolicy>
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<root level="info">
<appender-ref ref="CONSOLE"/>
<appender-ref ref="FILE"/>
</root>
</configuration>