public Message sendLocation( TelegramChat chat, float latitude, float longitude, Message replyToMessage, ReplyMarkup markup) throws JSONException, UnsupportedOperationException, IOException, URISyntaxException { if (chat == null) { throw new NullPointerException("The chat argument must not be null."); } JSONObject data = new JSONObject(); data.put("chat_id", chat.getId()); data.put("latutide", latitude); data.put("longitude", longitude); if (replyToMessage != null) { data.put("reply_to_message_id", replyToMessage.getMessageId()); } if (markup != null) { data.put("reply_markup", markup.toJSONObject()); } JSONObject response = new Request(getURIFromMethod("sendLocation")).execute(data).getResultAsJSONObject(); if (response.getBoolean("ok")) { return new Message(response.getJSONObject("result")); } else { throw new TelegramAPIError(response.getString("description")); } }
public Message sendMessage( TelegramChat chat, String text, Boolean disableWebPagePreview, Message replyToMessage, ReplyMarkup markup) throws JSONException, UnsupportedOperationException, IOException, URISyntaxException { if (chat == null) { throw new NullPointerException("The chat argument must not be null."); } if (text == null) { throw new NullPointerException("The text argument must not be null."); } JSONObject data = new JSONObject(); data.put("chat_id", chat.getId()); data.put("text", text); if (disableWebPagePreview != null) { data.put("disable_web_page_preview", disableWebPagePreview); } if (replyToMessage != null) { data.put("reply_to_message_id", replyToMessage.getMessageId()); } if (markup != null) { data.put("reply_markup", markup.toJSONObject()); } JSONObject response = new Request(getURIFromMethod("sendMessage")).execute(data).getResultAsJSONObject(); if (response.getBoolean("ok")) { return new Message(response.getJSONObject("result")); } else { throw new TelegramAPIError(response.getString("description")); } }
public Message forwardMessage(TelegramChat chat, Message source) throws JSONException, UnsupportedOperationException, IOException, URISyntaxException { if (chat == null) { throw new NullPointerException("The chat argument must not be null."); } if (source == null) { throw new NullPointerException("The source argument must not be null."); } JSONObject data = new JSONObject(); data.put("chat_id", chat.getId()); data.put("from_chat_id", source.getChatRoom().getId()); data.put("message_id", source.getMessageId()); JSONObject response = new Request(getURIFromMethod("forwardMessage")).execute(data).getResultAsJSONObject(); if (response.getBoolean("ok")) { return new Message(response.getJSONObject("result")); } else { throw new TelegramAPIError(response.getString("description")); } }