get TMessage on sendImage, sendAnimation
This commit is contained in:
parent
72e321c741
commit
d30750a5ff
|
@ -85,4 +85,17 @@ public class TMessage extends JSONBased {
|
|||
public TUser getForward_from() {
|
||||
return forward_from;
|
||||
}
|
||||
|
||||
|
||||
public int getMessageID() {
|
||||
return message_id;
|
||||
}
|
||||
|
||||
public static void delete(TelegramAPI api, int chatid, int msgid) {
|
||||
try {
|
||||
api.request("deleteMessage", "chat_id=" + chatid + "&message_id=" + msgid);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -123,41 +123,39 @@ public class TUser {
|
|||
}
|
||||
|
||||
public boolean sendImage(String caption, String url) {
|
||||
return sendImage(api, id, caption, url, null);
|
||||
return sendImage(api, id, caption, url, null) != null;
|
||||
}
|
||||
|
||||
public static boolean sendImage(TelegramAPI api, int userid, String caption, String url, TReplyMarkup rply) {
|
||||
public static TMessage sendImage(TelegramAPI api, int userid, String caption, String url, TReplyMarkup rply) {
|
||||
try {
|
||||
String cap = "";
|
||||
if(caption != null) {
|
||||
if(!caption.isEmpty())
|
||||
cap = "&caption=" + caption;
|
||||
}
|
||||
api.request("sendPhoto", "chat_id=" + userid + parseRPMU(rply) + cap + "&photo=" + url);
|
||||
return new TMessage(api.request("sendPhoto", "chat_id=" + userid + parseRPMU(rply) + cap + "&photo=" + url).getJSONObject("result"), api);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean sendAnimation(String caption, String url) {
|
||||
return sendAnimation(api, id, caption, url, null);
|
||||
return sendAnimation(api, id, caption, url, null) != null;
|
||||
}
|
||||
|
||||
public static boolean sendAnimation(TelegramAPI api, int userid, String caption, String url, TReplyMarkup rply) {
|
||||
public static TMessage sendAnimation(TelegramAPI api, int userid, String caption, String url, TReplyMarkup rply) {
|
||||
try {
|
||||
String cap = "";
|
||||
if(caption != null) {
|
||||
if(!caption.isEmpty())
|
||||
cap = "&caption=" + caption;
|
||||
}
|
||||
api.request("sendAnimation", "chat_id=" + userid + parseRPMU(rply) + cap + "&animation=" + url);
|
||||
return new TMessage(api.request("sendAnimation", "chat_id=" + userid + parseRPMU(rply) + cap + "&animation=" + url).getJSONObject("result"), api);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue