2017-05-29 02:27:03 +03:00
|
|
|
# III Client
|
2017-09-29 01:09:32 +04:00
|
|
|
<p align="justify">
|
|
|
|
<a href="https://www.npmjs.com/package/iii-client">
|
|
|
|
<img alt="NPM" src="https://img.shields.io/npm/v/iii-client.svg">
|
|
|
|
</a>
|
|
|
|
<a href="https://travis-ci.org/valentineus/iii-client">
|
|
|
|
<img alt="Build Status" src="https://travis-ci.org/valentineus/iii-client.svg?branch=master">
|
|
|
|
</a>
|
|
|
|
<a href="https://www.codacy.com/app/valentineus/iii-client">
|
|
|
|
<img alt="Codacy Badge" src="https://api.codacy.com/project/badge/Grade/81b2fdc2f5dd42a6bdc8fdb43640b282">
|
|
|
|
</a>
|
|
|
|
<a href="https://www.codacy.com/app/valentineus/iii-client/files">
|
|
|
|
<img alt="Codacy Coverage Badge" src="https://api.codacy.com/project/badge/Coverage/81b2fdc2f5dd42a6bdc8fdb43640b282">
|
|
|
|
</a>
|
|
|
|
<a href="https://david-dm.org/valentineus/iii-client?type=dev">
|
|
|
|
<img alt="devDependencies Status" src="https://david-dm.org/valentineus/iii-client/dev-status.svg">
|
|
|
|
</a>
|
|
|
|
</p>
|
|
|
|
<p align="justify">
|
|
|
|
<a href="https://www.libhive.com/providers/npm/packages/iii-client">
|
|
|
|
<img alt="libhive Badge" src="https://www.libhive.com/providers/npm/packages/iii-client/examples/badge.svg">
|
|
|
|
</a>
|
|
|
|
<a href="https://runkit.com/npm/iii-client">
|
|
|
|
<img alt="RunKit Badge" src="https://badge.runkitcdn.com/stripe.svg">
|
|
|
|
</a>
|
2017-09-29 02:06:40 +04:00
|
|
|
<a href="https://gitter.im/valentineus/iii-client">
|
2017-09-29 01:09:32 +04:00
|
|
|
<img alt="Gitter Badge" src="https://badges.gitter.im/Join%20Chat.svg">
|
|
|
|
</a>
|
|
|
|
</p>
|
2017-05-29 01:46:00 +03:00
|
|
|
|
|
|
|
Simple API for communicating with the bot of the \"iii.ru\" service.
|
|
|
|
|
|
|
|
## Features
|
|
|
|
- A small and light library.
|
2017-09-29 01:09:32 +04:00
|
|
|
- Works, both in NodeJS, and in the browser.
|
|
|
|
- Getting session ID.
|
|
|
|
- Sending and receiving messages.
|
|
|
|
- Does not process incoming errors.
|
2017-05-29 01:46:00 +03:00
|
|
|
|
|
|
|
## Installation
|
2017-09-28 21:28:18 +04:00
|
|
|
NodeJS:
|
2017-05-29 01:46:00 +03:00
|
|
|
```bash
|
|
|
|
npm install --save iii-client
|
|
|
|
```
|
|
|
|
|
2017-09-28 21:28:18 +04:00
|
|
|
Browser:
|
|
|
|
```html
|
|
|
|
<script src="https://unpkg.com/iii-client@latest/dist/bundle.js">
|
2017-09-29 01:09:32 +04:00
|
|
|
/* iiiClient - This is the global name for accessing the package */
|
2017-09-28 21:28:18 +04:00
|
|
|
</script>
|
|
|
|
```
|
|
|
|
|
2017-05-29 01:46:00 +03:00
|
|
|
## Using
|
2017-06-04 19:03:38 +00:00
|
|
|
An example of a connection, receiving session identification and sending a bot message:
|
2017-05-29 01:46:00 +03:00
|
|
|
```javascript
|
2017-09-29 01:09:32 +04:00
|
|
|
import { connect, send } from 'iii-client';
|
|
|
|
|
|
|
|
var uuid = '109cd867-0ef3-4473-af71-7543a9b2fccd';
|
|
|
|
var text = 'Hello, World!';
|
|
|
|
|
|
|
|
/* We connect to the system and get a session */
|
|
|
|
connect(uuid, (request) => {
|
|
|
|
console.info(`Session: ${request}`);
|
|
|
|
/* Send the message and process the response */
|
|
|
|
if (request.result) {
|
|
|
|
var cuid = request.result.cuid;
|
|
|
|
send(cuid, text, (answer) => {
|
|
|
|
console.info(`Answer: ${answer}`);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
2017-05-29 01:46:00 +03:00
|
|
|
```
|
|
|
|
|
|
|
|
## API
|
2017-09-29 01:09:32 +04:00
|
|
|
## Functions
|
|
|
|
<dl>
|
|
|
|
<dt>
|
|
|
|
<a href="#connect">connect(uuid, callback)</a>
|
|
|
|
</dt>
|
|
|
|
<dd>
|
|
|
|
<p>Connection to the service and retrieves the session identifier.</p>
|
|
|
|
</dd>
|
|
|
|
<dt>
|
|
|
|
<a href="#send">send(cuid, text, callback)</a>
|
|
|
|
</dt>
|
|
|
|
<dd>
|
|
|
|
<p>Sends a message to bot and returns a response.</p>
|
|
|
|
</dd>
|
|
|
|
</dl>
|
|
|
|
|
|
|
|
<a name="connect"></a>
|
|
|
|
|
|
|
|
## connect(uuid, callback)
|
|
|
|
Connection to the service and retrieves the session identifier.
|
2017-07-29 04:39:18 +04:00
|
|
|
|
|
|
|
| Param | Type | Description |
|
|
|
|
| --- | --- | --- |
|
2017-09-29 01:09:32 +04:00
|
|
|
| uuid | <code>String</code> | Bot ID |
|
|
|
|
| callback | <code>function</code> | Function handler |
|
2017-07-29 04:39:18 +04:00
|
|
|
|
2017-09-29 01:09:32 +04:00
|
|
|
<a name="send"></a>
|
2017-07-29 04:39:18 +04:00
|
|
|
|
2017-09-29 01:09:32 +04:00
|
|
|
## send(cuid, text, callback)
|
|
|
|
Sends a message to bot and returns a response.
|
2017-05-29 01:46:00 +03:00
|
|
|
|
2017-07-29 04:39:18 +04:00
|
|
|
| Param | Type | Description |
|
|
|
|
| --- | --- | --- |
|
2017-09-29 01:09:32 +04:00
|
|
|
| cuid | <code>String</code> | Session ID |
|
|
|
|
| text | <code>String</code> | Send messages |
|
|
|
|
| callback | <code>function</code> | Function handler |
|
2017-06-05 16:38:03 +00:00
|
|
|
|
2017-05-29 01:46:00 +03:00
|
|
|
## License
|
2017-05-30 16:03:39 +03:00
|
|
|
[](https://github.com/eslint/eslint)
|
2017-05-29 07:02:09 +03:00
|
|
|
|
2017-07-29 04:39:18 +04:00
|
|
|
[MIT](LICENSE.md).
|
|
|
|
Copyright (c)
|
|
|
|
[Valentin Popov](https://valentineus.link/).
|