vk-bot-api
Advanced tools
Comparing version 1.4.7 to 2.0.0
{ | ||
"name": "vk-bot-api", | ||
"version": "1.4.7", | ||
"description": "Tool to make VK chat bots", | ||
"main": "./lib/vk.js", | ||
"keywords": [ | ||
"vk", | ||
"чат бот", | ||
"бот", | ||
"bot", | ||
"вк", | ||
"vk api" | ||
], | ||
"version": "2.0.0", | ||
"description": "", | ||
"main": "index.js", | ||
"scripts": { | ||
"prepublish": "./node_modules/.bin/babel -d ./lib src", | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"author": "Vitaly Volynsky <vitalya147@ya.ru>", | ||
"license": "MIT", | ||
"devDependencies": { | ||
"babel-cli": "^6.16.0", | ||
"babel-preset-latest": "^6.16.0", | ||
"eslint": "^3.8.1", | ||
"eslint-config-standard": "^6.2.0", | ||
"eslint-plugin-promise": "^3.3.0", | ||
"eslint-plugin-standard": "^2.0.1" | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/npm/deprecate-holder.git" | ||
}, | ||
"dependencies": { | ||
"eventemitter3": "^2.0.2", | ||
"request": "^2.75.0", | ||
"request-promise": "^4.1.1" | ||
} | ||
"author": "", | ||
"license": "ISC", | ||
"bugs": { | ||
"url": "https://github.com/npm/deprecate-holder/issues" | ||
}, | ||
"homepage": "https://github.com/npm/deprecate-holder#readme" | ||
} |
102
README.md
@@ -1,101 +0,5 @@ | ||
## vk-bot-api | ||
Библиотека для создания чат-ботов ВК. | ||
# Deprecated Package | ||
## Установка | ||
```sh | ||
npm i --save vk-bot-api | ||
``` | ||
## Получение токена | ||
``` | ||
https://oauth.vk.com/authorize?client_id= ID ВАШЕГО ПРИЛОЖЕНИЯ &scope=messages,photos&redirect_uri=http://oauth.vk.com/blank.html&response_type=token | ||
``` | ||
Права доступа: | ||
This package is no longer supported and has been deprecated. To avoid malicious use, npm is hanging on to the package name. | ||
| Право доступа | Зачем | | ||
| ------------- | ----- | | ||
| messages | Отправка, прием сообщений | | ||
| photos | Загрузка фотографий | | ||
Данные права обязательны, но можно добавить еще дабы расширить функционал бота | ||
## Пример использования | ||
```js | ||
var VkBotApi = require('vk-bot-api') | ||
var bot = new VkBotApi({ | ||
token: '<VK_TOKEN>', | ||
prefix: /бот/i | ||
}) | ||
// создаем команду "дуров онлайн?" | ||
bot.onText(/дуров онлайн\?/i, msg => { | ||
bot.API.call('users.get', { // запрашиваем информацию о Дурове из VK API | ||
user_ids: 1, | ||
fields: 'online' | ||
}).then(users => { | ||
var durov = users[0] | ||
bot.sendMessage(msg, durov.online ? 'Да' : 'Нет') | ||
}) | ||
}) | ||
``` | ||
## Конструктор бота | ||
Создает событие `message`, когда приходит новое сообщение для бота, `unhalded`, когда приходят собщения, на которые не сработал ни один обработчик сообщений и дополнительные события `chat_create`, `chat_title_update`, `chat_photo_update`, `chat_invite_user`, `chat_kick_user` (для бесед) | ||
Параметры: | ||
| Параметр |Описание | Тип | По умолчанию | | ||
|-----------|---------|-----|--------------| | ||
| token | Токен | Строка | | | ||
| v | Используемая версия VK API | Число | 5 | | ||
| chats | Список id чатов и пользователей, на сообщения которых бот будут отвечать. Если не указывать, то будет отвечать на все сообщения. ID беседы = 2e9 + номер беседы. <br> Например, если указать `[1, 2e9+12]`, то бот будет отвечать только на сообщения Дурова и чата #12 | Массив | Пуст | | ||
| prefix | Имя бота, с которого должны начинаться сообщения. Если не указывать, то будет отвечать на все сообщения. | Регулярное выражение | | | ||
| timeout | Таймаут для обращений к VK API. | Число | 5 | | ||
| prefixOnlyForGroups | Если true, то префикс будет проверяться только в беседах, а в диалогах с пользователями будет отвечать на все | Логический | false | ||
| LPMessages | Если true, то сообщения будут приходить не в виде [объекта сообщения](https://vk.com/dev/message), а в виде [массива, который присылает LongPoll - сервер](https://vk.com/dev/using_longpoll). Иначе, бот сначала получит объект используя API. | Логический | false | | ||
## Запросы к VK API | ||
В примере выше вы могли заметить, что мы воспользовались методом Vk API. Запросы делаются так: | ||
```js | ||
bot.API.call('метод', { | ||
ключ: значение | ||
}) | ||
``` | ||
## Создание команд | ||
Для этого используется функция `onText`, принимающая два параметра: | ||
* RegExp, содержащий команду | ||
* Функция, которая выполняется при совпадении | ||
```js | ||
bot.onText(/погода (.*)/, (msg, match) => { | ||
// получаем погоду... | ||
bot.sendMessage(msg, 'В городе ' + match[1] + 'тепло') | ||
}) | ||
``` | ||
## Отправка сообщений | ||
Параметры: | ||
| Параметр |Описание | | ||
|-----------|---------| | ||
| peer_id | [`peer_id`](https://vk.com/dev/messages.send) | | ||
| message | Текст сообщения | | ||
| params | Объект с дополнительными параметрами | ||
```js | ||
bot.sendMessage(2e9 + 12, 'Привет с:', { | ||
'attachment': 'photo100172_166443618' | ||
}) | ||
``` | ||
## Загрузка фотографий | ||
Выполняется с помощью функции uploadPhoto. | ||
В качестве параметра принимается адрес файла, возвращает объект фотографии (см. [photos.saveMessagesPhoto](https://vk.com/dev/photos.saveMessagesPhoto)). | ||
```js | ||
bot.uploadPhoto('/home/user/kittens.png') // путь к файлу | ||
.then(photo => { | ||
// творим магию | ||
}) | ||
``` | ||
Please contact support@npmjs.com if you have questions about this package. |
Empty package
Supply chain riskPackage does not contain any code. It may be removed, is name squatting, or the result of a faulty package publish.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No contributors or author data
MaintenancePackage does not specify a list of contributors or an author in package.json.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
0
0
1
0
672
2
0
6
3
- Removedeventemitter3@^2.0.2
- Removedrequest@^2.75.0
- Removedrequest-promise@^4.1.1
- Removedajv@6.12.6(transitive)
- Removedasn1@0.2.6(transitive)
- Removedassert-plus@1.0.0(transitive)
- Removedasynckit@0.4.0(transitive)
- Removedaws-sign2@0.7.0(transitive)
- Removedaws4@1.12.0(transitive)
- Removedbcrypt-pbkdf@1.0.2(transitive)
- Removedbluebird@3.7.2(transitive)
- Removedcaseless@0.12.0(transitive)
- Removedcombined-stream@1.0.8(transitive)
- Removedcore-util-is@1.0.2(transitive)
- Removeddashdash@1.14.1(transitive)
- Removeddelayed-stream@1.0.0(transitive)
- Removedecc-jsbn@0.1.2(transitive)
- Removedeventemitter3@2.0.3(transitive)
- Removedextend@3.0.2(transitive)
- Removedextsprintf@1.3.0(transitive)
- Removedfast-deep-equal@3.1.3(transitive)
- Removedfast-json-stable-stringify@2.1.0(transitive)
- Removedforever-agent@0.6.1(transitive)
- Removedform-data@2.3.3(transitive)
- Removedgetpass@0.1.7(transitive)
- Removedhar-schema@2.0.0(transitive)
- Removedhar-validator@5.1.5(transitive)
- Removedhttp-signature@1.2.0(transitive)
- Removedis-typedarray@1.0.0(transitive)
- Removedisstream@0.1.2(transitive)
- Removedjsbn@0.1.1(transitive)
- Removedjson-schema@0.4.0(transitive)
- Removedjson-schema-traverse@0.4.1(transitive)
- Removedjson-stringify-safe@5.0.1(transitive)
- Removedjsprim@1.4.2(transitive)
- Removedlodash@4.17.21(transitive)
- Removedmime-db@1.52.0(transitive)
- Removedmime-types@2.1.35(transitive)
- Removedoauth-sign@0.9.0(transitive)
- Removedperformance-now@2.1.0(transitive)
- Removedpsl@1.9.0(transitive)
- Removedpunycode@2.3.1(transitive)
- Removedqs@6.5.3(transitive)
- Removedrequest@2.88.2(transitive)
- Removedrequest-promise@4.2.6(transitive)
- Removedrequest-promise-core@1.1.4(transitive)
- Removedsafe-buffer@5.2.1(transitive)
- Removedsafer-buffer@2.1.2(transitive)
- Removedsshpk@1.18.0(transitive)
- Removedstealthy-require@1.1.1(transitive)
- Removedtough-cookie@2.5.0(transitive)
- Removedtunnel-agent@0.6.0(transitive)
- Removedtweetnacl@0.14.5(transitive)
- Removeduri-js@4.4.1(transitive)
- Removeduuid@3.4.0(transitive)
- Removedverror@1.10.0(transitive)