_: Sendet Infos zur TV-Serie]]
+end
+
+local BASE_URL = 'http://thetvdb.com/api'
+
+local makeOurDate = function(dateString)
+ local pattern = "(%d+)%-(%d+)%-(%d+)"
+ local year, month, day = dateString:match(pattern)
+ return day..'.'..month..'.'..year
+end
+
+
+function tv:get_tv_info(series)
+ local url = BASE_URL..'/GetSeries.php?seriesname='..series..'&language=de'
+ local res,code = http.request(url)
+ if code ~= 200 then return "HTTP-ERROR" end
+ local result = xml.load(res)
+ if not xml.find(result, 'seriesid') then return "NOTFOUND" end
+ return result
+end
+
+function tv:send_tv_data(result, msg)
+ local title = xml.find(result, 'SeriesName')[1]
+ local id = xml.find(result, 'seriesid')[1]
+
+ if xml.find(result, 'AliasNames') and xml.find(result, 'AliasNames')[1] ~= title then
+ alias = '\noder: '..xml.find(result, 'AliasNames')[1]
+ else
+ alias = ''
+ end
+
+ if xml.find(result, 'Overview') then
+ desc = '\n_'..string.sub(xml.find(result, 'Overview')[1], 1, 250) .. '..._'
+ else
+ desc = ''
+ end
+
+ if xml.find(result, 'FirstAired') then
+ aired = '\n*Erstausstrahlung:* '..makeOurDate(xml.find(result, 'FirstAired')[1])
+ else
+ aired = ''
+ end
+
+
+ if xml.find(result, 'Network') then
+ publisher = '\n*Publisher:* '..xml.find(result, 'Network')[1]
+ else
+ publisher = ''
+ end
+
+ if xml.find(result, 'IMDB_ID') then
+ imdb = '\n[IMDB-Seite](http://www.imdb.com/title/'..xml.find(result, 'IMDB_ID')[1]..')'
+ else
+ imdb = ''
+ end
+
+ local text = '*'..title..'*'..alias..aired..publisher..imdb..desc..'\n[TVDB-Seite besuchen](http://thetvdb.com/?id='..id..'&tab=series)'
+ if xml.find(result, 'banner') then
+ local image_url = 'http://www.thetvdb.com/banners/'..xml.find(result, 'banner')[1]
+ 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)
+end
+
+
+function tv:action(msg, config, matches)
+ local series = URL.escape(matches[1])
+ local tv_info = tv:get_tv_info(series)
+ if tv_info == "NOTFOUND" then
+ utilities.send_reply(msg, config.errors.results)
+ return
+ elseif tv_info == "HTTP-ERROR" then
+ utilities.send_reply(msg, config.errors.connection)
+ return
+ else
+ tv:send_tv_data(tv_info, msg)
+ end
+end
+
+return tv
diff --git a/miku/plugins/twitch.lua b/miku/plugins/twitch.lua
index a3b0570..e837723 100644
--- a/miku/plugins/twitch.lua
+++ b/miku/plugins/twitch.lua
@@ -1,36 +1,36 @@
-local twitch = {}
-
-twitch.triggers = {
- "twitch.tv/([A-Za-z0-9-_-]+)"
-}
-
-local BASE_URL = 'https://api.twitch.tv'
-
-function twitch:send_twitch_info(twitch_name)
- local url = BASE_URL..'/kraken/channels/'..twitch_name
- local res,code = https.request(url)
- if code ~= 200 then return "HTTP-FEHLER" end
- local data = json.decode(res)
-
- local display_name = data.display_name
- local name = data.name
- if not data.game then
- game = 'nichts'
- else
- game = data.game
- end
- local status = data.status
- local views = comma_value(data.views)
- local followers = comma_value(data.followers)
- local text = '*'..display_name..'* ('..name..') streamt *'..game..'*\n'..status..'\n_'..views..' Zuschauer insgesamt und '..followers..' Follower_'
-
- return text
-end
-
-function twitch:action(msg, config, matches)
- local text = twitch:send_twitch_info(matches[1])
- if not text then utilities.send_reply(msg, config.errors.connection) return end
- utilities.send_reply(msg, text, true)
-end
-
-return twitch
+local twitch = {}
+
+twitch.triggers = {
+ "twitch.tv/([A-Za-z0-9-_-]+)"
+}
+
+local BASE_URL = 'https://api.twitch.tv'
+
+function twitch:send_twitch_info(twitch_name)
+ local url = BASE_URL..'/kraken/channels/'..twitch_name
+ local res,code = https.request(url)
+ if code ~= 200 then return "HTTP-FEHLER" end
+ local data = json.decode(res)
+
+ local display_name = data.display_name
+ local name = data.name
+ if not data.game then
+ game = 'nichts'
+ else
+ game = data.game
+ end
+ local status = data.status
+ local views = comma_value(data.views)
+ local followers = comma_value(data.followers)
+ local text = '*'..display_name..'* ('..name..') streamt *'..game..'*\n'..status..'\n_'..views..' Zuschauer insgesamt und '..followers..' Follower_'
+
+ return text
+end
+
+function twitch:action(msg, config, matches)
+ local text = twitch:send_twitch_info(matches[1])
+ if not text then utilities.send_reply(msg, config.errors.connection) return end
+ utilities.send_reply(msg, text, true)
+end
+
+return twitch
diff --git a/miku/plugins/wiimmfi.lua b/miku/plugins/wiimmfi.lua
deleted file mode 100644
index 0b4bec7..0000000
--- a/miku/plugins/wiimmfi.lua
+++ /dev/null
@@ -1,54 +0,0 @@
-local wiimmfi = {}
-
-function wiimmfi:init(config)
- wiimmfi.triggers = {
- "^/(mkw)$",
- "^/wiimmfi$",
- "^/wfc$"
- }
- wiimmfi.doc = [[*
-]]..config.cmd_pat..[[wfc*: Zeigt alle Wiimmfi-Spieler an
-*]]..config.cmd_pat..[[mkw*: Zeigt alle Mario-Kart-Wii-Spieler an]]
-end
-
-wiimmfi.command = 'wfc, /mkw'
-
-function wiimmfi:getplayer(game)
- local url = 'http://wiimmfi.de/game'
- local res,code = http.request(url)
- if code ~= 200 then return "Fehler beim Abrufen von wiimmfi.de" end
- if game == 'mkw' then
- local players = string.match(res, "(.-)")
- if players == nil then players = 0 end
- text = 'Es spielen gerade '..players..' Spieler Mario Kart Wii'
- else
- local players = string.match(res, " | (.-) | .-", ": ")
- local players = string.gsub(players, " | ", "")
- local players = string.gsub(players, "Wii", "")
- local players = string.gsub(players, "WiiWare", "")
- local players = string.gsub(players, "NDS", "")
- local players = string.gsub(players, "", "")
- local players = string.gsub(players, "", "")
- local players = string.gsub(players, "", "")
- local players = string.gsub(players, "", "")
- local players = string.gsub(players, "", "")
- local players = string.gsub(players, "", "")
- local players = string.gsub(players, "", "")
- if players == nil then players = 'Momentan spielt keiner auf Wiimmfi :(' end
- text = players
- end
- return text
-end
-
-function wiimmfi:action(msg, config, matches)
- if matches[1] == "mkw" then
- utilities.send_reply(msg, wiimmfi:getplayer('mkw'))
- return
- else
- utilities.send_reply(msg, wiimmfi:getplayer())
- return
- end
-end
-
-return wiimmfi
\ No newline at end of file
diff --git a/miku/plugins/wikia.lua b/miku/plugins/wikia.lua
index 0b204b7..346c158 100644
--- a/miku/plugins/wikia.lua
+++ b/miku/plugins/wikia.lua
@@ -27,14 +27,14 @@ function send_wikia_article(wikia, article)
local abstract = data.items[id].abstract
local article_url = data.basepath..data.items[id].url
- local text = '*'..title..'*:\n'..abstract..' [Weiterlesen]('..article_url..')'
+ local text = ''..title..':\n'..abstract..' Weiterlesen'
return text
end
function wikia:action(msg, config, matches)
local wikia = matches[1]
local article = matches[2]
- utilities.send_reply(msg, send_wikia_article(wikia, article), true)
+ utilities.send_reply(msg, send_wikia_article(wikia, article), 'HTML')
end
return wikia
\ No newline at end of file
diff --git a/miku/plugins/yourls.lua b/miku/plugins/yourls.lua
index 48c93ec..5956925 100644
--- a/miku/plugins/yourls.lua
+++ b/miku/plugins/yourls.lua
@@ -1,53 +1,53 @@
-local yourls = {}
-
-function yourls:init(config)
- if not cred_data.yourls_site_url then
- print('Fehlender Key: yourls_site_url.')
- print('yourls.lua wird nicht aktiviert.')
- return
- elseif not cred_data.yourls_signature_token then
- print('Fehlender Key: yourls_signature_token.')
- print('yourls.lua wird nicht aktiviert.')
- return
- end
-
- yourls.triggers = {
- "^/yourls (https?://[%w-_%.%?%.:/%+=&]+)"
- }
-end
-
-local SITE_URL = cred_data.yourls_site_url
-local signature = cred_data.yourls_signature_token
-local BASE_URL = SITE_URL..'/yourls-api.php'
-
-function yourls:prot_url(url)
- local url, h = string.gsub(url, "http://", "")
- local url, hs = string.gsub(url, "https://", "")
- local protocol = "http"
- if hs == 1 then
- protocol = "https"
- end
- return url, protocol
-end
-
-function yourls:create_yourls_link(long_url, protocol)
- local url = BASE_URL..'?format=simple&signature='..signature..'&action=shorturl&url='..long_url
- if protocol == "http" then
- link,code = http.request(url)
- else
- link,code = https.request(url)
- end
- if code ~= 200 then
- link = 'Ein Fehler ist aufgetreten. '..link
- end
- return link
-end
-
-function yourls:action(msg, config, matches)
- local long_url = matches[1]
- local baseurl, protocol = yourls:prot_url(SITE_URL)
- utilities.send_reply(msg, yourls:create_yourls_link(long_url, protocol))
- return
-end
-
-return yourls
+local yourls = {}
+
+function yourls:init(config)
+ if not cred_data.yourls_site_url then
+ print('Fehlender Key: yourls_site_url.')
+ print('yourls.lua wird nicht aktiviert.')
+ return
+ elseif not cred_data.yourls_signature_token then
+ print('Fehlender Key: yourls_signature_token.')
+ print('yourls.lua wird nicht aktiviert.')
+ return
+ end
+
+ yourls.triggers = {
+ "^/yourls (https?://[%w-_%.%?%.:/%+=&]+)"
+ }
+end
+
+local SITE_URL = cred_data.yourls_site_url
+local signature = cred_data.yourls_signature_token
+local BASE_URL = SITE_URL..'/yourls-api.php'
+
+function yourls:prot_url(url)
+ local url, h = string.gsub(url, "http://", "")
+ local url, hs = string.gsub(url, "https://", "")
+ local protocol = "http"
+ if hs == 1 then
+ protocol = "https"
+ end
+ return url, protocol
+end
+
+function yourls:create_yourls_link(long_url, protocol)
+ local url = BASE_URL..'?format=simple&signature='..signature..'&action=shorturl&url='..long_url
+ if protocol == "http" then
+ link,code = http.request(url)
+ else
+ link,code = https.request(url)
+ end
+ if code ~= 200 then
+ link = 'Ein Fehler ist aufgetreten. '..link
+ end
+ return link
+end
+
+function yourls:action(msg, config, matches)
+ local long_url = matches[1]
+ local baseurl, protocol = yourls:prot_url(SITE_URL)
+ utilities.send_reply(msg, yourls:create_yourls_link(long_url, protocol))
+ return
+end
+
+return yourls
diff --git a/miku/plugins/youtube.lua b/miku/plugins/youtube.lua
index 621e4b4..09570f4 100644
--- a/miku/plugins/youtube.lua
+++ b/miku/plugins/youtube.lua
@@ -98,15 +98,15 @@ function send_youtube_data(data, msg, self, link, sendpic)
local upload_date = makeOurDate(data.snippet.publishedAt)
local viewCount = comma_value(data.statistics.viewCount)
if data.statistics.likeCount then
- likeCount = ', '..comma_value(data.statistics.likeCount)..' Likes und '
- dislikeCount = comma_value(data.statistics.dislikeCount)..' Dislikes'
+ likeCount = ' | 👍 '..comma_value(data.statistics.likeCount)..' |'
+ dislikeCount = ' 👎 '..comma_value(data.statistics.dislikeCount)..''
else
likeCount = ''
dislikeCount = ''
end
if data.statistics.commentCount then
- commentCount = ', '..comma_value(data.statistics.commentCount)..' Kommentare'
+ commentCount = ' | 🗣 '..comma_value(data.statistics.commentCount)..''
else
commentCount = ''
end
@@ -120,7 +120,7 @@ function send_youtube_data(data, msg, self, link, sendpic)
blocked = false
end
- text = ''..title..'\n('..uploader..' am '..upload_date..', '..viewCount..'x angesehen, Länge: '..duration..likeCount..dislikeCount..commentCount..')\n'
+ text = ''..title..'\n🎥 '..uploader..', 📅 '..upload_date..'\n👁 '..viewCount..' | 🕒 '..duration..''..likeCount..dislikeCount..commentCount..'\n'
if link then
text = link..'\n'..text
end
@@ -132,7 +132,7 @@ function send_youtube_data(data, msg, self, link, sendpic)
if sendpic then
local image_url = get_yt_thumbnail(data)
-- need to change text, because Telegram captions can only be 200 characters long and don't support Markdown
- local text = link..'\n'..title..'\n('..uploader..' am '..upload_date..', '..viewCount..'x angesehen, Länge: '..duration..')'
+ local text = link..'\n'..title..'\n🎥 '..uploader..', 📅 '..upload_date..'\n👁 '..viewCount..' | 🕒 '..duration..likeCount..dislikeCount..commentCount..'\n'
if blocked then
text = text..'\nACHTUNG, In Deutschland gesperrt!'
end