sending images only with userid

This commit is contained in:
mrbesen 2019-02-06 02:20:30 +01:00
parent 2f4309042e
commit 5147b40fdc
Signed by: MrBesen
GPG Key ID: 596B2350DCD67504
2 changed files with 13 additions and 3 deletions

View File

@ -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))

View File

@ -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();
}