Tmessage getFileID
This commit is contained in:
parent
9dc407180d
commit
7a5b2d72ca
|
@ -100,6 +100,28 @@ public class TMessage extends JSONBased {
|
|||
return message_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the FileID if a file is attached to this message. If More than one File is attached to this message only one file id is returned
|
||||
* @return
|
||||
*/
|
||||
public String getFileID() {
|
||||
try {
|
||||
JSONObject doc;
|
||||
if(has(JSONBased.Member.document))
|
||||
doc = ((JSONObject) get(JSONBased.Member.document));
|
||||
else if(has(JSONBased.Member.video))
|
||||
doc = ((JSONObject) get(JSONBased.Member.video));
|
||||
else if(has(JSONBased.Member.audio))
|
||||
doc = ((JSONObject) get(JSONBased.Member.audio));
|
||||
else return null;
|
||||
|
||||
return doc.getString("file_id");
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void delete(TelegramAPI api, long chatid, int msgid) {
|
||||
delete(api, chatid, msgid, false);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue