From 301e99fec15214aa912f66c34b9e4b7a88b9c7f6 Mon Sep 17 00:00:00 2001 From: Akamaru Date: Tue, 31 Oct 2017 22:55:52 +0100 Subject: [PATCH] MyAnimeList: Anpassung auf HTML --- miku/plugins/myanimelist.lua | 67 +++++++++++++++++------------------- 1 file changed, 32 insertions(+), 35 deletions(-) diff --git a/miku/plugins/myanimelist.lua b/miku/plugins/myanimelist.lua index 1ec53b3..f00310c 100644 --- a/miku/plugins/myanimelist.lua +++ b/miku/plugins/myanimelist.lua @@ -64,7 +64,7 @@ function mal:get_mal_info(query, typ) end function mal:send_anime_data(result, receiver) - local title = '*'..xml.find(result, 'title')[1]..'*' + local title = ''..xml.find(result, 'title')[1]..'' local id = xml.find(result, 'id')[1] local mal_url = 'https://myanimelist.net/anime/'..id @@ -75,19 +75,19 @@ function mal:send_anime_data(result, receiver) end if xml.find(result, 'english')[1] then - eng = '\nEnglisch: *'..xml.find(result, 'english')[1]..'*' + eng = '\nEnglisch: '..xml.find(result, 'english')[1] else eng = '' end if xml.find(result, 'synonyms')[1] then - syno = '\nAlternativ: *'..xml.find(result, 'synonyms')[1]..'*' + syno = '\nAlternativ: '..xml.find(result, 'synonyms')[1] else syno = '' end if xml.find(result, 'episodes')[1] then - episodes = '\nEpisoden: '..xml.find(result, 'episodes')[1] + episodes = '\nEpisoden: '..xml.find(result, 'episodes')[1] else episodes = '' end @@ -99,13 +99,13 @@ function mal:send_anime_data(result, receiver) end if xml.find(result, 'score')[1] ~= "0.00" then - score = '\nScore: '..string.gsub(xml.find(result, 'score')[1], "%.", ",") + score = '\nScore: '..string.gsub(xml.find(result, 'score')[1], "%.", ",") else score = '' end if xml.find(result, 'start_date')[1] ~= "0000-00-00" then - startdate = '\nAusstrahlung: '..makeOurDate(xml.find(result, 'start_date')[1]) + startdate = '\nAusstrahlung: '..makeOurDate(xml.find(result, 'start_date')[1]) else startdate = '' end @@ -117,19 +117,21 @@ function mal:send_anime_data(result, receiver) end if xml.find(result, 'synopsis')[1] then - desc = '\n_'..unescape(mal:delete_tags(string.sub(xml.find(result, 'synopsis')[1], 1, 250)))..'..._' + desc = '\n'..unescape(mal:delete_tags(string.sub(xml.find(result, 'synopsis')[1], 1, 250)))..'...' else desc = '' end - local text = title..typ..eng..syno..episodes..status..score..startdate..enddate..'\n'..desc..'\n[Auf MyAnimeList ansehen]('..mal_url..')' - if xml.find(result, 'image') then - local image_url = xml.find(result, 'image')[1] - return text, image_url + image_url = xml.find(result, 'image')[1] else - return text - end + image_url = '' + end + + local text = title..typ..eng..syno..episodes..status..score..startdate..enddate..'\n'..desc..' \nAuf MyAnimeList ansehen' + + return text + end function mal:send_manga_data(result) @@ -150,7 +152,7 @@ function mal:send_manga_data(result) end if xml.find(result, 'chapters')[1] then - chapters = '\nKapitel: '..xml.find(result, 'chapters')[1] + chapters = '\nKapitel: '..xml.find(result, 'chapters')[1] else chapters = '' end @@ -162,19 +164,19 @@ function mal:send_manga_data(result) end if xml.find(result, 'volumes')[1] then - volumes = '\nBände '..xml.find(result, 'volumes')[1] + volumes = '\nBände: '..xml.find(result, 'volumes')[1] else volumes = '' end if xml.find(result, 'score')[1] ~= "0.00" then - score = '\nScore: '..xml.find(result, 'score')[1] + score = '\nScore: '..xml.find(result, 'score')[1] else score = '' end if xml.find(result, 'start_date')[1] ~= "0000-00-00" then - startdate = '\nVeröffentlichungszeitraum: '..makeOurDate(xml.find(result, 'start_date')[1]) + startdate = '\nVeröffentlichungszeitraum: '..makeOurDate(xml.find(result, 'start_date')[1]) else startdate = '' end @@ -186,18 +188,21 @@ function mal:send_manga_data(result) end if xml.find(result, 'synopsis')[1] then - desc = '\n'..unescape(mal:delete_tags(string.sub(xml.find(result, 'synopsis')[1], 1, 200))) .. '...' + desc = '\n'..unescape(mal:delete_tags(string.sub(xml.find(result, 'synopsis')[1], 1, 200)))..'...' else desc = '' end - local text = '*'..title..'*'..alt_name..typ..chapters..status..volumes..score..startdate..enddate..'_'..desc..'_\n[Auf MyAnimeList ansehen]('..mal_url..')' if xml.find(result, 'image') then - local image_url = xml.find(result, 'image')[1] - return text, image_url + image_url = xml.find(result, 'image')[1] else - return text - end + image_url = '' + end + + local text = title..alt_name..typ..chapters..status..volumes..score..startdate..enddate..desc..' \nAuf MyAnimeList ansehen' + + return text + end function mal:action(msg, config, matches) @@ -208,12 +213,8 @@ function mal:action(msg, config, matches) utilities.send_reply(msg, 'Anime nicht gefunden!') return else - local text, image_url = mal:send_anime_data(anime_info) - if image_url then - utilities.send_typing(msg.chat.id, 'upload_photo') - utilities.send_photo(msg.chat.id, image_url, nil, msg.message_id) - end - utilities.send_reply(msg, text, true) + local text = mal:send_anime_data(anime_info) + utilities.send_message(msg.chat.id, text, false, msg.message_id, 'html') return end elseif matches[1] == 'manga' then @@ -222,12 +223,8 @@ function mal:action(msg, config, matches) utilities.send_reply(msg, 'Manga nicht gefunden!') return else - local text, image_url = mal:send_manga_data(manga_info) - if image_url then - utilities.send_typing(msg.chat.id, 'upload_photo') - utilities.send_photo(msg.chat.id, image_url, nil, msg.message_id) - end - utilities.send_reply(msg, text, true) + local text = mal:send_manga_data(manga_info) + utilities.send_message(msg.chat.id, text, false, msg.message_id, 'html') return end end