World Conquest Chronicles

World Conquest Chronicles

VK Bot, v1.0.0

Conversation with the bot

Extendable VK group bot.

Major release.

Features

  • listen inbox messages via the long polling technology;
  • process messages by the specified outer command;
  • serialize a message object (see below for details) to the JSON format.

Installation

Clone this repository:

$ git clone https://github.com/thewizardplusplus/vk-bot.git
$ cd vk-bot

Install dependencies and build the project:

$ npm install

Symlink the package folder:

$ sudo npm link

Usage

$ vk-bot --version
$ vk-bot --help

Options:

  • --version — show version number;
  • --help — show help.

Environment variables:

  • VK_BOT_TOKEN — VK API access token;
  • VK_BOT_COMMAND — messages process command.

Environment variables can be specified in a .env file in the project folder in the format:

NAME_1=value_1
NAME_2=value_2
...

See details about the format: https://github.com/motdotla/dotenv#rules.

A .env file will never modify any environment variables that have already been set.

Message object

Message object in the JSON Schema format:

{
  "type": "object",
  "properties": {
    "id": {
      "type": "integer"
    },
    "peer_id": {
      "type": "integer"
    },
    "timestamp": {
      "description": "date and time in ISO 8601 format",
      "type": "string",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{3}Z$"
    },
    "subject": {
      "$ref": "#/definitions/nonempty-string"
    },
    "text": {
      "$ref": "#/definitions/nonempty-string"
    }
  },
  "required": [
    "id",
    "peer_id",
    "timestamp",
    "subject",
    "text"
  ],
  "additionalProperties": false,
  "definitions": {
    "nonempty-string": {
      "type": "string",
      "minLength": 1
    }
  }
}

Repository

Link: https://github.com/thewizardplusplus/vk-bot/tree/v1.0.0.

Content: code.

License: MIT.

Screenshots

Help message

Help message

Messages processing

Messages processing