go-cqhttp / for-java Goto Github PK
View Code? Open in Web Editor NEW基于 go-cqhttp 和 java 的 qq 机器人
License: MIT License
基于 go-cqhttp 和 java 的 qq 机器人
License: MIT License
接收群消息时,JSON序列化成GroupMessageEvent类会报错com.alibaba.fastjson.JSONException: syntax error, expect [, actual string, pos 0, fieldName null
无论加不加这个注解,都会调用方法
_ _
___| |__ _ _ __ _____(_) _ _ ___ _ _ ___ ___ _ __ ___
|_ / '_ \| | | | \ \ /\ / / _ \ | | | | |/ _ \| | | | / __/ _ \| '_ ` _ \
/ /| | | | |_| | \ V V / __/ | | |_| | (_) | |_| | _ | (_| (_) | | | | | |
/___|_| |_|\__,_| \_/\_/ \___|_| \__, |\___/ \__,_| (_) \___\___/|_| |_| |_|
|___/
目前个人使用MessageChain.image()
过程中,只能发送.image缓存文件.
我尝试过使用new ImageMessage()
后setUrl("本地文件地址")
进行发送,go-cqhhtp服务端显示 消息图片上传失败: image type error: .
是否是我使用了错误的发图方式?我应该如何解决这个问题?
另外我在go-cqhttp里配置了report-self-message: true ,也就是上报机器人自身的消息,但是在使用过程中发现并没有捕获到机器人的发言,我需要加上什么另外的配置吗?
@GroupMessageHandler
@FriendMessageHandler
注入Friend参数空指针,排查到没有Friend相关的Inject类,添加后解决该bug
@FriendMessageHandler(senderIds = xxx)
public void Test(Friend friend, String message)
friend is null
@requiredargsconstructor(onConstructor = @__(@Autowired))
报错:
java: 找不到符号
符号: 类 __
我的cqhttp部署在反向代理后,建议支持自定义URL,提供更高的自由度,类似wss://example.com:443/ws
这样的格式
新增好友后,Friend无法注入
thanks!
是否提供了一个给Bot对象主动发送消息的方法?看readme没懂
新入群的人发送消息,member参数空指针,查看到Bot属性groupMembers里群成员该用户不存在,考虑新用户发第一条消息时把该用户保存到map
如题
这个access_token默认不是为空吗?也改过access_token,就是连不上。
引入对应 jar 包 但无法启动
<dependency>
<groupId>com.zhuangxv</groupId>
<artifactId>bot-core</artifactId>
<version>1.0.0</version>
<scope>system</scope>
<systemPath>/Users/Desktop/bot-core-1.0.0.jar</systemPath>
</dependency>
Eeupt 框架引入 bot-core jar包 在启动类 添加 @EnableBot 注解
package com.example.demo;
import com.example.demo.proxy.TestLoginProxy;
import com.zhuangxv.bot.EnableBot;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import xyz.erupt.core.annotation.EruptScan;
import xyz.erupt.upms.fun.EruptLogin;
import java.awt.*;
import java.net.URI;
@EnableBot
@SpringBootApplication
@EruptLogin(TestLoginProxy.class)
@EntityScan
@EruptScan
public class ExampleApplication extends SpringBootServletInitializer {
//详细使用方法详见项目内 README.md 文件说明
public static void main(String[] args) {
SpringApplication.run(ExampleApplication.class, args);
try {
System.setProperty("java.awt.headless", "false");
Desktop.getDesktop().browse(new URI("http://localhost:7788"));
} catch (Exception e) {
System.setProperty("java.awt.headless", "true");
}
System.err.println("详细使用方法,请阅读:README.md");
}
//打WAR包的配置
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(ExampleApplication.class);
}
}
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2022-03-26 00:47:39.899 ERROR 17631 --- [ main] o.s.boot.SpringApplication : Application run failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.zhuangxv.bot.core.BotDispatcher': Lookup method resolution failed; nested exception is java.lang.IllegalStateException: Failed to introspect Class [com.zhuangxv.bot.core.BotDispatcher] from ClassLoader [sun.misc.Launcher$AppClassLoader@18b4aac2]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.determineCandidateConstructors(AutowiredAnnotationBeanPostProcessor.java:289) ~[spring-beans-5.3.6.jar:5.3.6]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineConstructorsFromBeanPostProcessors(AbstractAutowireCapableBeanFactory.java:1284) ~[spring-beans-5.3.6.jar:5.3.6]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1201) ~[spring-beans-5.3.6.jar:5.3.6]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:564) ~[spring-beans-5.3.6.jar:5.3.6]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:524) ~[spring-beans-5.3.6.jar:5.3.6]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.6.jar:5.3.6]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.6.jar:5.3.6]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.6.jar:5.3.6]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.6.jar:5.3.6]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:944) ~[spring-beans-5.3.6.jar:5.3.6]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918) ~[spring-context-5.3.6.jar:5.3.6]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583) ~[spring-context-5.3.6.jar:5.3.6]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:144) ~[spring-boot-2.4.5.jar:2.4.5]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:782) [spring-boot-2.4.5.jar:2.4.5]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:774) [spring-boot-2.4.5.jar:2.4.5]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:439) [spring-boot-2.4.5.jar:2.4.5]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:339) [spring-boot-2.4.5.jar:2.4.5]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1340) [spring-boot-2.4.5.jar:2.4.5]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1329) [spring-boot-2.4.5.jar:2.4.5]
at com.example.demo.ExampleApplication.main(ExampleApplication.java:25) [classes/:na]
Caused by: java.lang.IllegalStateException: Failed to introspect Class [com.zhuangxv.bot.core.BotDispatcher] from ClassLoader [sun.misc.Launcher$AppClassLoader@18b4aac2]
at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:481) ~[spring-core-5.3.6.jar:5.3.6]
at org.springframework.util.ReflectionUtils.doWithLocalMethods(ReflectionUtils.java:321) ~[spring-core-5.3.6.jar:5.3.6]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.determineCandidateConstructors(AutowiredAnnotationBeanPostProcessor.java:267) ~[spring-beans-5.3.6.jar:5.3.6]
... 19 common frames omitted
Caused by: java.lang.NoClassDefFoundError: com/alibaba/fastjson/JSONObject
at java.lang.Class.getDeclaredMethods0(Native Method) ~[na:1.8.0_282]
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701) ~[na:1.8.0_282]
at java.lang.Class.getDeclaredMethods(Class.java:1975) ~[na:1.8.0_282]
at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:463) ~[spring-core-5.3.6.jar:5.3.6]
... 21 common frames omitted
Caused by: java.lang.ClassNotFoundException: com.alibaba.fastjson.JSONObject
at java.net.URLClassLoader.findClass(URLClassLoader.java:382) ~[na:1.8.0_282]
at java.lang.ClassLoader.loadClass(ClassLoader.java:419) ~[na:1.8.0_282]
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352) ~[na:1.8.0_282]
at java.lang.ClassLoader.loadClass(ClassLoader.java:352) ~[na:1.8.0_282]
... 25 common frames omitted
Process finished with exit code 1
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.