public final class Message extends java.lang.Object implements Twitter.ITweet
Modifier and Type | Field and Description |
---|---|
java.lang.Number |
id |
java.lang.Number |
inReplyToMessageId
Equivalent to
Status.inReplyToStatusId *but null by default*. |
java.lang.String |
text |
Constructor and Description |
---|
Message(com.winterwell.json.JSONObject event)
Parse a Message from the format we get from webhooks and GET direct_messages/etc
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object obj)
Tests by class=Message and tweet id number
|
java.util.Date |
getCreatedAt() |
java.lang.String |
getDisplayText() |
java.math.BigInteger |
getId()
Twitter IDs are numbers - but they can exceed the range of Java's
signed long.
|
java.lang.String |
getLocation() |
java.util.List<java.lang.String> |
getMentions() |
static java.util.List<Message> |
getMessages(com.winterwell.json.JSONArray array) |
Place |
getPlace() |
User |
getRecipient() |
java.lang.Number |
getRecipientId() |
User |
getSender() |
java.lang.Number |
getSenderId() |
java.lang.String |
getText()
The actual status text.
|
java.util.List<Twitter.TweetEntity> |
getTweetEntities(Twitter.KEntityType type)
Twitter wrap urls with their own url-shortener (as a defence against
malicious tweets).
|
User |
getUser()
This is equivalent to
getSender() |
int |
hashCode() |
void |
setPeople(com.winterwell.json.JSONObject users)
Set up sender/recipient full objects
|
void |
setPeople(User sender,
User recipient)
Set up sender/recipient full objects
|
java.lang.String |
toString() |
public final java.lang.Number id
public java.lang.Number inReplyToMessageId
Status.inReplyToStatusId
*but null by default*. If
you want to use this, you must set it yourself. The field is just a
convenient storage place. Strangely Twitter don't report the previous ID
for messages.public final java.lang.String text
public Message(com.winterwell.json.JSONObject event)
event
- The message objectpublic java.lang.String getDisplayText()
getDisplayText
in interface Twitter.ITweet
public static java.util.List<Message> getMessages(com.winterwell.json.JSONArray array)
public void setPeople(com.winterwell.json.JSONObject users)
users
- Map from numeric user IDs to user JSON (delivered in webhooks update)public void setPeople(User sender, User recipient)
sender
- recipient
- public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public java.util.Date getCreatedAt()
getCreatedAt
in interface Twitter.ITweet
public java.math.BigInteger getId()
Twitter.ITweet
getId
in interface Twitter.ITweet
public java.lang.String getLocation()
getLocation
in interface Twitter.ITweet
Note: This will be set if Twitter supply any geo-information. We extract a location from geo and place objects.
public java.util.List<java.lang.String> getMentions()
getMentions
in interface Twitter.ITweet
getRecipient()
.
Notes: This method is in ITweet as a convenience to allow the same code to process both Statuses and Messages where possible. It would be better named "getRecipients()", but for historical reasons it isn't.
public Place getPlace()
getPlace
in interface Twitter.ITweet
public User getRecipient()
public User getSender()
public java.lang.Number getSenderId()
public java.lang.Number getRecipientId()
public java.lang.String getText()
Twitter.ITweet
Twitter.toString()
getText
in interface Twitter.ITweet
public java.util.List<Twitter.TweetEntity> getTweetEntities(Twitter.KEntityType type)
Twitter.ITweet
Entity support is off by default. Request entity support by setting
Twitter.setIncludeTweetEntities(boolean)
. Twitter do NOT
support entities for search :(
getTweetEntities
in interface Twitter.ITweet
type
- urls, user_mentions, or hashtagspublic User getUser()
getSender()
getUser
in interface Twitter.ITweet
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object