- Entferne Games und Twitch
- YouTube-Plugin hat eine neue Ausgabe
This commit is contained in:
parent
5c498b3c04
commit
37580de23b
@ -1,149 +0,0 @@
|
||||
local games = {}
|
||||
|
||||
local xml = require("xml")
|
||||
|
||||
games.command = 'game <Spiel>'
|
||||
|
||||
function games:init(config)
|
||||
games.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('game', true).table
|
||||
games.doc = [[*
|
||||
]]..config.cmd_pat..[[game*_ <Spiel>_: Sendet Infos zum Spiel]]
|
||||
end
|
||||
|
||||
local BASE_URL = 'http://thegamesdb.net/api'
|
||||
|
||||
local makeOurDate = function(dateString)
|
||||
local pattern = "(%d+)%/(%d+)%/(%d+)"
|
||||
local month, day, year = dateString:match(pattern)
|
||||
return day..'.'..month..'.'..year
|
||||
end
|
||||
|
||||
|
||||
function games:get_game_id(game)
|
||||
local url = BASE_URL..'/GetGamesList.php?name='..game
|
||||
local res,code = http.request(url)
|
||||
if code ~= 200 then return "HTTP-FEHLER" end
|
||||
local result = xml.load(res)
|
||||
if xml.find(result, 'id') then
|
||||
local game = xml.find(result, 'id')[1]
|
||||
return game
|
||||
else
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
function games:send_game_photo(result, self, msg)
|
||||
local BASE_URL = xml.find(result, 'baseImgUrl')[1]
|
||||
local images = {}
|
||||
|
||||
if xml.find(result, 'fanart') then
|
||||
local fanart = xml.find(result, 'fanart')[1]
|
||||
local fanrt_url = BASE_URL..fanart[1]
|
||||
table.insert(images, fanrt_url)
|
||||
end
|
||||
|
||||
if xml.find(result, 'boxart', 'side', 'front') then
|
||||
local boxart = xml.find(result, 'boxart', 'side', 'front')[1]
|
||||
local boxart_url = BASE_URL..boxart
|
||||
table.insert(images, boxart_url)
|
||||
end
|
||||
|
||||
local i = 0
|
||||
for k, v in pairs(images) do
|
||||
i = i+1
|
||||
utilities.send_photo(msg.chat.id, v, nil, msg.message_id)
|
||||
end
|
||||
end
|
||||
|
||||
function games:send_game_data(game_id, self, msg)
|
||||
local url = BASE_URL..'/GetGame.php?id='..game_id
|
||||
local res,code = http.request(url)
|
||||
if code ~= 200 then return nil end
|
||||
local result = xml.load(res)
|
||||
|
||||
local title = xml.find(result, 'GameTitle')[1]
|
||||
local platform = xml.find(result, 'Platform')[1]
|
||||
|
||||
if xml.find(result, 'ReleaseDate') then
|
||||
date = ', erschienen am '..makeOurDate(xml.find(result, 'ReleaseDate')[1])
|
||||
else
|
||||
date = ''
|
||||
end
|
||||
|
||||
if xml.find(result, 'Overview') then
|
||||
desc = '\n_'..string.sub(xml.find(result, 'Overview')[1], 1, 200) .. '..._'
|
||||
else
|
||||
desc = ''
|
||||
end
|
||||
|
||||
if xml.find(result, 'Genres') then
|
||||
local genres = xml.find(result, 'Genres')
|
||||
local genre_count = #genres-1
|
||||
if genre_count == 1 then
|
||||
genre = '\nGenre: '..genres[1][1]
|
||||
else
|
||||
local genre_loop = '\nGenres: '
|
||||
for v in pairs(genres) do
|
||||
if v == 'xml' then break; end
|
||||
if v < genre_count then
|
||||
genre_loop = genre_loop..genres[v][1]..', '
|
||||
else
|
||||
genre_loop = genre_loop..genres[v][1]
|
||||
end
|
||||
end
|
||||
genre = genre_loop
|
||||
end
|
||||
else
|
||||
genre = ''
|
||||
end
|
||||
|
||||
if xml.find(result, 'Players') then
|
||||
players = '\nSpieler: '..xml.find(result, 'Players')[1]
|
||||
else
|
||||
players = ''
|
||||
end
|
||||
|
||||
if xml.find(result, 'Youtube') then
|
||||
video = '\n[Video auf YouTube ansehen]('..xml.find(result, 'Youtube')[1]..')'
|
||||
else
|
||||
video = ''
|
||||
end
|
||||
|
||||
if xml.find(result, 'Publisher') then
|
||||
publisher = '\nPublisher: '..xml.find(result, 'Publisher')[1]
|
||||
else
|
||||
publisher = ''
|
||||
end
|
||||
|
||||
local text = '*'..title..'* für *'..platform..'*'..date..desc..genre..players..video..publisher
|
||||
utilities.send_reply(msg, text, true)
|
||||
|
||||
if xml.find(result, 'fanrt') or xml.find(result, 'boxart') then
|
||||
utilities.send_typing(msg.chat.id, 'upload_photo')
|
||||
games:send_game_photo(result, self, msg)
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
function games:action(msg, config)
|
||||
local game = utilities.input(msg.text)
|
||||
if not game then
|
||||
if msg.reply_to_message and msg.reply_to_message.text then
|
||||
game = msg.reply_to_message.text
|
||||
else
|
||||
utilities.send_message(msg.chat.id, fun.doc, true, msg.message_id, true)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
local game_id = games:get_game_id(game)
|
||||
if not game_id then
|
||||
utilities.send_reply(msg, 'Spiel nicht gefunden!')
|
||||
return
|
||||
else
|
||||
games:send_game_data(game_id, self, msg)
|
||||
end
|
||||
end
|
||||
|
||||
return games
|
@ -1,36 +0,0 @@
|
||||
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
|
@ -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 = '<b>'..title..'</b>\n<i>('..uploader..' am '..upload_date..', '..viewCount..'x angesehen, Länge: '..duration..likeCount..dislikeCount..commentCount..')</i>\n'
|
||||
text = '<b>'..title..'</b>\n🎥 <b>'..uploader..'</b>, 📅 '..upload_date..'\n👁 '..viewCount..' | 🕒 '..duration..likeCount..dislikeCount..commentCount..'\n'
|
||||
if link then
|
||||
text = link..'\n'..text
|
||||
end
|
||||
|
Reference in New Issue
Block a user