Загрузка...

Не работает (Node JS)

Тема в разделе Node.js создана пользователем MrPesic 8 сен 2019. 556 просмотров

  1. MrPesic
    MrPesic Автор темы 8 сен 2019 22 31 мар 2019
    Код

    const VKCOINAPI = require('node-vkcoinapi');
    const vkcoin = new VKCOINAPI(options);
    key: "",
    userId: ,
    token: "",
    });
    const { VK } = require('vk-io');
    const vk = new VK();
    const commands = [];
    const utils = {
    sp: (int) => {
    int = int.toString();
    return int.split('').reverse().join('').match(/[0-9]{1,3}/g).join(',').split('').reverse().join('');
    },
    rn: (int, fixed) => {
    if (int === null) return null;
    if (int === 0) return '0';
    fixed = (!fixed || fixed < 0) ? 0 : fixed;
    let b = (int).toPrecision(2).split('e'),
    k = b.length === 1 ? 0 : Math.floor(Math.min(b[1].slice(1), 14) / 3),
    c = k < 1 ? int.toFixed(0 + fixed) : (int / Math.pow(10, k * 3) ).toFixed(1 + fixed),
    d = c < 0 ? c : Math.abs(c),
    e = d + ['', 'тыс', 'млн', 'млрд', 'трлн'][k];
    e = e.replace(/e/g, '');
    e = e.replace(/\+/g, '');
    e = e.replace(/Infinity/g, 'ДОХЕРА');
    return e;
    },
    gi: (int) => {
    int = int.toString();
    let text = ``;
    for (let i = 0; i < int.length; i++)
    {
    text += `${int[i]}&#8419;`;
    }
    return text;
    },
    decl: (n, titles) => { return titles[(n % 10 === 1 && n % 100 !== 11) ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2] },
    random: (x, y) => {
    return y ? Math.round(Math.random() * (y - x)) + x : Math.round(Math.random() * x);
    },
    pick: (array) => {
    return array[utils.random(array.length - 1)];
    }
    }
    let users = require('./users.json');
    let buttons = [];
    setInterval(async () => {
    await saveUsers();
    console.log('«Аккаунты сохранены»');
    }, 15000);

    async function saveUsers()
    {
    require('fs').writeFileSync('mineru/users.json', JSON.stringify(users, null, '\t'));
    return true;
    }
    vk.setOptions({ token: '', pollingGroupId: });
    const { updates, snippets } = vk;
    updates.startPolling();
    updates.on('message', async (message) => {
    stats.messages.inbox += 1;
    if(Number(message.senderId) <= 0) return;
    if(/\[club180690577\|(.*)\]/i.test(message.text)) message.text = message.text.replace(/\[club180690577\|(.*)\]/ig, '').trim();
    if(!users.find(x=> x.id === message.senderId))
    {
    const [user_info] = await vk.api.users.get({ user_id: message.senderId });
    const date = new Date();
    users.push({
    id: message.senderId,
    uid: users.length,
    vk: message.user,
    balance: 0,
    loc: 0,
    click: 1,
    up: {
    cursor: 0,
    cursor_count: 0,
    bcursor: 0,
    bcursor_count: 0,
    mishka: 0,
    mishka_count: 0,
    smishka: 0,
    smishka_count: 0,
    kolonka: 0,
    kolonka_count: 0,
    printer: 0,
    printer_count: 0
    },
    admin: 0,
    referal: null,
    mention: true,
    ban: false,
    work: 0,
    workenergy: 5,
    stag: 0,
    regDate: getUnix(),
    timers: {
    bonus: false
    },
    modules:
    {
    "1": {
    price: 50,
    count: 0,
    profit: 1
    },
    "2": {
    price: 1400,
    count: 0,
    profit: 2
    },
    "3": {
    price: 2500,
    count: 0,
    profit: 3
    },
    "4": {
    price: 5000,
    count: 0,
    profit: 4
    },
    "5": {
    price: 10250,
    count: 0,
    profit: 6
    },
    "6": {
    price: 15000,
    count: 0,
    profit: 8
    },
    "7": {
    price: 40000,
    count: 0,
    profit: 10
    }
    },
    tag: user_info.first_name
    });
    }
    message.user = users.find(x=> x.id === message.senderId);
    if(message.user.ban) return;
    const bot = (text, params) => {
    return message.send(`${message.user.mention ? `@id${message.user.id} (${message.user.tag})` : `${message.user.tag}`}, ${text}`, params);
    }
    const command = commands.find(x=> x[0].test(message.text));
    if(!command) return;

    message.args = message.text.match(command[0]);
    await command[1](message, bot);
    console.log(`Пользователь ${utils.sp(message.user.uid)}: ${message.text}`)
    });
    function getUnix() {
    return Date.now();
    }
    function unixStamp(stamp) {
    let date = new Date(stamp),
    year = date.getFullYear(),
    month = date.getMonth() + 1,
    day = date.getDate(),
    hour = date.getHours() < 10 ? "0"+date.getHours() : date.getHours(),
    mins = date.getMinutes() < 10 ? "0"+date.getMinutes() : date.getMinutes(),
    secs = date.getSeconds() < 10 ? "0"+date.getSeconds() : date.getSeconds();
    return `${day}.${month}.${year}, ${hour}:${mins}:${secs}`;
    }
    function unixStampLeft(stamp) {
    stamp = stamp / 1000;
    let s = stamp % 60;
    stamp = ( stamp - s ) / 60;
    let m = stamp % 60;
    stamp = ( stamp - m ) / 60;
    let h = ( stamp ) % 24;
    let d = ( stamp - h ) / 24;
    let text = ``;
    if(d > 0) text += Math.floor(d) + " д. ";
    if(h > 0) text += Math.floor(h) + " ч. ";
    if(m > 0) text += Math.floor(m) + " мин. ";
    if(s > 0) text += Math.floor(s) + " с.";
    return text;
    }
    setInterval(function(){
    for (i=0;i<users.length;i++) {
    let u = users[i];
    if (u) {
    u.balance += Number(u.modules['1'].profit * u.modules['1'].count);
    u.balance += Number(u.modules['2'].profit * u.modules['2'].count);
    u.balance += Number(u.modules['3'].profit * u.modules['3'].count);
    u.balance += Number(u.modules['4'].profit * u.modules['4'].count);
    u.balance += Number(u.modules['5'].profit * u.modules['5'].count);
    u.balance += Number(u.modules['6'].profit * u.modules['6'].count);
    u.balance += Number(u.modules['7'].profit * u.modules['7'].count);
    }
    }
    }, 1000);
    const cmd = {
    hear: (p, f) => {
    commands.push([p, f]);
    }
    }
    cmd.hear(/^(?:поиск)(\shttps\:\/\/vk\.com\/)?(id)?([0-9]+)?([^]+)?$/i, async (message, args, bot) => {
    if(message.user.admin < 1) return message.send(`[ERROR]`);
    if(message.args[3]){
    let user = users.find(x=> x.id === Number(message.args[3]));
    return message.send(`
    ➖ Игрок: ${user.tag}
    ➖ ID: ${user.uid}
    VK: vk.com/id${user.id}
    Баланс: ${utils.sp(user.balance)} VKC
    `);
    }else{
    if(!message.args[4]) return message.send(`Укажите данные`);
    var domain = message.args[4].split(" ");
    vk.api.call("utils.resolveScreenName", {
    screen_name: message.args[4]
    }).then((res) => {
    let user = users.find(x=> x.id === Number(res.object_id));
    return message.send(`
    ➖ Игрок: ${user.tag}
    ➖ ID: ${user.uid}
    VK: vk.com/id${user.id}
    Баланс: ${utils.sp(user.balance)} VKC.`)
    })
    return;
    }

    });
    cmd.hear(/(?:« Назад|назад|меню|начать|start|помощь|@public181548840 « Назад|@public181548840 Назад|┇┇ Назад)$/i, async (message, bot) => {
    await bot(`мои команды:
     ┇┇ Профиль - ваша статистика.
     ┇┇ Вывод [coins] - вывод VKCOIN.
     ┇┇ Клик - сделать клик.
     ┇┇ Топ - топ игроков по кликам.
     ┇┇ Передать [Bot-ID] [coins] - перевод коинов.
     ┇┇ Магазин - магазин ресурсов.
     ┇┇ Бот - информация о боте.
     ┇┇ Курс - курс coins для вывода.
     ┇┇ Ускорения - магазин ускорений.
     ┇┇ Работы - список работ
     ┇┇ Улучшения - список улучшений.`,
    {
    keyboard:JSON.stringify(
    {
    "one_time": false,
    "buttons": [
    [{
    "action": {
    "type": "text",
    "payload": "{\"button\": \"1\"}",
    "label": "┇┇"
    },
    "color": "positive"
    },
    {
    "action": {
    "type": "text",
    "payload": "{\"button\": \"2\"}",
    "label": "┇┇ Профиль"
    },
    "color": "primary"
    },
    {
    "action": {
    "type": "text",
    "payload": "{\"button\": \"3\"}",
    "label": "┇┇ Магазин"
    },
    "color": "primary"
    },
    {
    "action": {
    "type": "text",
    "payload": "{\"button\": \"3\"}",
    "label": "┇┇ Вывод"
    },
    "color": "negative"
    },
    ]
    ]
    })
    });
    });

    cmd.hear(/(?:Профиль|┇┇ Профиль)$/i, async (message, bot) => {
    let text = ``;
    text += `┇┇ Игровой ID: ${message.user.uid}\n`;
    text += `┇┇ Баланс: ${utils.sp(message.user.balance)} VKC \n`;
    text += `┇┇ За клик: ${utils.sp(message.user.click)} VKC\n\n`
    text += ("┇┇ Регистрация в боте: " + unixStamp(message.user.regDate));
    if(message.user.up.cursor || message.user.up.bcursor || message.user.up.mishka || message.user.up.smishka || message.user.up.kolonka ||
    message.user.up.printer)
    {
    text += `\n┇Улучшения к кликам┇\n`;
    if(message.user.up.cursor) text += `&#4448;┇┇ Курсор (${utils.sp(message.user.up.cursor_count)}x)\n`;
    if(message.user.up.bcursor) text += `&#4448;┇┇ Большой курсор (${utils.sp(message.user.up.bcursor_count)}x)\n`;
    if(message.user.up.mishka) text += `&#4448;┇┇ Мышка (${utils.sp(message.user.up.mishka_count)}x)\n`;
    if(message.user.up.smishka) text += `&#4448;┇┇ Супер мышка (${utils.sp(message.user.up.smishka_count)}x)\n`;
    if(message.user.up.kolonka) text += `&#4448;┇┇ Колонка (${utils.sp(message.user.up.kolonka_count)}x)\n`;
    if(message.user.up.printer) text += `&#4448;┇┇ Принтер (${utils.sp(message.user.up.printer_count)}x)\n`;
    }
    if(message.user.modules["1"].count || message.user.modules["2"].count || message.user.modules["3"].count || message.user.modules["4"].count || message.user.modules["5"].count ||
    message.user.modules["6"].count || message.user.modules["7"].count)
    {
    text += `\n┇Ускорения к кликам┇\n`;
    if(message.user.modules["1"].count) text += `┇┇ Курсор [${message.user.modules["1"].count}] +${message.user.modules["1"].count*1}/сек\n`;
    if(message.user.modules["2"].count) text += `┇┇ Видеокарта [${message.user.modules["2"].count}] +${message.user.modules["2"].count*2}/сек\n`;
    if(message.user.modules["3"].count) text += `┇┇ Стойка Видеокарт [${message.user.modules["3"].count}] +${message.user.modules["3"].count*3}/сек\n`;
    if(message.user.modules["4"].count) text += `┇┇ Суперкомпьютер [${message.user.modules["4"].count}] +${message.user.modules["4"].count*4}/сек\n`;
    if(message.user.modules["5"].count) text += `┇┇ Сервер ВКонтакте [${message.user.modules["5"].count}] +${message.user.modules["5"].count*6}/сек\n`;
    if(message.user.modules["6"].count) text += `┇┇ Квантовый компьютер [${message.user.modules["6"].count}] +${message.user.modules["6"].count*8}/сек\n`;
    if(message.user.modules["7"].count) text += `┇┇ Датацентр [${message.user.modules["7"].count}] +${message.user.modules["7"].count*10}/сек\n\n`;
    text += `┇┇ В сумме: ${(message.user.modules["1"].count*1)+(message.user.modules["2"].count*2)+(message.user.modules["3"].count*3)+(message.user.modules["4"].count*4)+(messag
    [IMG]
     
  2. Help
    Help 8 сен 2019 469 12 май 2017
    userId: , заменить на: userId: "",

    key: "",

    userId: "",

    token: "",
    в этих строках нужно поставить свои данные
     
  3. MrPesic
    MrPesic Автор темы 8 сен 2019 22 31 мар 2019
    Help, делал так, не работает
    --- Сообщение объединено с предыдущим 8 сен 2019
    Help, скриншот посмотрите
     
  4. Help
    Help 8 сен 2019 469 12 май 2017
    MrPesic, ЧТо то не так делал или скрипт не работает. В консоли ошибка на 4 строке. А в вашем коде на 3
     
  5. MrPesic
    MrPesic Автор темы 8 сен 2019 22 31 мар 2019
    Help, у меня не работают даже официальные боты от vk coin
     
  6. Hebun
    Hebun 8 сен 2019 131 20 дек 2016
    Так добычу убрали, как они работать будут?
     
  7. MrPesic
    MrPesic Автор темы 8 сен 2019 22 31 мар 2019
    Hebun, это бот для группы
     
  8. AlexBrin
    AlexBrin 9 сен 2019 Фанат Daemon'а 121 8 апр 2019
    javascript

    const VKCOINAPI = require('node-vkcoinapi');
    const vkcoin = new VKCOINAPI({
    key: "",
    userId: "",
    token: ""
    });
     
Загрузка...
Top