Skip to content

Commit b14428f

Browse files
committed
doc: update docs
1 parent 471ba96 commit b14428f

File tree

4 files changed

+29
-39
lines changed

4 files changed

+29
-39
lines changed

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,25 @@ A **Query Engine** for building interactive prompts.
66
[![Supported Node.js Versions](https://img.shields.io/badge/node->=7-green.svg)](https://github.com/forfuturellc/mau)
77

88

9-
**table of contents:**
9+
**Table of Contents**
1010

11-
* [installation](#installation)
12-
* [examples](example/README.md)
13-
* [API reference](doc/api.md)
11+
* [Installation](#installation)
12+
* [Examples](example/README.md)
13+
* [API Reference](doc/api.md)
1414
* [Specifications](doc/spec.md)
15-
* [license](#license)
15+
* [License](#license)
1616

1717

1818
<a name="installation"></a>
19-
## installation:
19+
## Installation
2020

2121
```bash
2222
$ npm install --save mau
2323
```
2424

2525

2626
<a name="license"></a>
27-
## license:
27+
## License
2828

2929
***The MIT License (MIT)***
3030

doc/api.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -213,14 +213,14 @@ formset.processForm(name, 12345, ref);
213213
**Example** *(FormNotFoundError)*
214214
```js
215215
// Assuming there's no form with the name '404'.
216-
formset.processForm("404", chatID, ref, function(error) {
216+
formset.processForm("404", chatID, ref).catch(function(error) {
217217
assert.ok(error instanceof mau.errors.FormNotFoundError);
218218
});
219219
```
220220
**Example** *(BusyError)*
221221
```js
222222
// Assuming there's a form already being processed.
223-
formset.processForm(name, chatID, ref, function(error) {
223+
formset.processForm(name, chatID, ref).catch(function(error) {
224224
assert.ok(error instanceof mau.errors.BusyError);
225225
});
226226
```
@@ -247,15 +247,13 @@ which if not found, a `FormNotFoundError` error is thrown.
247247
**Example**
248248
```js
249249
// Assuming there's a form named 'hello'
250-
try {
251-
await formset.process(chatID, text, ref);
252-
} catch (error) {
253-
if (error && error instanceof mau.errors.FormNotFoundError) {
250+
await formset.process(chatID, text, ref).catch(function (error) {
251+
if (error instanceof mau.errors.FormNotFoundError) {
254252
// There's NO active form.
255253
// Let's trigger the 'hello' form.
256254
await formset.processForm("hello", chatID, text, ref);
257255
}
258-
}
256+
});
259257
```
260258
<a name="FormSet+cancel"></a>
261259

example/README.md

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
## examples:
1+
## Examples
22

33
* [setting up](#setting-up)
44
* [examples](#examples)
55

66

77
<a name="setting-up"></a>
8-
### setting up:
8+
### Setting up
99

1010
Clone this repository:
1111

@@ -24,28 +24,22 @@ $ cd mau/
2424
$ npm install --only=prod
2525
```
2626

27-
Change into the `example/` directory:
27+
Change into the `example/` directory and install some
28+
additional dependencies are required to run the examples:
2829

2930
```bash
31+
# Change directory.
3032
$ cd example/
31-
```
32-
33-
Some additional dependencies are required to run the
34-
examples. You'll need to install them:
35-
36-
```bash
37-
# For ALL examples.
38-
$ npm install tgfancy
3933

40-
# For example #2.
41-
$ npm install http-proxy ngrok
34+
# Install additional dependencies.
35+
$ npm install
4236
```
4337

4438
You will also need [Redis][redis] for example #2.
4539

4640

4741
<a name="examples"></a>
48-
### examples:
42+
### Examples
4943

5044
* [Example #1](#example-1): A single Telegram bot
5145
* [Example #2](#example-2): Multiple Telegram bots
@@ -62,7 +56,7 @@ $ export TELEGRAM_TOKEN=xxxxx
6256

6357
# Run the bot.
6458
# Leave out 'NO_REDIS=1' if you want to use Redis.
65-
$ NO_REDIS=1 node example/telegram.js
59+
$ NO_REDIS=1 node telegram.js
6660
```
6761

6862
**Time to Play**: Send your bot a message.
@@ -81,12 +75,12 @@ to be `6379`. Port can be changed using environment variable
8175
# In a separate shell, start a bot instance
8276
# listening on port 9101.
8377
$ export TELEGRAM_TOKEN=xxxxx
84-
$ node example/telegram.js 9101
78+
$ node telegram.js 9101
8579

8680
# In another separate shell, start another instance
8781
# listening on port 9102.
8882
$ export TELEGRAM_TOKEN=xxxxx
89-
$ node example/telegram.js 9102
83+
$ node telegram.js 9102
9084

9185
# ... Run more instances if you wish ...
9286

@@ -95,7 +89,7 @@ $ node example/telegram.js 9102
9589
# Append the port numbers of any additional instances you have started. Mind the commas.
9690
# Leave out `PROXY_PORT=9100` to have proxy listen on its default port i.e. 9100.
9791
$ export TELEGRAM_TOKEN=xxxxx
98-
$ PROXY_PORT=9100 node example/proxy.js 9101,9102
92+
$ PROXY_PORT=9100 node proxy.js 9101,9102
9993
```
10094

10195
**Time to Play**: Send your bot a message.

lib/formset.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -115,13 +115,13 @@ class FormSet extends EventEmitter {
115115
*
116116
* @example <caption>FormNotFoundError</caption>
117117
* // Assuming there's no form with the name '404'.
118-
* formset.processForm("404", chatID, ref, function(error) {
118+
* formset.processForm("404", chatID, ref).catch(function(error) {
119119
* assert.ok(error instanceof mau.errors.FormNotFoundError);
120120
* });
121121
*
122122
* @example <caption>BusyError</caption>
123123
* // Assuming there's a form already being processed.
124-
* formset.processForm(name, chatID, ref, function(error) {
124+
* formset.processForm(name, chatID, ref).catch(function(error) {
125125
* assert.ok(error instanceof mau.errors.BusyError);
126126
* });
127127
*
@@ -153,15 +153,13 @@ class FormSet extends EventEmitter {
153153
*
154154
* @example
155155
* // Assuming there's a form named 'hello'
156-
* try {
157-
* await formset.process(chatID, text, ref);
158-
* } catch (error) {
159-
* if (error && error instanceof mau.errors.FormNotFoundError) {
156+
* await formset.process(chatID, text, ref).catch(function (error) {
157+
* if (error instanceof mau.errors.FormNotFoundError) {
160158
* // There's NO active form.
161159
* // Let's trigger the 'hello' form.
162160
* await formset.processForm("hello", chatID, text, ref);
163161
* }
164-
* }
162+
* });
165163
*
166164
* @param {String|Number} chatID Unique identifier for the originating
167165
* chat

0 commit comments

Comments
 (0)