Package com.github.stormbit.sdk.objects
Class Message
- java.lang.Object
-
- com.github.stormbit.sdk.objects.Message
-
public class Message extends Object
Message object for both (received and sent) messages
-
-
Method Summary
Modifier and Type Method Description Messageattachments(String... attachments)Message attachmentsIntegerauthorId()IntegerchatId()Messagedoc(String doc)Synchronous adding doc to the messageMessagedoc(String doc, DocTypes typeOfDoc)Synchronous adding doc to the messageMessagedocAsync(String doc)Attach doc to messageMessagedocAsync(String doc, DocTypes type)Attach doc to messageMessagedocFromBytes(byte[] docBytes, DocTypes typeOfDoc, String fileNameField)MessageforwardedMessages(Object... ids)IDs of forwarded messagesMessagefrom(Client client)Your client with id, access tokenorg.json.JSONArraygetAttachments()Get attachments from messageStringgetBiggestPhotoUrl(org.json.JSONArray photos)IntegergetChatIdLong()Map<String,Integer>getCountOfAttachmentsByType()Method helps to identify kind of messageIntegergetFlags()org.json.JSONArraygetForwardedMessages()IntegergetMessageId()org.json.JSONArraygetPhotos()IntegergetRandomId()StringgetText()IntegergetTimestamp()StringgetTitle()org.json.JSONObjectgetVoiceMessage()booleanhasFwds()booleanisAudioMessage()booleanisDocMessage()booleanisGifMessage()booleanisLinkMessage()booleanisMessageFromChat()booleanisPhotoMessage()booleanisSimpleTextMessage()booleanisStickerMessage()booleanisVideoMessage()booleanisVoiceMessage()booleanisWallMessage()StringmessageType()Get the type of messageMessagephoto(String photo)Synchronous adding photo to the messageMessagephotoAsync(String photo)Attach photo to messageMessagerandomId(Integer randomId)Message random_idvoidsend(Callback<Object>... callback)Send the messagevoidsendVoiceMessage(String doc, Callback<Object>... callback)Send voice messagevoidsetAccessToken(String accessToken)voidsetChatId(Integer chatId)voidsetChatIdLong(Integer chatIdLong)voidsetTitle(String title)Messagesticker(Integer id)ID of sticker, only for user tokensMessagetext(Object text)Message textMessagetitle(Object title)Message title (bold text)Messageto(Integer peerId)ID of target dialogStringtoString()voiduploadDoc(org.json.JSONObject doc, Callback<Object> callback)Async uploading docvoiduploadPhoto(String photo, Callback<Object> callback)Async uploading photos
-
-
-
Constructor Detail
-
Message
public Message()
Constructor for sent message
-
Message
public Message(Client client, Integer messageId, Integer flags, Integer peerId, Integer timestamp, String text, org.json.JSONObject attachments, Integer randomId)
Constructor for received message- Parameters:
client- clientmessageId- message idflags- flagspeerId- peer idtimestamp- timestamptext- message textattachments- message attachmentsrandomId- random id
-
-
Method Detail
-
from
public Message from(Client client)
Your client with id, access token- Parameters:
client- client- Returns:
- this
-
sticker
public Message sticker(Integer id)
ID of sticker, only for user tokens- Parameters:
id- sticker id- Returns:
- this
-
forwardedMessages
public Message forwardedMessages(Object... ids)
IDs of forwarded messages- Parameters:
ids- message ids- Returns:
- this
-
text
public Message text(Object text)
Message text- Parameters:
text- message content- Returns:
- this
-
title
public Message title(Object title)
Message title (bold text)- Parameters:
title- message title- Returns:
- this
-
attachments
public Message attachments(String... attachments)
Message attachments- Parameters:
attachments- attachments- Returns:
- this
-
randomId
public Message randomId(Integer randomId)
Message random_id- Parameters:
randomId- random- Returns:
- this
-
photo
public Message photo(String photo)
Synchronous adding photo to the message- Parameters:
photo- String URL, link to vk doc or path to file- Returns:
- this
-
doc
public Message doc(String doc, DocTypes typeOfDoc)
Synchronous adding doc to the message- Parameters:
doc- String URL, link to vk doc or path to filetypeOfDoc- Type of doc, 'audio_message' or 'graffiti' ('doc' as default)- Returns:
- this
-
docFromBytes
public Message docFromBytes(byte[] docBytes, DocTypes typeOfDoc, String fileNameField)
-
doc
public Message doc(String doc)
Synchronous adding doc to the message- Parameters:
doc- String URL, link to vk doc or path to file- Returns:
- this
-
photoAsync
public Message photoAsync(String photo)
Attach photo to messageWorks slower that sync photo adding, but will be called from execute
- Parameters:
photo- Photo link: url, from disk or already uploaded to VK as photo{owner_id}_{id}- Returns:
- this
-
uploadPhoto
public void uploadPhoto(String photo, Callback<Object> callback)
Async uploading photos- Parameters:
photo- Photo link: url, from disk or already uploaded to VK as photo{owner_id}_{id}callback- callback
-
uploadDoc
public void uploadDoc(org.json.JSONObject doc, Callback<Object> callback)Async uploading doc- Parameters:
doc- Doc link: url, from disk or already uploaded to VK as doc{owner_id}_{id}callback- callback
-
docAsync
public Message docAsync(String doc, DocTypes type)
Attach doc to message- Parameters:
doc- Doc link: url, from disk or already uploaded to VK as doc{owner_id}_{id}type- type- Returns:
- this
-
docAsync
public Message docAsync(String doc)
Attach doc to message- Parameters:
doc- Doc link: url, from disk or already uploaded to VK as doc{owner_id}_{id}- Returns:
- this
-
sendVoiceMessage
public void sendVoiceMessage(String doc, Callback<Object>... callback)
Send voice message- Parameters:
doc- URL or path to filecallback- response will returns to callback
-
send
public void send(Callback<Object>... callback)
Send the message- Parameters:
callback- will be called with response object
-
messageType
public String messageType()
Get the type of message- Returns:
- type of message
-
hasFwds
public boolean hasFwds()
- Returns:
- true if message has forwarded messages
-
getForwardedMessages
public org.json.JSONArray getForwardedMessages()
- Returns:
- array of forwarded messages or []
-
getAttachments
public org.json.JSONArray getAttachments()
Get attachments from message- Returns:
- JSONArray attachments
-
isPhotoMessage
public boolean isPhotoMessage()
-
isSimpleTextMessage
public boolean isSimpleTextMessage()
-
isVoiceMessage
public boolean isVoiceMessage()
-
isAudioMessage
public boolean isAudioMessage()
-
isVideoMessage
public boolean isVideoMessage()
-
isDocMessage
public boolean isDocMessage()
-
isWallMessage
public boolean isWallMessage()
-
isStickerMessage
public boolean isStickerMessage()
-
isLinkMessage
public boolean isLinkMessage()
-
isGifMessage
public boolean isGifMessage()
-
getCountOfAttachmentsByType
public Map<String,Integer> getCountOfAttachmentsByType()
Method helps to identify kind of message- Returns:
- Map: key=type of attachment, value=count of attachments, key=summary - value=count of all attachments.
-
getMessageId
public Integer getMessageId()
-
getFlags
public Integer getFlags()
-
authorId
public Integer authorId()
-
getTimestamp
public Integer getTimestamp()
-
getText
public String getText()
-
getPhotos
public org.json.JSONArray getPhotos()
-
getChatIdLong
public Integer getChatIdLong()
-
setChatIdLong
public void setChatIdLong(Integer chatIdLong)
-
getBiggestPhotoUrl
public String getBiggestPhotoUrl(org.json.JSONArray photos)
- Parameters:
photos- JSONArray with photo objects- Returns:
- URL of biggest image file
-
getVoiceMessage
public org.json.JSONObject getVoiceMessage()
-
isMessageFromChat
public boolean isMessageFromChat()
-
chatId
public Integer chatId()
-
setChatId
public void setChatId(Integer chatId)
-
setAccessToken
public void setAccessToken(String accessToken)
-
getRandomId
public Integer getRandomId()
-
getTitle
public String getTitle()
-
setTitle
public void setTitle(String title)
-
-