Загрузка...

Mini game script in VK conversation

Thread in Backend created by Alex_85461 Jun 9, 2018. 3473 views

  1. w0rking
    w0rking Jun 9, 2018 work work work 521 Jul 28, 2016
    не робит чет
     
  2. asQ_inactive103103
    asQ_inactive103103 Jun 9, 2018 Banned 187 Apr 15, 2017
  3. WALGED
    WALGED Jun 9, 2018 Чтение это фундамент всех ваших мыслей и идей 2321 Mar 2, 2018
  4. asQ_inactive103103
    asQ_inactive103103 Jun 9, 2018 Banned 187 Apr 15, 2017
    ТС, как фиксить ?
     
  5. gigvabes
    gigvabes Jun 9, 2018 145 May 2, 2018
    та ж ошибка
     
  6. Checkerchin
    Checkerchin Jun 9, 2018 178 Apr 16, 2017
    Походу тс скопипастил и слился)
     
  7. Fockstrot
    Fockstrot Jun 9, 2018 Banned 1466 May 14, 2016
    Скрипт кривой,паста стопудовая,без тестирования,остальные что в наборе есть работают
     
  8. Fockstrot
    Fockstrot Jun 9, 2018 Banned 1466 May 14, 2016
     
  9. Dakosa
    Dakosa Jun 9, 2018 Banned 1144 Jan 1, 2018
    Смысл бота?
     
  10. fak
    fak Jun 9, 2018 Играю с твоей сукой 140 Mar 21, 2017
    Исправил скрипт. Для этого скрипта надо токен добавлять на сайт. Нажмите "О сайте", там написано.
    Code

    let strings = {
    cmd_start: ["дуэль", "драка", "пиздилка", "пизделка", "стрела"],
    wait_opponent: [" кто хочет с ним попиздиться?"],
    accept: ["я", "+","го","Го"],
    accepted: [" согласился(лась) попиздиться с "],
    msg_battle_exists: ["вы уже пиздитесь"],
    msg_winner: [" победил(а) в пиздилке "],
    timeout: [" никто не согласился пиздиться"],
    action_timeout: [" съебался от "],
    actions: [
    ["сделать шишку на лбу", "украсть душу", "ударить по почкам", "поставить подножку","Хуем по лбу провести,грех с души свести!"],
    ["прописать по щам", "сломать ребра", "дать с левой", "свалить на прохожего","Позвать сына маминой подруги"],
    ["обидеться", "Нож в печень", "кинуть помидор", "кончить на лицо"],
    ["укусить", "выколоть глаз", "выпороть", "тыкнуть пальцем", "Разбить бутыль об голову"],
    ["пердануть", "убежать", "отшлепать", "выключить свет", "Вырвать волосы"],
    ["отсосать", "пронзить взглядом", "взять в заложники", "выбить зуб","Щекотать"],
    ["заплакать", "пошутить про мамку", "обосцать", "спрятаться", "Включить мало половин"],
    ["поджопник", "унизить", "наложить проклятье анимешника", "убить", "Вы кто такие, я вас не звал, идите нахуй!"],
    ["сломать иголку об яйцо", "бухнуть", "покурить", "позвонить в 102","Вызвать сатану"],
    ["порезать лук", "оторвать губу", "толкнуть в говно", "сбрить брови","Сделать клизму"],
    ["доказать отсутствие мозга", "написать заявление в полицию", "выкачать мозг", "сломать ноготь","Сломать психику"],
    ["натравить собаку", "облить кипятком", "удалить мозг через компьютер", "задушить туалетной бумагой","Сломать член"],
    ["Посадить на кол", "Послать нахуй", "Насрать в рот", "Адвокаааат", "растянуть очко"],
    ["Кинуть арматуру", "Бездействовать", "Сломать логику ", "Вертеть на хую ","Пирсинг на глаз"],
    ]
    }

    Array.prototype.random = function() {
    return this[Math.floor(Math.random() * this.length)];
    }

    let battles = {};
    let users = {};

    vk.addListener.messages(function(msg) {
    //if (msg.out) return;
    if (msg.chat_id === 0) return;
    if (typeof battles[msg.chat_id] == "undefined") battles[msg.chat_id] = {};
    if (typeof users[msg.user_id] == "undefined") {
    vk.api.users.get({
    user_ids: msg.user_id
    }, function(res) {
    users[msg.user_id] = res.response[0].first_name + " " + res.response[0].last_name;
    handle(msg);
    });
    } else handle(msg);
    });

    function handle(msg) {
    //let args = msg.body.toLowerCase().split(" ");
    let cmd = msg.body.toLowerCase();
    if (typeof battles[msg.chat_id][msg.user_id] != "undefined") {
    battles[msg.chat_id][msg.user_id].setAction(msg);
    } else if (strings.cmd_start.includes(cmd)) {
    if (typeof battles[msg.chat_id][msg.user_id] != "undefined") {
    msg.send(strings.msg_battle_exists.random());
    return;
    }
    if (typeof battles[msg.chat_id].wait != "undefined") accept(msg);
    else create(msg);
    } else if (typeof battles[msg.chat_id][msg.user_id] == "undefined" &&
    typeof battles[msg.chat_id].wait != "undefined" &&
    strings.accept.includes(cmd)) accept(msg);
    }

    function create(msg) {
    battles[msg.chat_id][msg.user_id] = new Battle(msg.chat_id, msg.user_id);
    battles[msg.chat_id].wait = battles[msg.chat_id][msg.user_id];
    msg.send(users[msg.user_id] + strings.wait_opponent.random());
    }

    function accept(msg) {
    battles[msg.chat_id][msg.user_id] = battles[msg.chat_id].wait;
    delete battles[msg.chat_id].wait;
    battles[msg.chat_id][msg.user_id].setOpponent(msg.user_id);
    msg.send(users[msg.user_id] + strings.accepted.random() + users[battles[msg.chat_id][msg.user_id].users[0]]);
    }

    class Battle {
    constructor(chatId, userId) {
    this.chatId = chatId;
    this.users = [userId];
    let instance = this;
    this.timeoutId = setTimeout(function() {
    delete battles[chatId][userId];
    delete battles[chatId].wait;
    instance.message(users[userId] + strings.timeout.random());
    }, 60000);
    }

    setAction(msg) {
    if (this.currentAction == msg.user_id) {
    let index = msg.body.split(" ").shift();
    try {
    index = parseInt(index);
    if (index !== 0 && !isNaN(index)) {
    if (index == this.target[this.getOpponent(msg.user_id)]) this.setWinner(msg.user_id);
    else this.nextAction();
    }
    } catch (e) {}
    }
    }

    setOpponent(userId) {
    this.users.push(userId);
    this.currentAction = this.users.random();
    let cnt = strings.actions.random().length;
    this.target = {};
    this.target[this.users[0]] = Math.floor(Math.random() * cnt);
    this.target[this.users[1]] = Math.floor(Math.random() * cnt);
    this.nextAction();
    }

    nextAction() {
    this.currentAction = this.getOpponent(this.currentAction);
    let msg = users[this.currentAction] + " ебашь\n";
    let actions = strings.actions.random();
    for (let id in actions) {
    if (actions.hasOwnProperty(id)) {
    msg += (parseInt(id) + 1) + " " + actions[id] + "\n";
    }
    }
    clearTimeout(this.timeoutId);
    let chatId = this.chatId;
    let instance = this;
    this.timeoutId = setTimeout(function() {
    delete battles[chatId][instance.users[0]];
    delete battles[chatId][instance.users[1]];
    instance.message(users[instance.currentAction] + strings.action_timeout.random() + users[instance.getOpponent(instance.currentAction)]);
    }, 60000);
    this.message(msg);
    }

    getOpponent(userId) {
    return userId == this.users[0] ? this.users[1] : this.users[0];
    }

    message(text) {
    let chatId = this.chatId;
    vk.api.messages.send({
    chat_id: chatId,
    message: text
    });
    }

    setWinner(userId) {
    clearTimeout(this.timeoutId);
    let chatId = this.chatId;
    delete battles[chatId][this.users[0]];
    delete battles[chatId][this.users[1]];
    let winner = users[userId];
    let looser = users[this.getOpponent(userId)];
    let msg = winner + strings.msg_winner.random() + looser;
    this.message(msg);
    }
    }

    var coin, random;
    coin = ["Иди нахуй!.", "Он тупой еблан", "Ха-ха-ха, иди нахуй. Кхм..."];

    random = function() {
    return coin[Math.floor(Math.random() * coin.length)];
    };


    vk.addListener.messages(function (msg) {
    if (msg.body === "/Go") {
    return msg.reply(random());
    }
    });
     
  11. asQ_inactive103103
    asQ_inactive103103 Jun 9, 2018 Banned 187 Apr 15, 2017
    слушай, а не знаешь как можно самому добавлять новые фразы ?
     
  12. asQ_inactive103103
    asQ_inactive103103 Jun 9, 2018 Banned 187 Apr 15, 2017
    я просто добавил , но когда доходит дело до новых фраз бот ничего не отправляет
     
  13. slime
    slime Jun 9, 2018 Banned 1206 Feb 22, 2017
    замути файлом php с токеном)
     
  14. Fockstrot
    Fockstrot Jun 9, 2018 Banned 1466 May 14, 2016
    Ничего не поменялось,токен добавлен,прогресса ноль
     
  15. Fockstrot
    Fockstrot Jun 9, 2018 Banned 1466 May 14, 2016
    Так скрин дай умник
     
  16. fak
    fak Jun 9, 2018 Играю с твоей сукой 140 Mar 21, 2017
  17. fak
    fak Jun 9, 2018 Играю с твоей сукой 140 Mar 21, 2017
    asQ_inactive103103, просто замени фразы, там скрипт запрограммирован на несколько раундов. Ну или добавь раундов.
     
  18. Slamzer
    Slamzer Jun 9, 2018 Жизнь без цели равноценна медленной смерти. 211 Aug 30, 2017
    Бля , запиши видик )
     
  19. SellerBoy
    SellerBoy Jun 10, 2018 33 May 13, 2018
    Добавляйте меня: *click*
    Буду ботом :D
     
Loading...
Top