2.0.1 • Published 3 years ago

win93-trollbox-bot v2.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

Trollbot

Trollbot is a minimal library for making simple, fast-responding trollbox bots for windows 93.

Types

type Home = string;

type User = {
  nick: string;
  color: string;
  style: string;
  home: Home;
  room: string;
  isBot: boolean;
};

type Message = {
  date: number;
  nick: string;
  color: string;
  style: string;
  home: Home;
  msg: string;
};

Usage

First of all, import the bot class, and create a bot.

import Bot from "trollbox-bot";

const bot = new Bot("Name", "Color", "Prefix", "Welcome message");

setCommand - Adds a callback that fires when the message begins with the bot's prefix and the command's name

// When a user says "name" with the prefix, the bot will send back its current nickname.
// Have a look through the data variable for info on the command that was sent.

bot.setCommand("name", (message) => {
  bot.sendMessage(`My name is ${bot.name}, ${message.nick}`);
});

onConnect - Adds a callback that fires when the bot has successfully connected.

bot.onConnect((socket) => {
  bot.sendMessage("Nvm, I'm out...");
  socket.close();
});

onmessage - Adds a callback that fires when a message is received.

bot.onMessage((message) => {
  // ...
});

onUserJoined - Adds a callback that fires when a user joins.

bot.onUserJoined((user) => {
  // ...
});

onUserLeft - Adds a callback that fires when a user leaves your current room.

bot.onUserLeft((user) => {
  // ...
});

updateColor - Updates the color of the bot

bot.updateColor("White");

updateName - Updates the name of the bot

bot.updateName("Joebot (=)");

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

Bots made with this

None so far that has been noted

License

MIT