$ git clone http://tcclient.ion.nu/tc_client.git
commit e03c13d2cefe8a8e0ba019af797fff7cbecefe45
Author: Alicia <...>
Date:   Tue Jan 12 23:02:57 2016 +0100

    modbot: if nothing is playing when a video gets approved, play it even if it's not first in the queue.

diff --git a/ChangeLog b/ChangeLog
index 2231d60..8ef4fa9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -9,6 +9,7 @@ libcamera: fixed compiler warnings.
 libcamera: added support for cameras on windows through the ESCAPI library.
 testbuilds.sh: added a warning to prevent users from trying to use it to test their build, which is not what it does.
 configure/Makefile: added a summary of utilities and features enabled/available at the end of configure (or manually with 'make confinfo')
+modbot: if nothing is playing when a video gets approved, play it even if it's not first in the queue.
 0.36:
 Implemented /whois <nick/ID> to check someone's username.
 Changed the /whois output to be more human-readable in cases where the user isn't logged in.
diff --git a/utilities/modbot/modbot.c b/utilities/modbot/modbot.c
index 4b1ca49..fe3ee3e 100644
--- a/utilities/modbot/modbot.c
+++ b/utilities/modbot/modbot.c
@@ -710,7 +710,12 @@ int main(int argc, char** argv)
             list_del(&badvids, vid);
             list_save(&goodvids, "goodvids.txt");
             list_save(&badvids, "badvids.txt");
-            if(!playing && queue.itemcount>0 && !strcmp(vid, queue.items[0].video)){playnext(0);} // Next in queue just got approved, so play it
+            int pos=queue_getpos(&queue, vid);
+            if(!playing && pos>-1) // If nothing is playing and the approved video is in the queue, play it
+            {
+              if(pos>0){queue_movetofront(&queue, pos);} // If it wasn't next in queue, move it to the front
+              playnext(0);
+            }
           }
           else if(!strcmp(msg, "!badvid") || !strcmp(msg, "!badvideo") || !strncmp(msg, "!badvid ", 8) || !strncmp(msg, "!badvideo ", 10))
           {