async function delWords(txt, countDeleteWords){
// Возьмем переменную текст как "deleteWord word word"
text += (`Original: ` + txt) // чистая переменная
let filter1 = txt.replace(/\s/g, ",")
text += (`\n\nFilter1: ` + filter1) // deleteWord,word,word
let prefilter = filter1.split(",") // делим все слова на массив: ["deleteWord", "word", "word"]
if(prefilter.length < countDeleteWords){
let err = {
code: 1,
text: "countDeleteWords is too bigger then count words"
}
return err;
} // Обработка ошибки, может кому то надо
let filter2 = prefilter.slice(countDeleteWords) // убираем n слов(-о) в Array
text += (`\n\nfilter2: ` + filter2) // результат word,word
return text; // возвращаем переменную, по необходимости меняем на filter2
}
let filter2 = filter1.split(",").slice(countDeleteWords)
setInterval(function(){
var parent = document.querySelectorAll('.cart_item');
for(let i = 0; i<parent.length; i++){
var elems1 = parent[i].querySelectorAll('.meta_wc');
var elems = parent[i].querySelectorAll('.first_size');
if (elems.innerHTML == '' ) {
elems1.style.display = 'none';
};
}
}, 1000);
vk.updates.on('message', async (message) => {
if(message.attachments){ // проверка на фотки и тп
let att = message.attachments
for(let i = 0; i < att.length; i++){
if(att[i].type == photo){
// фото
} else if(att[i].type == video){
// видео
} // так можно продолжать и дальше.
}
} else {
return;
}
})
function playAudio($url) {
$audio = new Audio();
$audio.src = $url;
return $audio.play();
}
if ( $k_new !=0 && $k_new_fav == 0 ){
echo 'тут уведомление';
$url = "http://freewavesamples.com/files/Yamaha-TG100-Ocarina-C5.wav"
playAudio($url)
}
async function unBan(id, chatid) {
await mongo.models.chatsusers.updateOne({ vkid: Number(id), join_chat: Number(chatid), banned: String(true) }, { $set: { banned: false, bannedTime: "None", bannedReason: "None" } })
}
let timeValue = `1`
let timeUnit = `день`
let seconds = convertToSeconds(timeValue, timeUnit)
let secondsToMilSeconds = seconds * 1000
let chatid = message.chatId
setTimeout(() => {
unBan(id, chatid)
}, secondsToMilSeconds);
function convertToSeconds(timeValue, timeUnit) {
switch (timeUnit) {
case 'день':
return timeValue * 24 * 60 * 60;
case 'час':
return timeValue * 60 * 60;
case 'минута':
return timeValue * 60;
default:
return 0;
}
}
const { VK, Upload, Updates } = require('vk-io');
const { HearManager } = require('@vk-io/hear');
const vk = new VK({
token: "// токен нужно получить в группе"
});
const pollid = `// айди нужно получить в группе`
const bot = new HearManager()
bot.hear(/^(?:Пинг)/i, async message => {
return message.send("ПОНГ")
});
vk.updates.start().catch(console.error)
console.log('VK Polling starting...')
console.log('Polling started')
console.log("Ready! If u see this message all is ok.")