Skip to content

Instantly share code, notes, and snippets.

@devyn
Created July 14, 2011 06:22
Show Gist options
  • Save devyn/1082023 to your computer and use it in GitHub Desktop.
Save devyn/1082023 to your computer and use it in GitHub Desktop.
this.queue = {};
this.register_command("queue", function(context, text) {
var who = context.intent.name;
if (!this.queue[who]) this.queue[who] = [];
this.queue[who].push([context.sender, text]);
});
this.register_command("dequeue", function(context, text) {
var who = context.intent.name;
if (!this.queue[who]) this.queue[who] = [];
var item = (text == "peek") ? this.queue[who][0] : this.queue[who].shift();
if (item) {
context.channel.send_reply (context.intent, "<"+item[0].name+"> "+item[1]);
} else {
context.channel.send_reply (context.sender, "The queue is empty.");
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment