已解决 如何获取引用的信息源?
-
例如:
我希望得到该信息中引用的信息的具体内容。@Handler public void quoteBack(CommandSenderOnMessage sender){ System.out.println(sender.getFromEvent().getMessage().contentToString()); QuoteReply reply = new QuoteReply(sender.getFromEvent().getSource()); MessageChain chain = sender.getFromEvent().getSource().getOriginalMessage(); System.out.println(reply.toString()); System.out.println(chain.get(0)); System.out.println(chain.toString()); if (sender.getFromEvent().getMessage().contentToString().contains("quote")){ sender.sendMessage("back"); } }
sender.getFromEvent().getSource().getOriginalMessage();
new QuoteReply(sender.getFromEvent().getSource());
该代码似乎并无法达成目的。
它只会返回如下内容:
有什么办法解决吗? -
具体做法如下:
public void function(CommandSenderOnMessage sender) throws IOException { QuoteReply reply = sender.getFromEvent().getMessage().get(QuoteReply.Key); MessageChain chain = reply.getSource().getOriginalMessage(); do something... }
或者全写一起,
public void function(CommandSenderOnMessage sender) throws IOException { MessageChain chain = sender.getFromEvent().getMessage().get(QuoteReply.Key).getSource().getOriginalMessage(); do something... }
-
要获取真实内容请使用新加的获取历史消息
-
reply.getSource()
-
@karlatemp
新加的历史信息指的是? -
@karlatemp
是指这样吗?
该指令的结果
-
具体做法如下:
public void function(CommandSenderOnMessage sender) throws IOException { QuoteReply reply = sender.getFromEvent().getMessage().get(QuoteReply.Key); MessageChain chain = reply.getSource().getOriginalMessage(); do something... }
或者全写一起,
public void function(CommandSenderOnMessage sender) throws IOException { MessageChain chain = sender.getFromEvent().getMessage().get(QuoteReply.Key).getSource().getOriginalMessage(); do something... }