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/pokedex.lua

31 lines
765 B
Lua
Raw Normal View History

do
local function get_pokemon(query)
local url = "http://pokeapi.co/api/v1/pokemon/" .. query .. "/"
local b,c = http.request(url)
local pokemon = json:decode(b)
if pokemon == nil then
2015-05-23 17:23:57 +02:00
return 'Kein Pokemon gefunden.'
end
return 'Pokédex ID: ' .. pokemon.pkdx_id .. '\n'
..'Name: ' .. pokemon.name .. '\n'
2015-05-23 17:23:57 +02:00
..'Gewicht: ' .. pokemon.weight .. '\n'
..'Größe: ' .. pokemon.height .. '\n'
..'Speed: ' .. pokemon.speed .. '\n'
2015-05-23 17:23:57 +02:00
..'Spezies: ' .. pokemon.species .. '\n'
end
local function run(msg, matches)
2015-05-23 17:51:24 +02:00
local name = string.lower(matches[1])
return get_pokemon(name)
end
return {
2015-05-23 17:23:57 +02:00
description = "Pokedex für Telegram",
usage = "/pokedex [Name/ID]",
patterns = {"^/pokedex (.*)$"},
run = run
}
end