0
mirror of https://github.com/valentineus/iii-client.git synced 2025-04-28 01:41:25 +03:00
iii-client/README.md

78 lines
2.2 KiB
Markdown
Raw Normal View History

2017-05-29 02:27:03 +03:00
# III Client
2017-05-30 16:03:39 +03:00
[![npm](https://img.shields.io/npm/v/iii-client.svg)](https://www.npmjs.com/package/iii-client)
2017-05-29 01:46:00 +03:00
Simple API for communicating with the bot of the \"iii.ru\" service.
2017-07-29 04:39:18 +04:00
**Attention!** At the moment there are difficulties with the `iii.ru` service, there is a possibility that the service will not be restored. All information on the company's
[forum](http://forum.iii.ru/index.php?showtopic=19886).
2017-06-14 22:00:24 +00:00
2017-05-29 01:46:00 +03:00
## Features
- A small and light library.
- Receiving and sending messages.
2017-06-04 19:03:38 +00:00
- Installation and processing of sessions.
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">
/* client - This is the global name for accessing the package */
</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-07-29 04:39:18 +04:00
import client from 'iii-client';
2017-05-29 01:46:00 +03:00
2017-07-29 04:39:18 +04:00
const uuid = '109cd867-0ef3-4473-af71-7543a9b2fccd';
const text = 'Hello, World!';
2017-05-29 01:46:00 +03:00
2017-06-04 19:03:38 +00:00
// We connect to the system and get a session
2017-07-29 04:39:18 +04:00
client.connect(uuid).then(session => {
2017-06-04 19:03:38 +00:00
// Send the message and process the response
2017-07-29 04:39:18 +04:00
client.send(session.cuid, text).then(answer => {
console.info(answer);
2017-06-04 19:03:38 +00:00
});
2017-07-29 04:39:18 +04:00
}).catch(error => console.error(error.message));
2017-05-29 01:46:00 +03:00
```
## API
2017-07-29 04:39:18 +04:00
### Functions
#### connect(uuid)
Connects to the server and returns the connection data.
**Promise**: <code>Object</code> Answer from the server.
**Rejects**: <code>Error</code> If there are errors in operation.
| Param | Type | Description |
| --- | --- | --- |
| uuid | <code>String</code> | The bot ID. |
#### send(cuid, text)
Send a message to the server and return a response.
**Promise**: <code>Object</code> Answer from the server.
**Rejects**: <code>Error</code> If there are errors in operation.
2017-05-29 01:46:00 +03:00
2017-07-29 04:39:18 +04:00
| Param | Type | Description |
| --- | --- | --- |
| cuid | <code>String</code> | Session identifier. |
| text | <code>String</code> | Message text. |
2017-05-29 01:46:00 +03:00
2017-07-29 04:39:18 +04:00
Found out a mistake or feel a lack of functionality?
[issues](https://github.com/valentineus/iii-client/issues)
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
[![JavaScript Style Guide](https://cdn.rawgit.com/feross/standard/master/badge.svg)](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/).