From c0115554aac7106974e12fd5b66ceaf69cee6e84 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Fri, 13 May 2016 11:26:34 +0300 Subject: full message format --- src/main/java/com/juick/api/TelegramBotHook.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/main/java/com/juick/api') diff --git a/src/main/java/com/juick/api/TelegramBotHook.java b/src/main/java/com/juick/api/TelegramBotHook.java index 7ee759eb..6a6404de 100644 --- a/src/main/java/com/juick/api/TelegramBotHook.java +++ b/src/main/java/com/juick/api/TelegramBotHook.java @@ -54,9 +54,15 @@ public class TelegramBotHook { public void onTextMessage(WebSocket websocket, String text) throws Exception { super.onTextMessage(websocket, text); com.juick.Message jmsg = ms.deserialize(new JSONObject(text)); - logger.info("got jmsg: " + jmsg.toString()); + logger.info("got jmsg: " + ms.serialize(jmsg).toString()); + StringBuilder sb = new StringBuilder(); + sb.append(jmsg.getUser()).append("\n").append(jmsg.getText()).append("\n"); + if (jmsg.getAttachmentURL() != null) { + sb.append(jmsg.getAttachmentURL()); + } + sb.append("https://juick.com/" + jmsg.getMID()); chats.stream().forEach(c -> { - bot.execute(new SendMessage(c, jmsg.getText()), new Callback() { + bot.execute(new SendMessage(c, sb.toString()), new Callback() { @Override public void onResponse(SendMessage request, SendResponse response) { logger.info("got response: " + response.message().toString()); -- cgit v1.2.3