From 51b13df77fc088c09c272a00ff357117beb79bfb Mon Sep 17 00:00:00 2001 From: Andreas Bielawski Date: Wed, 22 Jun 2016 19:17:30 +0200 Subject: [PATCH] - Fix in Pocket, wenn kein Titel vorhanden - Fixe YouTube-Patterns --- otouto/plugins/pocket.lua | 2 +- otouto/plugins/youtube.lua | 10 +++------- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/otouto/plugins/pocket.lua b/otouto/plugins/pocket.lua index b974d09..328dbc4 100644 --- a/otouto/plugins/pocket.lua +++ b/otouto/plugins/pocket.lua @@ -72,7 +72,7 @@ function pocket:add_pocket_item(access_token, url) local result = post_petition(BASE_URL..'/add', 'consumer_key='..consumer_key..'&access_token='..access_token..'&url='..url, headers) if result.status ~= 1 then return 'Ein Fehler beim Hinzufügen der URL ist aufgetreten :(' end local given_url = result.item.given_url - if result.item.title == "" then + if result.item.title == "" or not result.item.title then title = 'Seite' else title = '"'..result.item.title..'"' diff --git a/otouto/plugins/youtube.lua b/otouto/plugins/youtube.lua index c5c98a7..d992b7e 100644 --- a/otouto/plugins/youtube.lua +++ b/otouto/plugins/youtube.lua @@ -14,6 +14,7 @@ function youtube:init(config) youtube.triggers = { 'youtu.be/([A-Za-z0-9-_-]+)', + 'youtube.com/embed/([A-Za-z0-9-_-]+)', 'youtube.com/watch%?v=([A-Za-z0-9-_-]+)' } youtube.doc = [[*YouTube-Link*: Postet Infos zu Video]] @@ -148,13 +149,8 @@ function send_youtube_data(data, msg, self, link, sendpic) end end -function youtube:action(msg) - if not msg.text:match('youtu.be/([A-Za-z0-9-_-]+)') and not msg.text:match('youtube.com/watch%?v=([A-Za-z0-9-_-]+)') then - return - end - local yt_code = msg.text:match('youtu.be/([A-Za-z0-9-_-]+)') - if not yt_code then yt_code = msg.text:match('youtube.com/watch%?v=([A-Za-z0-9-_-]+)') end - +function youtube:action(msg, config, matches) + local yt_code = matches[1] local data = get_yt_data(yt_code) send_youtube_data(data, msg, self) return