node-vk-bot-api
Advanced tools
Comparing version 2.0.5 to 2.1.0
@@ -39,4 +39,5 @@ const axios = require('axios') | ||
} catch (err) { | ||
throw new Error(err) | ||
this.longPollParams = null | ||
this.startPolling(timeout) | ||
} | ||
} |
@@ -38,2 +38,5 @@ class Stage { | ||
}, | ||
selectStep: (index) => { | ||
ctx.session.__scene.step = index | ||
} | ||
} | ||
@@ -40,0 +43,0 @@ |
{ | ||
"name": "node-vk-bot-api", | ||
"version": "2.0.5", | ||
"version": "2.1.0", | ||
"description": "🤖 Vk bot framework for Node.js", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -125,5 +125,5 @@ [![node-vk-bot-api](https://img.shields.io/npm/v/node-vk-bot-api.svg?style=flat-square)](https://www.npmjs.com/package/node-vk-bot-api/) | ||
* [.reply(message, attachment, keyboard, sticker)](#replymessage-attachment-keyboard-sticker) | ||
* [.reply(message, attachment, markup, sticker)](#replymessage-attachment-keyboard-sticker) | ||
### .reply(message, attachment, keyboard, sticker) | ||
### .reply(message, attachment, markup, sticker) | ||
@@ -140,34 +140,34 @@ Helper method for reply to the current user. | ||
Add keyboard in message. | ||
### Keyboards | ||
```javascript | ||
const VkBot = require('node-vk-bot-api') | ||
const Markup = require('node-vk-bot-api/lib/markup') | ||
* `Markup.keyboard(buttons)`: Create keyboard | ||
* `Markup.button(label, color, payload)`: Create custom button | ||
* `Markup.oneTime()`: Set oneTime to keyboard | ||
const bot = new VkBot({ | ||
token: process.env.TOKEN, | ||
group_id: process.env.GROUP_ID, | ||
}) | ||
#### Simple usage | ||
bot.command('/sport', (ctx) => { | ||
ctx.reply('Select your sport', null, Markup | ||
.keyboard([ | ||
'Football', | ||
'Basketball', | ||
]) | ||
.oneTime()) | ||
}) | ||
```js | ||
ctx.reply('Select your sport', null, Markup | ||
.keyboard([ | ||
'Football', | ||
'Basketball', | ||
]) | ||
.oneTime() | ||
) | ||
``` | ||
bot.command('/mood', (ctx) => { | ||
ctx.reply('How are you doing?', null, Markup | ||
.keyboard([ | ||
[ | ||
Markup.button('Normally', 'primary'), | ||
], | ||
[ | ||
Markup.button('Fine', 'positive'), | ||
Markup.button('Bad', 'negative'), | ||
], | ||
])) | ||
}) | ||
#### Advanced usage | ||
```js | ||
ctx.reply('How are you doing?', null, Markup | ||
.keyboard([ | ||
[ | ||
Markup.button('Normally', 'primary'), | ||
], | ||
[ | ||
Markup.button('Fine', 'positive'), | ||
Markup.button('Bad', 'negative'), | ||
], | ||
]) | ||
) | ||
``` | ||
@@ -267,5 +267,2 @@ | ||
* `constructor(...scenes)`: Register scenes | ||
* `enter(name)`: Enter in scene | ||
* `leave()`: Leave from scene | ||
* `next()`: Go to the next step in scene | ||
@@ -276,4 +273,13 @@ #### Scene | ||
#### Context | ||
```js | ||
ctx.scene.enter(name) // Enter in scene | ||
ctx.scene.leave() // Leave from scene | ||
ctx.scene.next() // Go to the next step in scene | ||
ctx.scene.selectStep(index) // Go to the selected step in scene | ||
``` | ||
## License | ||
MIT. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
18656
417
282