const options = {
typeId,
name,
description,
groupId,
primaryAttribute, // 180
secondaryAttribute, // 181
skillTimeConstant, // 275
requiredSkill1, // 182
requiredSkill1Level, // 277
requiredSkill2, // 183
requiredSkill2Level, // 278
requiredSkill3, // 184
requiredSkill3Level, // 279
};
class Skill {
constructor(options) {
Object.assign(this, options);
}
}
async function test() {
// ...
if (msg.message.text.startsWith('!kick')) {
if (await isAdmin(msg)) {
const str = msg.message.text;
const idStart = str.indexOf(' ');
const idEnd = str.indexOf(' ', idStart + 1);
const id = str.slice(idStart + 2, idEnd);
const reason = str.slice(idEnd + 1);
if ((idStart < 0) || (idEnd < 0) || (id.length === 0) || (reason.length === 0)) {
messagesend('Неверная команда.');
} else {
vk.call('messages.removeChatUser', {
chat_id: msg.message.peer_id - 2000000000,
user_id: id
});
messagesend(`🔫 Был исключен vk.com/${id} | Причина: ${reason}`);
}
} else {
notmessage();
}
}
// ...
}
$(() => {
const imagesPreview = (input, container) => {
if (input.files) {
for (const file of input.files) {
const reader = new FileReader();
reader.onload = e => {
$($.parseHTML('<img>')).attr('src', e.target.result).appendTo(container);
$($.parseHTML('<div>')).text(file.name).appendTo(container);
}
reader.readAsDataURL(file);
}
}
};
$('#gallery-photo-add').on('change', e => imagesPreview(e.currentTarget, 'div.gallery'));
});
#include <stdio.h>
int main()
{
int scanf_res = 0;
double firstNum;
do
{
printf("Enter a NUMBER: ");
fflush(stdin);
scanf_res = scanf("%lf", & firstNum);
}
while (scanf_res == 0);
printf("NUMBER = %f", firstNum);
return 0;
}
const noft = await vk.call('messages.getConversationMembers', {
peer_id: msg.message.peer_id,
fields: 'id, first_name',
group_id: 193658885
});
const longString = noft.items.filter(item => (item.member_id > 0))
.map(item => `[id${item.member_id}|@]`)
.join(' ');
console.log(longString);
// [id590120892|@] [id299403203|@] [id102021723|@]
// ...
const arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
function getRandomRiver(n, arr) {
const indexes = new Set();
const limit = arr.length;
n = Math.min(n, limit);
while (indexes.size < n) {
const index = Math.floor(limit * Math.random());
indexes.add(index);
}
const result = [...indexes].map(index => arr[index]);
return result;
};
const randomSet = getRandomRiver(3, arr);
console.log(randomSet);
function splitOnTwoParts(str) {
const regexp = /\([^\(\)]*\d[^\(\)]*\)/;
const innerStr = str.match(regexp)[0];
const firstPart = innerStr.slice(1, -1);
const secondPart = str.replace(innerStr, '');
return [firstPart, secondPart];
}
splitOnTwoParts("Organix (сухие корма) для собак малых пород, с курицей, Adult Dog Small Breed Chicken (12 кг)");
// ["12 кг", "Organix (сухие корма) для собак малых пород, с курицей, Adult Dog Small Breed Chicken "]
const array = [
{
name: 'Jonh',
age: 32
}, {
name: 'James',
age: 33
}, {
name: 'Jacob',
age: 33
}
];
const key = 'age';
const values = new Set();
const filtredArray = array.filter(item => {
const value = item[key];
if (!values.has(value)) {
values.add(value);
return true;
}
return false;
});
let arr = [1, 2, 3];
console.log(arr);
function clear(arr) {
arr.length = 0;
}
clear(arr);
console.log(arr);
function getDescriptionChain(subCats, id) {
for (const subCat of subCats) {
if (subCat.id === id) {
return [subCat.descr];
} else {
const chain = getDescriptionChain(subCat.sub_cats, id);
if (chain.length > 0) {
return [subCat.descr, ...chain];
}
}
}
return [];
}
const subCats = [
{
"parent_id": null,
"sub_cats": [
{
"parent_id": 472,
"descr": "D",
"level": 1,
"id": 508,
"order": 0,
"sub_cats": [
{
"parent_id": 472,
"sub_cats": [
{
"parent_id": 508,
"sub_cats": [
],
"descr": "FOO",
"level": 2,
"id": 1076,
"order": 0
}
],
"descr": "Bar",
"level": 1,
"id": 345,
"sub_cats_ids": [
]
}
]
},
{
"parent_id": 472,
"descr": "E",
"level": 1,
"id": 490,
"order": 1
}
],
"descr": "A",
"level": 0,
"id": 472,
"order": 0
},
{
"parent_id": null,
"sub_cats": [
],
"descr": "B",
"level": 0,
"id": 544,
"order": 1
}
];
const chain = getDescriptionChain(subCats, 1076);
console.log(chain.join(' > ')); // "A > D > Bar > FOO"