From 5147b40fdc65b3af0517a56c18b4d6818529b604 Mon Sep 17 00:00:00 2001 From: mrbesen Date: Wed, 6 Feb 2019 02:20:30 +0100 Subject: [PATCH] sending images only with userid --- src/de/mrbesen/telegram/TelegramAPI.java | 2 +- src/de/mrbesen/telegram/objects/TUser.java | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/de/mrbesen/telegram/TelegramAPI.java b/src/de/mrbesen/telegram/TelegramAPI.java index aff6a60..1d46a49 100644 --- a/src/de/mrbesen/telegram/TelegramAPI.java +++ b/src/de/mrbesen/telegram/TelegramAPI.java @@ -166,7 +166,7 @@ public class TelegramAPI implements Runnable { msg_offset = (upd.update_id+1 > msg_offset ? upd.update_id+1 : msg_offset); } } - + public TUser getUser(String name) { for(TUser us : users) { if(us.getName().equals(name)) diff --git a/src/de/mrbesen/telegram/objects/TUser.java b/src/de/mrbesen/telegram/objects/TUser.java index 5eda77e..7dd95f8 100644 --- a/src/de/mrbesen/telegram/objects/TUser.java +++ b/src/de/mrbesen/telegram/objects/TUser.java @@ -105,25 +105,35 @@ public class TUser { } public void sendImage(String caption, String url) { + sendImage(api, id, caption, url); + } + + public static void sendImage(TelegramAPI api, int userid, String caption, String url) { try { String cap = ""; if(caption != null) { if(!caption.isEmpty()) cap = "&caption=" + caption; } - api.request("sendPhoto", "chat_id=" + id + cap + "&photo=" + url); + api.request("sendPhoto", "chat_id=" + userid + cap + "&photo=" + url); } catch (IOException e) { e.printStackTrace(); } } + + public void sendAnimation(String caption, String url) { + sendAnimation(api, id, caption, url); + } + + public static void sendAnimation(TelegramAPI api, int userid, String caption, String url) { try { String cap = ""; if(caption != null) { if(!caption.isEmpty()) cap = "&caption=" + caption; } - api.request("sendAnimation", "chat_id=" + id + cap + "&animation=" + url); + api.request("sendAnimation", "chat_id=" + userid + cap + "&animation=" + url); } catch (IOException e) { e.printStackTrace(); }