World Conquest Chronicles

World Conquest Chronicles

VK Bot, v1.3.0

Error in a message processing

Extendable VK group bot.

Add a flood protection, an error response and improve a logging.

Change Log

  • Closed issues:
    • Responses:
      • Respond only to a last message from several messages received simultaneously #19
      • Support a special response on an error in a message processing #17
    • Log:
      • Mark log messages about a processing of a same user message #25
      • Add a setting of a colorful log #23
      • Don't split log messages across multiple lines #22
    • Add a setting of a .env config path #24
    • Limit a frequency of requests to VK API #18
  • Fixed bugs:
    • Process errors on a join request #20

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;
  • special responses:
    • request of a join to the group;
    • preliminary response about a receiving of a message for a processing;
    • special response on an error in a message processing;
  • respond only to a last message from several messages received simultaneously;
  • attachments:
    • support attachments in a response (see below for details);
    • automatically load attachments from a command response;
    • cache loaded attachments:
      • search in a cache by:
        • attachment path;
        • attachment basename.

Update

Pull updates from the repository:

$ cd vk-bot
$ git pull --rebase origin master

Install new dependencies and rebuild the project:

$ npm install

Update the symlink to the package folder:

$ sudo npm link

Usage

$ vk-bot --version
$ vk-bot --help
$ vk-bot [--config PATH | -c PATH]

Options:

  • --version — show version number;
  • --help — show help;
  • --config PATH, -c PATH — path to a .env config (default: ./.env).

Environment variables:

  • VK_BOT_TOKEN — VK API access token;
  • VK_BOT_GROUP — ID or screen name of the group;
  • VK_BOT_COMMAND — messages process command;
  • VK_BOT_CACHE — file where to persist cached attachments (default: ~/.vk-bot/attachments.json);
  • VK_BOT_INEXACT_CACHE — search attachments in a cache only by its basenames (allowed: TRUE);
  • VK_BOT_LOG — file where to persist a log (default: ~/.vk-bot/logs/app.log);
  • VK_BOT_COLORFUL_LOG — colorize log messages (allowed: TRUE);
  • VK_BOT_PRELIMINARILY — preliminary response about a receiving of a message for a processing (default: Hello! Your message is being processed. Please, wait.);
  • VK_BOT_REQUIRE_JOIN — require join to the group before start a conversation (allowed: TRUE);
  • VK_BOT_JOIN_REQUEST — request of a join to the group (default: Hello! To talk to me, please, join my group.);
  • VK_BOT_ERROR — special response on an error in a message processing (default: I'm sorry, but error has occurred on a processing of your message. Please, try again.);
  • VK_BOT_ONLY_LAST — respond only to a last message from several messages received simultaneously (allowed: TRUE).

Environment variables can be specified in a .env config in the format:

NAME_1=value_1
NAME_2=value_2
...

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

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

Repository

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

Content: code.

License: MIT.

Screenshots

Help message

Help message

Messages processing

Messages processing