update captions
This commit is contained in:
parent
d52e8f22a4
commit
077017f590
|
@ -4,6 +4,7 @@ import java.io.IOException;
|
|||
import java.io.InputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.net.URL;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Scanner;
|
||||
|
||||
|
@ -47,7 +48,7 @@ public class TelegramAPI implements Runnable {
|
|||
//stats
|
||||
protected int fetchedUpdates = 0;
|
||||
protected long start = 0;
|
||||
|
||||
|
||||
private LinkedList<TUser> users = new LinkedList<>();
|
||||
private CommandManager cmdmgr = new CommandManager();
|
||||
private EventManager evntmgr = new EventManager();
|
||||
|
@ -125,7 +126,7 @@ public class TelegramAPI implements Runnable {
|
|||
//throw new IOException("API request returned HTTP " + con.getResponseCode() + " (" + con.getResponseMessage() + ") for action " + request + "\nurl: " + url.toString() + "\nparams: " + parameter + "\nerror description: " + errdesc);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected String readfromIS(InputStream is) {
|
||||
Scanner s = new Scanner(is);
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
@ -161,7 +162,7 @@ public class TelegramAPI implements Runnable {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public void sendTypedMessage(final String msg, final TUser user, final int seconds) {
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
|
@ -177,6 +178,19 @@ public class TelegramAPI implements Runnable {
|
|||
}).start();
|
||||
}
|
||||
|
||||
public void updateCaption(final String newCaption, int chatid, int msg_id, boolean async, Callback<JSONObject, ?> clb) {
|
||||
try {
|
||||
String q = "chat_id=" + chatid + "&message_id=" + msg_id + "&caption=" + URLEncoder.encode(newCaption, "UTF-8");
|
||||
if(async) {
|
||||
this.async.enque("editMessageCaption", q);
|
||||
} else {
|
||||
request("editMessageCaption", q);
|
||||
}
|
||||
} catch(IOException e) {
|
||||
log.log("", e);
|
||||
}
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
run = false;
|
||||
thread.interrupt();
|
||||
|
@ -201,8 +215,8 @@ public class TelegramAPI implements Runnable {
|
|||
fetchedUpdates++;
|
||||
try {
|
||||
int wait = (int) (updateInterval - (System.currentTimeMillis() - runstart));
|
||||
if(wait > 0)
|
||||
Thread.sleep(wait);
|
||||
if(wait > 0)
|
||||
Thread.sleep(wait);
|
||||
} catch (InterruptedException e) {
|
||||
break;
|
||||
}
|
||||
|
@ -304,7 +318,7 @@ public class TelegramAPI implements Runnable {
|
|||
public int getupdateInterval() {
|
||||
return updateInterval;
|
||||
}
|
||||
|
||||
|
||||
public float getUpdatesperSecond() {
|
||||
if(start == 0)
|
||||
return -1;
|
||||
|
@ -410,7 +424,7 @@ public class TelegramAPI implements Runnable {
|
|||
isArray = b;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class APIError extends IOException {
|
||||
/**
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue