This repository has been archived on 2021-04-24. You can view files and clone it, but cannot push or open issues or pull requests.
Mikubot/plugins/imdb.lua

36 lines
710 B
Lua
Raw Normal View History

do
2015-02-13 16:45:27 +01:00
function imdb(movie)
local http = require("socket.http")
http.TIMEOUT = 5
2015-02-13 16:45:27 +01:00
local movie = movie:gsub(' ', '+')
local url = "http://www.imdbapi.com/?t=" .. movie
local response, code, headers = http.request(url)
2015-02-13 16:45:27 +01:00
if code ~= 200 then
return "Error: " .. code
end
2015-02-13 16:45:27 +01:00
if #response > 0 then
local r = json:decode(response)
r['Url'] = "http://imdb.com/title/" .. r.imdbID
local t = ""
for k, v in pairs(r) do t = t .. k .. ": " .. v .. ", " end
return t:sub(1, -3)
end
return nil
2015-02-13 16:45:27 +01:00
end
function run(msg, matches)
return imdb(matches[1])
2015-02-13 16:45:27 +01:00
end
return {
description = "Imdb plugin for telegram",
usage = "!imdb [movie]",
patterns = {"^!imdb (.+)"},
run = run
2015-02-13 16:45:27 +01:00
}
end