samuri51 / chillybot

a turntable bot created by a moderator of straight_chillin11
12 stars 12 forks source link

Dj Queue Re-add #17

Closed JimmyRehberg closed 11 years ago

JimmyRehberg commented 11 years ago

Hey, is it possible to add something to your code to have it re-add users to the queue once they've reached their play limit and are taken down?

samuri51 commented 11 years ago

you mean automatically for everyone or like an optional thing?

samuri51 commented 11 years ago

i think i could it make it so that theres like a toggle /readdme command, and if you enabled it for yourself you'll be readded when you get off stage, otherwise you won't. would that work?

samuri51 commented 11 years ago

and you only want this to work the play limit too right, not with the normal queue?

JimmyRehberg commented 11 years ago

I always use the playlimit within the queue..so I'd say readd everyone but I'd want to be able to turn it on and off

James

On Mar 19, 2013, at 3:16 PM, chris larosa notifications@github.com wrote:

and you only want this to work the play limit too right, not with the normal queue?

— Reply to this email directly or view it on GitHub.

samuri51 commented 11 years ago

you sure you don't want me to make it individual? wouldn't that be a problem if someone was removed for the limit and didn't want to get back on stage?

JimmyRehberg commented 11 years ago

so what are you thinking..users just type some command to be re-added each time they dj?

James

On Mar 19, 2013, at 3:16 PM, chris larosa notifications@github.com wrote:

and you only want this to work the play limit too right, not with the normal queue?

— Reply to this email directly or view it on GitHub.

samuri51 commented 11 years ago

they type a command to be readded only when they get removed for the play limit, and they type it again to not have that effect. and then maybe i could make an admin readdmeon and off so that you can enable/ disable that option

samuri51 commented 11 years ago

you do know that you can use the play limit without the queue though right?

JimmyRehberg commented 11 years ago

I like it

James

On Mar 19, 2013, at 3:38 PM, chris larosa notifications@github.com wrote:

they type a command to be readded only when they get removed for the play limit, and they type it again to not have that effect. and then maybe i could make an admin readdmeon and off so that you can enable/ disable that option

— Reply to this email directly or view it on GitHub.

JimmyRehberg commented 11 years ago

yes..thank you

James

On Mar 19, 2013, at 3:39 PM, chris larosa notifications@github.com wrote:

you do know that you can use the play limit without the queue though right?

— Reply to this email directly or view it on GitHub.

samuri51 commented 11 years ago

here's the solution i came up with, let me know if you notice any bugs or logic errors i just kind of made this up on the fly.

add these global variables to the top

var READDME = false; //for readdme true = on by default, false = off

global.readded = []; //for readded

add these three commands anywhere in the else if structure

else if (text.match(/^\/readdmeOn/) && condition === true)
{
    readded = [];
    READDME = true;
    bot.speak('readdme is now enabled');
}
else if (text.match(/^\/readdmeOff/) && condition === true)
{
    READDME = true;
    bot.speak('readdme is now disabled');
}
else if (text.match(/^\/readdme/))
{
    if (READDME == true) //if readdme enabled
    {
        if (PLAYLIMIT == true) //if play limit on
        {
            if (queue == true) //if the queue is turned on
            {
                var areTheyReadded = readded.indexOf(data.userid); //are they in the readded array?

                if (areTheyReadded == -1) //no
                {
                    readded.unshift(data.userid);
                    bot.speak('@' + name + ' you will now be readded to the queue after' +
                        ' being removed by the play limit.');
                }
                else if (areTheyReadded != -1) //yes
                {
                    readded.splice(areTheyReadded, 1);
                    bot.speak('@' + name + ' you are no longer being readded to the queue' +
                        ' after being removed by the play limit.');
                }
            }
            else
            {
                bot.pm('error, the queue must be enabled in order for you to be readded to the queue ' +
                    'after being removed for the play limit', data.userid);
            }
        }
        else
        {
            bot.pm('error, the play limit must be active for you to use that feature.', data.userid);
        }
    }
    else
    {
        bot.pm('error, readdme must be enabled in order for you to use this feature, ' +
            'ask an admin for more details', data.userid);
    }
}

change the code in nosong to this, should be somewhere around 664

 if (getonstage === true && vipList.length === 0 && queueList.length === 0)
 {
     bot.addDj();
 }
 skipOn = false;

change the play limit code at the bottom to this, around line 3600

if (READDME == true) //is readdme active?
{
    var areTheyBeingReadded = readded.indexOf(data.room.metadata.current_dj); //are they on the readdme list
    var areTheyInTheQueue = queueList.indexOf(data.room.metadata.current_dj); //are they already in the queue again?
}

if (typeof (djs20[djId]) !== 'undefined')
{
    if (queueList.length != 0) //if theres more than zero people in queue
    {
        if (++djs20[djId].nbSong >= playLimit)
        {
            if (PLAYLIMIT === true) //is playlimit on?
            {
                if (djId == currentDjs[0] && playLimit === 1) //if person is in the far left seat and limit is set to one
                {
                    var checklist33 = theUsersList.indexOf(djId) + 1;
                    bot.speak('@' + theUsersList[checklist33] + ' you are over the playlimit of ' + playLimit + ' song');
                    bot.remDj(djId);
                    if (areTheyBeingReadded != -1 && areTheyInTheQueue == -1 && dj != null && READDME === true) //if they are being readded and they arent in the queue
                    {
                        queueList.push(dj, data.room.metadata.current_dj); //name then userid
                        queueName.push(dj); //name  
                        bot.speak(dj + ' you have been readded to the queue.');
                    }
                }
                else if (djId != USERID && playLimit !== 1) //is not bot, then true
                {
                    var checklist33 = theUsersList.indexOf(djId) + 1;
                    bot.speak('@' + theUsersList[checklist33] + ' you are over the playlimit of ' + playLimit + ' songs');
                    bot.remDj(djId);
                    if (areTheyBeingReadded != -1 && areTheyInTheQueue == -1 && dj != null && READDME === true) //if they are being readded and they arent in the queue
                    {
                        queueList.push(dj, data.room.metadata.current_dj); //name then userid
                        queueName.push(dj); //name  
                        bot.speak(dj + ' you have been readded to the queue.');
                    }
                }
            }
        }
    }
}

add this to the deregistered event, somewhere around line 3500


 //removes people who leave the room from the readded array
 if (readded.length !== 0)
 {
     var readdedChecker = readded.indexOf(data.user[0].userid);
     if (readdedChecker != -1)
     {
         readded.splice(readdedChecker, 1);
     }
 }
samuri51 commented 11 years ago

did this work for u?

JimmyRehberg commented 11 years ago

Hi, I haven't had a spare moment to add the changes. I hope to do it this weekend. thanks so much. I'll let you know how it goes as soon as I do.

James

On Mar 22, 2013, at 2:53 AM, chris larosa notifications@github.com wrote:

did this work for u?

— Reply to this email directly or view it on GitHub.

mnafricano commented 11 years ago

It worked for me when I tried it on my bot.

samuri51 commented 11 years ago

good to hear ;) thx for tryin it