Но как защитить сам код?- как вариант, переписать бота на C/C++.
Как в telebot отправлять сообщение определенному пользователю?
Как спарсить json ответ?
Как добавить объект в список json?
Как сделать кнопку с ссылкой в telebot python?
const net = require('net');
const crypto = require('crypto');
const handshake = `GET / HTTP/1.1
Host: 192.168.43.135:12345
Connection: Upgrade
Pragma: no-cache
Cache-Control: no-cache
Upgrade: websocket
Origin: file://
Sec-WebSocket-Version: 13
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36
Accept-Encoding: gzip, deflate, sdch
Accept-Language: zh-CN,zh;q=0.8,en-US;q=0.6,en;q=0.4
Sec-WebSocket-Key: bKdPyn3u98cTfZJSh4TNeQ==
Sec-WebSocket-Extensions: permessage-deflate; client_max_window_bits
`;
const s = net.connect(8080);
s.on('data', d => {
if (/HTTP\/1\.1 101 Switching Protocols/.test(d)) {
s.write(composeFrame('{"type": "handshake"}'));
setTimeout(
() => s.write(composeFrame('{"type":"action", "value":"move"}')),
10000
);
}
});
s.write(handshake);
function composeFrame(text) {
const mask = crypto.randomBytes(4);
return Buffer.from([
0b10000001,
0b10000000 | text.length,
...mask,
...[...Buffer.from(text)].map((e, i) => e ^ mask[i % 4])
]);
}
const arr1 = [
[ 432432, 23423, 123123, 54364346],
[ 756456, 2423423, 645654, 23423423],
[ 12354, 123123, 23423423, 1235765]
]
const arr3 = [ 12354, 5345, 53456346 ]
const arrResult = arr1
.flat(Infinity)
.filter(el => arr3.includes(el))
console.log(arrResult)
// Array [ 12354 ]
const arr1 = [
[ 432432, 23423, 123123, 54364346],
[ 756456, 2423423, 645654, 23423423],
[ 12354, 123123, 23423423, 1235765]
]
const arr3 = [ 12354, 5345, 53456346 ]
const arr1s = arr1.flat(Infinity)
arr1s.sort((a, b) => a - b)
const arr3s = arr3.slice()
arr3s.sort((a, b) => a - b)
const arrResult = []
for (let i = 0, let j = 0; i < arr1s.length, j < arr3s.length;) {
if (arr1s[i] === arr3s[j]) {
arrResult.push(arr1s[i])
i += 1
} else if (arr1s[i] < arr3s[j]) {
i += 1
} else {
j += 1
}
}
console.log(arrResult)
// Array [ 12354 ]
найти последний div
const last = document.querySelector('#container').lastElementChild;
остальные удалить
Array.prototype.reduceRight.call(
document.getElementById('container').children,
(_, n) => n?.nextElementSibling && (n.outerHTML = ''),
null
);
const last = Array
.from(document.querySelectorAll('#container > *'))
.reduce((_, n, i, a) => i === ~-a.length ? n : n.remove(), null);
arr = [[11,22], [33,44]]
console.log ( arr.flat() )