支持楼主!!!
B
bigcyy 发布的帖子
-
导入日志框架依赖后 idea中运行无问题,实际使用找不到日志框架
导入日志框架依赖后 idea中运行无问题,实际使用提示
ERROR StatusLogger Log4j2 could not find a logging implementation. Please add log4j-core to the classpath. Using SimpleLogger to log to the console...
-
RE: 如何将群里的文件发送到另外一个群
@bigcyy
研究出来了,贴这里供大家参考,我这里是mirai最新的稳定版//判断其是否是文件信息 boolean isFileMsg = message.stream().anyMatch((singleMessage) -> singleMessage instanceof FileMessage); if (isFileMsg) { //如果是文件 Optional<SingleMessage> first = message.stream().filter((singleMessage) -> singleMessage instanceof FileMessage).findFirst(); SingleMessage singleMessage; if(first.isPresent()) { singleMessage = first.get(); AbsoluteFile absoluteFile = ((FileMessage) singleMessage).toAbsoluteFile(group); //从刚刚发送文件的的群里获取该文件 String fileName = absoluteFile.getName(); String url = absoluteFile.getUrl(); //得到url OkHttpClient okHttpClient = new OkHttpClient(); //用okhttp发送请求,转成流 Request request = new Request.Builder().url(url).build(); okHttpClient.newCall(request).enqueue(new Callback() { @Override public void onFailure(@NotNull Call call, @NotNull IOException e) { e.printStackTrace(); } @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try { InputStream inputStream = response.body().byteStream(); //转成流 ExternalResource res = ExternalResource.create(inputStream).toAutoCloseable(); //用mirai的ExternalResource包装 pushGroup.getFiles().uploadNewFile("/" + fileName, res); inputStream.close(); } catch (Exception e) { e.printStackTrace(); } } }); } }
-
请问下,用java如何实现连续对话
有一个需求,用户发送登录,然后机器人回复验证码图片,用户回复验证码给机器人,机器人进行登录原来是用的两个群消息事件来实现的。看miria文档有kt代码可以实现类似功能(event处kt工具类),请问用java怎么写😭😭😭
-
GroupMessagePreSendEvent.class,与GroupMessagePostSendEvent.class的疑问,看了几遍api没看懂怎么用,求大佬们指点一下
Listener listenerTest = GlobalEventChannel.INSTANCE.subscribeAlways(GroupMessagePreSendEvent.class, (GroupMessagePreSendEvent e)->{ e.getTarget().sendMessage("test"); }); Listener listenerTest1 = GlobalEventChannel.INSTANCE.subscribeAlways(GroupMessagePostSendEvent.class, (GroupMessagePostSendEvent e)->{ e.getTarget().sendMessage("test"); });