alaingilbert / Turntable-API

Allows you to create bots for turntable.fm
http://alaingilbert.github.com/Turntable-API/
MIT License
318 stars 97 forks source link

Simple Queue Manager #246

Closed ghost closed 10 years ago

ghost commented 10 years ago

How can I code up a simple Queue Manager for my bot.

gizmotronic commented 10 years ago

(sorry, that was not intentional.)

In my opinion this is not a simple task, and I don't think it's an issue with Turntable-API.

ghost commented 10 years ago

um, ok. what should I do to code it, then.

gizmotronic commented 10 years ago

Here's the simplest possible implementation:

  1. Create an empty array. This is your queue. (You will push user IDs onto this array.)
  2. Create a function to check to see if there is room on the table and if the queue is not empty, and if so, tell the person in position 0 of the array that it's their turn.
  3. When someone says the command to add themselves to the queue, push their user ID onto the array and call the function from (2).
  4. When the rem_dj event is triggered, call the function from (2).
  5. When the add_dj event is triggered, make sure that the user ID in the event is the same as the user ID in position 0 of the array. If it is, shift the first entry off of the array. If not, use .remDj() to remove them. Finally, call the function from (2) (in case there's more spots open).

Some things to consider:

ghost commented 10 years ago

um, ok :)

MikeWills commented 10 years ago

A really basic queue is simple but will lead to lots of frustration. A good queue is hard and very complicated. Heck I still have many bugs I plan on fixing some day. I haven't fixed them mostly because I am not in rooms where we use queues.

Mike Wills mike@mikewills.me http://mikewills.me 507-933-0880 On Aug 3, 2013 8:01 AM, "Turntablelover" notifications@github.com wrote:

um, ok :)

— Reply to this email directly or view it on GitHubhttps://github.com/alaingilbert/Turntable-API/issues/246#issuecomment-22054567 .

ghost commented 10 years ago

ok