Class JVA

java.lang.Object
net.flioris.jva.JVA

public class JVA extends Object
Provides methods to execute API requests and handles events.
  • Constructor Details

    • JVA

      public JVA(String accessToken, String groupId)
      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

      public void setListeners(EventListener... listeners)
      Sets the event listeners that will handle incoming bot events.
      Parameters:
      listeners - The event listeners to be registered
    • getPhotoUploadServer

      public GetPhotoUploadServerAction getPhotoUploadServer(int peerId)
      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

      public GetDocumentUploadServerAction getDocumentUploadServer()
      Gets a documents upload server (currently used for uploading group photos).
      Returns:
      Documents upload server.
    • uploadPhoto

      public UploadPhotoAction uploadPhoto(String uploadUrl, File photo)
      Uploads a photo.
      Parameters:
      uploadUrl - Just the response of the getPhotosUploadServer method.
      photo - The photo file to upload.
      Returns:
      uploadPhotoResponse.
    • uploadDocument

      public UploadDocumentAction uploadDocument(String uploadUrl, File photo)
      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

      public SavePhotoAction savePhoto(org.json.JSONObject uploadResponse)
      Saves a photo.
      Parameters:
      uploadResponse - Just the response of the uploadPhoto method.
      Returns:
      savePhotoResponse.
    • saveDocument

      public SaveDocumentAction saveDocument(org.json.JSONObject uploadResponse)
      Saves a document (currently used for uploading group photos).
      Parameters:
      uploadResponse - Just the response of the uploadDocument method.
      Returns:
      saveDocumentResponse.
    • send

      public SendMessageAction send(int targetId)
      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

      public SendMessagesAction send(int... targetIds)
      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

      public PostAction post()
      Publishes a post on the wall of a bot group.
      Returns:
      The ID of the message that was sent.
    • getConversationById

      public GetConversationByIdAction getConversationById(String conversationId)
      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

      public GetConversationsByIdAction getConversationsById(String... conversationIds)
      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

      public GetUserByIdAction getUserById(String userId)
      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.