Skip to content

NeluQi/Hephaestu

Repository files navigation

VKBOT-Hephaestu

Bot for VK. Basis for the bot. It's easy to set up a new command
Bot uses an account, not a group.
A simple bot, wrote from boredom

List of commands already included in the bot:
/help - List of Commands
/fake - Anti-deadline - broken files
/vote "< QUESTION >" < TIME TO VOTE > - Start voting
/rdm - Random answer (Example of a shortened command: '/r Going to the store?')

You yourself can easily add new commands

Dependencies

IDE NetBans 8.2
The project uses:

Project structure

Bot uses the user’s account, not the api group

Main.java - The title explains everything
LongPoll.java - There are new events vk checked there. New event can be processed in ResponseProcessing
ResponseProcessing.java - Here new commands are added. There is also a set of commands.
TimeEvent.java - Started every minute. Serves for handling commands associated with a deferred response.

(NEW EVENT) LongPoll.java --> (Processing this event) ResponseProcessing.java

To create a new command:

  1. Create a new Java class (Recommended in the package “com.bot.vkhephaestusbot.Command”).
  2. Сreate a public static method.
  3. Your method should accept “Message”
Example:
public static void TextAnswers(Message msg){}

4.Process “msg” in your class.
Use the “UserActor” and the “VkApiClient” from the VK JAVA SDK (https://vk.com/dev/Java_SDK)
Use global UserActor actor and VkApiClient apiClient

Example:
public class Fils {
    public static void Fils(Message msg) throws ApiException, ClientException{
                if(msg.getBody().matches("/fil") && msg.getChatId() != null) { //Check for match of the command
                Main.APICLIENT.messages().send(ACTOR).chatId(msg.getChatId()).message("IS COMANDS").attachment().execute();
                System.out.println("[Fils]Send message"); LOG.info("[Fils]Send message");}
    }  
}

5. Call your function in ResponseProcessing.java

LICENSE WTFPL