vas-chat-reactor

1.1.3 • Public • Published

vas-chat-reactor

A plugin for mineflayer which allows the bot to respond to Chat Reaction messages

Prerequisites

Installation

Clone this repository in node_modules folder and run:

npm install

Or just simply:

npm install vas-chat-reactor

Configuration

  • Move or copy the file chat_config.ini in the bot directory. Make sure to have it in the same directory where nodejs starts.
  • Fill in the chat_config.ini file with the necessary things to identify Chat Reaction messages and extract the word from it. You will find all the documentation inside it. The dictionaryFile and unknownWordsFile paths are relative to where nodejs starts.
  • Fill the time to wait until the bot writes the word (will be evaluated with eval(timeout)). I found that 1850 + ~~((0.5 + Math.random()/2) * 150 * word.length) works best looking at how quick other players write.
  • Fill in the chance to write the word. 0 or less means 0% or never write the word and 1 or bigger is 100% chance of writing.
  • Write all the known possible words to descramble in dictionaryFile, one on every line. If you don't know the words, let the bot run for some time until it will collect most of them.

Anytime the bot will find an unknown word it will write it into the unknownWordsFile, as specificated in configuration file.
Don't use my config and dictionary file, they are just a reference guide!
Why don't I use regex instead of string.startsWith, string.endsWith and substring? Because it's faster this way and you can't have weird patterns in the message. Maybe I'm wrong...

Usage

Simply require it and add it to bot's plugins.

const mineflayer = require("mineflayer");
const chatReactor  = require("vas-chat-reactor");
const bot = mineflayer.createBot({
    "host": "HOST",
    "port": 25565,
    "username": "USERNAME",
    "password": "PASSWORD",
    "plugins": [chatReactor],
 
});
 

Or, if you prefer:

// Bot is already created here
require("vas-chat-reactor")(bot);

And then:

bot.enableChatReaction();

And if you want to disable it on the fly:

bot.disableChatReaction();

Additionally, if you want to see debug information, you can set the _DEBUG variable on row 16 of index.js to true.

Test coverage

To test it simply run npm test.

> npm test
 
> vas-chat-reactor@1.0.3 test /home/ubuntu/workspace/git/vas-chat-reactor
> mocha
 
 
 
  vas-chat-reactor
    Load plugin
      ✓ should load events
      ✓ should add functions to the bot
      ✓ should not crash on message event
 
 
  3 passing (23ms)
 

License

This plugin is distributed under Apache 2.0. See LICENSE.

Additional details

Contact

If you have any problems, contact me and I will try to help you. You can find me here.

Package Sidebar

Install

npm i vas-chat-reactor

Weekly Downloads

1

Version

1.1.3

License

Apache-2.0

Unpacked Size

24 kB

Total Files

9

Last publish

Collaborators

  • vasile2k