From 99391a866702b05382d4a79c4b7342e6778ce8b1 Mon Sep 17 00:00:00 2001 From: Akamaru Date: Wed, 10 Jun 2015 19:40:12 +0200 Subject: [PATCH] youtube_search sends video info --- plugins/youtube_search.lua | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/plugins/youtube_search.lua b/plugins/youtube_search.lua index d8a19e2..b268ad6 100644 --- a/plugins/youtube_search.lua +++ b/plugins/youtube_search.lua @@ -1,5 +1,3 @@ -do - -- HOW TO USE: -- 1. Go to the Google Developers Console. -- 2. Select a project. @@ -10,6 +8,10 @@ do -- google_apikey = "YOURKEY-HERE", -- Your quota is 50.000.000 per day and a search takes 100 points. So if you manage to use this in one day, you're a real spammer :P +do + +require("./plugins/youtube") + local function searchYoutubeVideo(text) local apikey = cred_data.google_apikey local data = httpsRequest('https://www.googleapis.com/youtube/v3/search?part=snippet&key='..apikey..'&maxResults=1&type=video&q=' .. URL.escape(text)) @@ -33,11 +35,15 @@ end function run(msg, matches) local text = msg.text:sub(string.len(matches[1]) + 1,-1) local link = searchYoutubeVideo(text) + local yt_code = videoId + local data = get_yt_data(yt_code) + local receiver = get_receiver(msg) + send_youtube_data(data, receiver, link) return searchYoutubeVideo(text) end return { - description = "Sucht YouTube-Video und sendet es", + description = "Sucht ein YouTube-Video und sendet es", usage = {"/youtube [Suchbegriff]","/yt [Suchbegriff]"}, patterns = {"^/youtube","^/yt"}, run = run