From 4cfdb3c6b7911673f579d34bde053c6c587b65be Mon Sep 17 00:00:00 2001 From: palmtree5 Date: Wed, 9 Mar 2016 13:25:31 -0500 Subject: [PATCH 1/3] Added command to check if a Twitch channel is live --- package.json | 2 +- runtime/commands.js | 37 ++++++++++++++++++++++++++++++++++++- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 9469dea64..fd5a7b595 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "WildBeast", - "version": "2.0.0-gamma.6", + "version": "2.0.0-gamma.6-2", "description": "A Discord bot", "readme": "README.md", "maintainers": [ diff --git a/runtime/commands.js b/runtime/commands.js index 34c3bda05..d0ad87f3e 100644 --- a/runtime/commands.js +++ b/runtime/commands.js @@ -26,7 +26,42 @@ Commands.ping = { bot.reply(msg, "Pong!"); // Easy for moderation } }; - +Commands.stream = { + name: "stream", + help: "Tells you if a specified streamer is live on Twitch.tv", + level: 0, + fn: function(bot, msg, suffix){ + if(!suffix){ + bot.sendMessage(msg.channel, "No channel specified!"); + return; + } + var request = require("request"); + var url = "https://api.twitch.tv/kraken/streams/" + suffix; + request({url: url, headers: {"Accept": "application/vnd.twitchtv.v3+json"}}, function(error, response, body){ + if (!error && response.statusCode == 200){ + var resp, error; + try{ + resp = JSON.parse(body); + } catch(error){ + Logger.error(error); + return; + } + if(resp.stream != null){ + bot.sendMessage(msg.channel, suffix + " is currently live at https://www.twitch.tv/" + suffix); + return; + } + else if(resp.stream == null){ + bot.sendMessage(msg.channel, suffix + " is not currently streaming"); + return; + } + } + else if (!error && response.statusCode == 404){ + bot.sendMessage(msg.channel, "Channel does not exist!"); + return; + } + }); + } +}; Commands.nowplaying = { name: "nowplaying", help: "Returns what video is currently playing.", From f7d31076d0f30bf11bf4b73c4cfa8aa04c763ea1 Mon Sep 17 00:00:00 2001 From: palmtree5 Date: Wed, 9 Mar 2016 13:32:51 -0500 Subject: [PATCH 2/3] Version bump --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b741e4f2f..555493578 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "WildBeast", - "version": "2.0.0-gamma.7", + "version": "2.0.0-gamma.7-2", "description": "A Discord bot", "readme": "README.md", "maintainers": [ From e4684cafa0ae929d7a4dd4d73f41825cd9537453 Mon Sep 17 00:00:00 2001 From: palmtree5 Date: Wed, 9 Mar 2016 15:41:45 -0500 Subject: [PATCH 3/3] change version back to 2.0.0-gamma.7 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 555493578..b741e4f2f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "WildBeast", - "version": "2.0.0-gamma.7-2", + "version": "2.0.0-gamma.7", "description": "A Discord bot", "readme": "README.md", "maintainers": [