0.11.4 • Published 6 years ago

riddlet-bot v0.11.4

Weekly downloads
2
License
Apache-2.0
Repository
github
Last release
6 years ago

logo

riddlet-bot

The official bot library for Riddlet, the anonymous chat application and server.

NPM

docs version

Installation

Installation is fairly simple. Just run npm install --save riddlet-bot in your project directory.

Your first bot

The official bot library allows for very barebones bot creation.

Simple Log Bot

To create a bot, you first want to create a new RiddletBot class.

var RiddletBot = require('riddlet-bot').RiddletBot

var bot = new RiddletBot("http://chat.example.com")

You should know if if this works when you get a token printed to your terminal. (ie: xxxxxxxxxxxxx.yyyyyyyyyyyy.zzzzzzzzzzzz)

We now want to stop the bot process and put that token as a second parameter. This allows our bot to have the same token each time it connects to the server.

var bot = new RiddletBot("http://chat.example.com", "xxxxxxxxxxxxx.yyyyyyyyyyyy.zzzzzzzzzzzz")

Your bot should now log every message it recieves from the server.

Custom Message Handler

Now to create a custom Message Handler.

Here is an example message handler that we will be using.

var xMessageHandler = function (bot, message) {
  if(message.data === "!info") {
    bot.SendMessage("test", "#all")
  }
}

Now we want to import it into our bot.

var bot = new RiddletBot("http://chat.example.com", "xxxxxxxxxxxxx.yyyyyyyyyyyy.zzzzzzzzzzzz", xMessageHandler)

And that's your first bot!

0.11.4

6 years ago

0.11.3

6 years ago

0.11.2

6 years ago

0.11.1

6 years ago

0.11.0

6 years ago