hearCommand('test', (context) => {});
// Аналогична данной запись
vk.updates.hear(
[
(text, { state }) => (
state.command === 'test'
),
'/test'
],
(context) => {}
);
hearCommand('test', /test (.+)/i, (context) => {});
// Аналогична данной запись
vk.updates.hear(
[
(text, { state }) => (
state.command === 'test'
),
/test (.+)/i
],
(context) => {}
);
const groupsList = Array(8).fill().map((_, i) => i + 1);
const groups = await Promise.all(groupsList.map(id => (
api.wall.get({
domain: id,
count: 100,
extended: true,
filter: 'others'
})
)));
{
"name": "you-library",
"scripts": {
"prepare": "babel src -d lib"
}
}
fs.readFile("user.data", "utf8", function(error,data){
if(error) throw error;
var obj = JSON.parse(data);
//obj.user.push({name: name, login: login});
console.log(typeof obj); // object
});
<form class="form_buying_product" action="/shop/cart/ajax/update_basket/" method="post">
<input class="value_product_id" type='hidden' value='{{ product.id }}' />
{{ cart_product_form }}
{% csrf_token %}
<button type="submit">Добавить в корзину</button>
</form>
$(function(){
$(document.body).on('click', '.form_buying_product button', function(e) {
e.preventDefault();
const $this = $(this);
const $form = $this.parent('form');
const productId = $form.find('.value_product_id').val();
const token = $form.find('input[name="csrfmiddlewaretoken"]').val();
const data = {
product_id: productId,
csrfmiddlewaretoken: token
};
console.log('Product data', data);
})
});
app.get('/chat/:chat', (req, res) => {
const chat = req.params.chat;
const json = {};
bot.telegram.getChat(chat).then((info) => {
json.success = true;
json.info = info;
res.json(json);
}).catch((error) => {
json.success = false;
json.info.error = error.code;
json.info.method = error.on.method;
json.info.description = error.description;
res.json(json);
});
});
app.get('/chat/:chat', async (req, res) => {
const { chat } = req.params;
const json = {};
try {
const info = await bot.telegram.getChat(chat);
json.success = true;
json.info = info;
} catch (error) {
json.success = false;
json.info.error = error.code;
json.info.method = error.on.method;
json.info.description = error.description;
}
res.json(json);
});