MyAnimeList: Anpassung auf HTML

This commit is contained in:
Akamaru 2017-10-31 22:55:52 +01:00
parent 8a84a228ce
commit 301e99fec1
1 changed files with 32 additions and 35 deletions

View File

@ -64,7 +64,7 @@ function mal:get_mal_info(query, typ)
end end
function mal:send_anime_data(result, receiver) function mal:send_anime_data(result, receiver)
local title = '*'..xml.find(result, 'title')[1]..'*' local title = '<b>'..xml.find(result, 'title')[1]..'</b>'
local id = xml.find(result, 'id')[1] local id = xml.find(result, 'id')[1]
local mal_url = 'https://myanimelist.net/anime/'..id local mal_url = 'https://myanimelist.net/anime/'..id
@ -75,19 +75,19 @@ function mal:send_anime_data(result, receiver)
end end
if xml.find(result, 'english')[1] then if xml.find(result, 'english')[1] then
eng = '\nEnglisch: *'..xml.find(result, 'english')[1]..'*' eng = '\n<b>Englisch:</b> '..xml.find(result, 'english')[1]
else else
eng = '' eng = ''
end end
if xml.find(result, 'synonyms')[1] then if xml.find(result, 'synonyms')[1] then
syno = '\nAlternativ: *'..xml.find(result, 'synonyms')[1]..'*' syno = '\n<b>Alternativ:</b> '..xml.find(result, 'synonyms')[1]
else else
syno = '' syno = ''
end end
if xml.find(result, 'episodes')[1] then if xml.find(result, 'episodes')[1] then
episodes = '\nEpisoden: '..xml.find(result, 'episodes')[1] episodes = '\n<b>Episoden:</b> '..xml.find(result, 'episodes')[1]
else else
episodes = '' episodes = ''
end end
@ -99,13 +99,13 @@ function mal:send_anime_data(result, receiver)
end end
if xml.find(result, 'score')[1] ~= "0.00" then if xml.find(result, 'score')[1] ~= "0.00" then
score = '\nScore: '..string.gsub(xml.find(result, 'score')[1], "%.", ",") score = '\n<b>Score:</b> '..string.gsub(xml.find(result, 'score')[1], "%.", ",")
else else
score = '' score = ''
end end
if xml.find(result, 'start_date')[1] ~= "0000-00-00" then if xml.find(result, 'start_date')[1] ~= "0000-00-00" then
startdate = '\nAusstrahlung: '..makeOurDate(xml.find(result, 'start_date')[1]) startdate = '\n<b>Ausstrahlung:</b> '..makeOurDate(xml.find(result, 'start_date')[1])
else else
startdate = '' startdate = ''
end end
@ -117,19 +117,21 @@ function mal:send_anime_data(result, receiver)
end end
if xml.find(result, 'synopsis')[1] then if xml.find(result, 'synopsis')[1] then
desc = '\n_'..unescape(mal:delete_tags(string.sub(xml.find(result, 'synopsis')[1], 1, 250)))..'..._' desc = '\n<i>'..unescape(mal:delete_tags(string.sub(xml.find(result, 'synopsis')[1], 1, 250)))..'...</i>'
else else
desc = '' desc = ''
end 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 if xml.find(result, 'image') then
local image_url = xml.find(result, 'image')[1] image_url = xml.find(result, 'image')[1]
return text, image_url
else else
return text image_url = ''
end end
local text = title..typ..eng..syno..episodes..status..score..startdate..enddate..'\n'..desc..'<a href="'..image_url..'"> </a>\n<a href="'..mal_url..'">Auf MyAnimeList ansehen</a>'
return text
end end
function mal:send_manga_data(result) function mal:send_manga_data(result)
@ -150,7 +152,7 @@ function mal:send_manga_data(result)
end end
if xml.find(result, 'chapters')[1] then if xml.find(result, 'chapters')[1] then
chapters = '\nKapitel: '..xml.find(result, 'chapters')[1] chapters = '\n<b>Kapitel:</b> '..xml.find(result, 'chapters')[1]
else else
chapters = '' chapters = ''
end end
@ -162,19 +164,19 @@ function mal:send_manga_data(result)
end end
if xml.find(result, 'volumes')[1] then if xml.find(result, 'volumes')[1] then
volumes = '\nBände '..xml.find(result, 'volumes')[1] volumes = '\n<b>Bände:</b> '..xml.find(result, 'volumes')[1]
else else
volumes = '' volumes = ''
end end
if xml.find(result, 'score')[1] ~= "0.00" then if xml.find(result, 'score')[1] ~= "0.00" then
score = '\nScore: '..xml.find(result, 'score')[1] score = '\n<b>Score:</b> '..xml.find(result, 'score')[1]
else else
score = '' score = ''
end end
if xml.find(result, 'start_date')[1] ~= "0000-00-00" then if xml.find(result, 'start_date')[1] ~= "0000-00-00" then
startdate = '\nVeröffentlichungszeitraum: '..makeOurDate(xml.find(result, 'start_date')[1]) startdate = '\n<b>Veröffentlichungszeitraum:</b> '..makeOurDate(xml.find(result, 'start_date')[1])
else else
startdate = '' startdate = ''
end end
@ -186,18 +188,21 @@ function mal:send_manga_data(result)
end end
if xml.find(result, 'synopsis')[1] then if xml.find(result, 'synopsis')[1] then
desc = '\n'..unescape(mal:delete_tags(string.sub(xml.find(result, 'synopsis')[1], 1, 200))) .. '...' desc = '\n<i>'..unescape(mal:delete_tags(string.sub(xml.find(result, 'synopsis')[1], 1, 200)))..'...</i>'
else else
desc = '' desc = ''
end 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 if xml.find(result, 'image') then
local image_url = xml.find(result, 'image')[1] image_url = xml.find(result, 'image')[1]
return text, image_url
else else
return text image_url = ''
end end
local text = title..alt_name..typ..chapters..status..volumes..score..startdate..enddate..desc..'<a href="'..image_url..'"> </a>\n<a href="'..mal_url..'">Auf MyAnimeList ansehen</a>'
return text
end end
function mal:action(msg, config, matches) function mal:action(msg, config, matches)
@ -208,12 +213,8 @@ function mal:action(msg, config, matches)
utilities.send_reply(msg, 'Anime nicht gefunden!') utilities.send_reply(msg, 'Anime nicht gefunden!')
return return
else else
local text, image_url = mal:send_anime_data(anime_info) local text = mal:send_anime_data(anime_info)
if image_url then utilities.send_message(msg.chat.id, text, false, msg.message_id, 'html')
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)
return return
end end
elseif matches[1] == 'manga' then elseif matches[1] == 'manga' then
@ -222,12 +223,8 @@ function mal:action(msg, config, matches)
utilities.send_reply(msg, 'Manga nicht gefunden!') utilities.send_reply(msg, 'Manga nicht gefunden!')
return return
else else
local text, image_url = mal:send_manga_data(manga_info) local text = mal:send_manga_data(manga_info)
if image_url then utilities.send_message(msg.chat.id, text, false, msg.message_id, 'html')
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)
return return
end end
end end