Package net.flioris.jva
Class JVA
java.lang.Object
net.flioris.jva.JVA
Provides methods to execute API requests and handles events.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetConversationById
(String conversationId) Returns the Conversation by its ID.getConversationsById
(String... conversationIds) Returns a List of Conversation by their ID.Gets a documents upload server (currently used for uploading group photos).getPhotoUploadServer
(int peerId) Gets a photos upload server.getUserById
(String userId) Returns the User by its ID.post()
Publishes a post on the wall of a bot group.saveDocument
(org.json.JSONObject uploadResponse) Saves a document (currently used for uploading group photos).savePhoto
(org.json.JSONObject uploadResponse) Saves a photo.send
(int targetId) Sends a message to the user or conversation.send
(int... targetIds) Sends a messages to users OR conversations.void
setListeners
(EventListener... listeners) Sets the event listeners that will handle incoming bot events.uploadDocument
(String uploadUrl, File photo) Uploads a document (currently used for uploading group photos).uploadPhoto
(String uploadUrl, File photo) Uploads a photo.
-
Constructor Details
-
JVA
Creates a new instance of the JVA bot with the specified access token and group ID.- Parameters:
accessToken
- The access token used to authenticate API requests.groupId
- The ID of the group the bot belongs to.
-
-
Method Details
-
setListeners
Sets the event listeners that will handle incoming bot events.- Parameters:
listeners
- The event listeners to be registered
-
getPhotoUploadServer
Gets a photos upload server.- Parameters:
peerId
- The ID of the user or conversation to which you want to upload a photo.- Returns:
- Photos upload server.
-
getDocumentUploadServer
Gets a documents upload server (currently used for uploading group photos).- Returns:
- Documents upload server.
-
uploadPhoto
Uploads a photo.- Parameters:
uploadUrl
- Just the response of the getPhotosUploadServer method.photo
- The photo file to upload.- Returns:
- uploadPhotoResponse.
-
uploadDocument
Uploads a document (currently used for uploading group photos).- Parameters:
uploadUrl
- Just the response of the getDocsUploadServer method.photo
- The photo file to upload.- Returns:
- uploadDocumentResponse.
-
savePhoto
Saves a photo.- Parameters:
uploadResponse
- Just the response of the uploadPhoto method.- Returns:
- savePhotoResponse.
-
saveDocument
Saves a document (currently used for uploading group photos).- Parameters:
uploadResponse
- Just the response of the uploadDocument method.- Returns:
- saveDocumentResponse.
-
send
Sends a message to the user or conversation.- Parameters:
targetId
- The ID of the user or conversation to which you want to post a message with text and a photo.- Returns:
- The ID of the message that was sent.
-
send
Sends a messages to users OR conversations. Do not include both users and conversations. If the bot is unable to send any message, no messages will be sent and an empty list will be returned to you.- Parameters:
targetIds
- User IDs OR Conversations IDs where you want to send the message.- Returns:
- А list of message IDs.
-
post
Publishes a post on the wall of a bot group.- Returns:
- The ID of the message that was sent.
-
getConversationById
Returns the Conversation by its ID.- Parameters:
conversationId
- The ID of the Conversation you want to receive. To get group chats use -1, -2 etc.- Returns:
- The Conversation with this ID. May return null.
-
getConversationsById
Returns a List of Conversation by their ID. May return an empty list if at least 1 conversation is not found.- Parameters:
conversationIds
- IDs of the Conversations you want to receive. To get group chats use -1, -2 etc.- Returns:
- A List of Conversation.
-
getUserById
Returns the User by its ID.- Parameters:
userId
- The ID of the User you want to receive.- Returns:
- The User with this ID. May return null.
-