diff --git a/otouto/plugins/youtube.lua b/otouto/plugins/youtube.lua index 27d71e1..655b9d0 100644 --- a/otouto/plugins/youtube.lua +++ b/otouto/plugins/youtube.lua @@ -34,6 +34,13 @@ local makeOurDate = function(dateString) return day..'.'..month..'.'..year end +function markdown_escape_simple(text) + text = text:gsub('_', '\\_') + text = text:gsub('%*', '\\*') + text = text:gsub('`', '\\`') + return text +end + function get_yt_data (yt_code) local apikey = cred_data.google_apikey local url = BASE_URL..'/videos?part=snippet,statistics,contentDetails&key='..apikey..'&id='..yt_code..'&fields=items(snippet(publishedAt,channelTitle,localized(title,description),thumbnails),statistics(viewCount,likeCount,dislikeCount,commentCount),contentDetails(duration,regionRestriction(blocked)))' @@ -98,7 +105,7 @@ function get_yt_thumbnail(data) end function send_youtube_data(data, msg, self, link, sendpic) - local title = utilities.md_escape(data.snippet.localized.title) + local title = markdown_escape_simple(data.snippet.localized.title) -- local description = data.snippet.localized.description local uploader = data.snippet.channelTitle local upload_date = makeOurDate(data.snippet.publishedAt) diff --git a/otouto/utilities.lua b/otouto/utilities.lua index 6e8d98f..b8be411 100644 --- a/otouto/utilities.lua +++ b/otouto/utilities.lua @@ -490,8 +490,7 @@ end function utilities.markdown_escape(text) text = text:gsub('_', '\\_') - text = text:gsub('%[', '[[') - text = text:gsub('%]', ']]') + text = text:gsub('%[', '\\[') text = text:gsub('%*', '\\*') text = text:gsub('`', '\\`') return text