# riddlet-bot

> The official bot library for Riddlet

Latest version **0.11.4** (published 2018-04-02) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install riddlet-bot
pnpm add riddlet-bot
yarn add riddlet-bot
bun add riddlet-bot
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.11.4 |
| Published | 2018-04-02 |
| First published | 2018-04-02 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 17.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | afroraydude |
| Maintainers | afroraydude |
| Keywords | chat, chatbot |

## Links

- npm: https://www.npmjs.com/package/riddlet-bot
- Repository: https://github.com/afroraydude/riddlet-bot
- Homepage: https://github.com/afroraydude/riddlet-bot#readme
- Issues: https://github.com/afroraydude/riddlet-bot/issues
- npm.io page: https://npm.io/package/riddlet-bot

## Dependencies (3)

- [crypto](https://npm.io/package/crypto.md) ^1.0.1
- [keypair](https://npm.io/package/keypair.md) ^1.0.1
- [socket.io-client](https://npm.io/package/socket.io-client.md) ^2.1.0

## Recent versions

- 0.11.4 (latest) — 2018-04-02
- 0.11.3 — 2018-04-02
- 0.11.2 — 2018-04-02
- 0.11.1 — 2018-04-02
- 0.11.0 — 2018-04-02

## README

![logo](https://riddletchat.firebaseapp.com/static/media/logo.786543bd.png)

# riddlet-bot

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

[![NPM](https://nodei.co/npm/riddlet-bot.png)](https://www.npmjs.com/package/riddlet-bot)

[![docs version](https://img.shields.io/badge/docs%20version-v0.11.0-orange.svg)](http://riddlet-docs.afroraydude.com/)

## 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.

```js
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.

```js
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.

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

Now we want to import it into our bot.

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

And that's your first bot!

---
_Source: https://npm.io/package/riddlet-bot · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
