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
Akamaru 952271851e new plugins
kick.lua
pokedex.lua
router_status.lua
whereisip.lua
2015-05-23 16:37:42 +02:00

29 lines
755 B
Lua

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
return 'No pokémon found.'
end
return 'Pokédex ID: ' .. pokemon.pkdx_id .. '\n'
..'Name: ' .. pokemon.name .. '\n'
..'Weight: ' .. pokemon.weight .. '\n'
..'Height: ' .. pokemon.height .. '\n'
..'Speed: ' .. pokemon.speed .. '\n'
end
local function run(msg, matches)
return get_pokemon(matches[1])
end
return {
description = "Pokedex searcher for Telegram",
usage = "/pokedex [Name/ID]: Search the pokédex for Name/ID and get info of the pokémon!",
patterns = {"^/pokedex (.*)$"},
run = run
}
end