# tagpro-bot

> A library to create bots in tagpro

Latest version **0.0.7** (published 2014-07-02) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

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

Negative: insecure dependencies; abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.7 |
| Published | 2014-07-02 |
| First published | 2014-05-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 6 |
| Author | ylambda |
| Maintainers | ylambda |

## Links

- npm: https://www.npmjs.com/package/tagpro-bot
- Repository: https://github.com/brainss/tagpro-bot
- Issues: https://github.com/brainss/tagpro-bot/issues
- npm.io page: https://npm.io/package/tagpro-bot

## Dependencies (2)

- [cookie](https://npm.io/package/cookie.md) ^0.1.2
- [socket.io-client](https://npm.io/package/socket.io-client.md) git+https://github.com/jj56/socket.io-client.git#jj56ver

## Recent versions

- 0.0.7 (latest) — 2014-07-02
- 0.0.6 — 2014-05-18
- 0.0.5 — 2014-05-18
- 0.0.4 — 2014-05-18
- 0.0.3 — 2014-05-18
- 0.0.2 — 2014-05-17
- 0.0.1 — 2014-05-17

## README

# tagpro-bot

A library to create a bot for tagpro.

``` javascript
var tagbot = require('tagpro-bot');
var room = process.argv[2];
var uri = 'http://tagpro-pi.koalabeast.com'

tagbot.getSession(uri, function(err, session) {
  var socket = tagbot.connect(uri+':81/groups/'+room, session);
  socket.on('connect', function() {
      socket.emit('chat', 'Hello groups!');
  });
});
```

This library also has a Bot constructor, useful for creating
a tagpro bot which can join groups, games, and the joiner. This bot
has listeners registered on each socket to record the state of the
game/group.

```
var room = process.argv[2];
var groupbot = Bot({
  hostname: 'http://tagpro-pi.koalabeast.com',
  room: room
});

// must have a session before connecting
groupbot.on('session', function() {
  var socket = groupbot.group.connect();
  socket.on('connect', function() {
    socket.emit('name', 'groupbot');
    socket.emit('chat', 'Hi, I\'m group bot!');
    setTimeout(function() {
      socket.emit('chat', 'Goodbye!');
      socket.disconnect();
    }, 5e3);
  });
});

```

## Usage

### .connect(uri, session, callback)

Open a new socket.io connection at the given uri.

  * `uri`: location to open the socket.io sessei
  * 'session`: tagpro session id to send with socket connection
  * `callback`: called after opening the socket connection with `callback(err, socket)`

### .getSession(uri, callback)

Retrieve a session token, necessary to open a socket connection.

  * `uri`: location to open the socket.io sessei
  * `callback`: called when the session is ready with `callback(err, session)`

## .Bot(options)

Create a new Bot instance, which has useful functions to connect to games, groups, or the joiner. On each socket, listeners will be registered to aid in keeping track of the game's state.

``` javascript
// options
{


}
```

# Credit

Thanks goes out to [✈](https://github.com/jj56) for creating [SpectaBot](https://github.com/jj56/SpectaBot) and for creating a socket.io-client with cookie option.

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