TelegramAPI/src/objects/TMessage.java

52 lines
1.0 KiB
Java

package objects;
import org.json.JSONObject;
import de.mrbesen.telegram.TelegramAPI;
public class TMessage extends JSONBased {
private int message_id;
private TUser from = null;//optional
private long date = -1;
private TUser forward_from = null; //optional
private String text = null;//optional
protected TelegramAPI api;
public void sendTo(TUser u) {
//if this message already exists forward, if not send directly.
}
public TMessage(JSONObject json, TelegramAPI api) {
super(json);
this.api = api;
message_id = json.getInt("message_id");
date = json.getLong("date");
if(json.has("from"))
from = api.getUser(json.getJSONObject("from"));
if(json.has("forward_from"))
forward_from = api.getUser(json.getJSONObject("forward_from"));
if(json.has("text") )
text = json.getString("text");
}
public TUser getFrom() {
return from;
}
public String getText() {
return text;
}
public long getDate() {
return date;
}
public TUser getForward_from() {
return forward_from;
}
}