Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
A phenny minetest module to search minetest mods
#!/usr/bin/env python
"""
modsearch.py - Phenny Minetest Mod Search Module
Copyright 2015, SmallJoker
Licensed under GNU General Public License v2.0
"""
import web
def mod(phenny, input):
uri = "http://nimg.pf-control.de/MTstuff/modSearchAPI.php"
text, sc = web.get(uri + "?q=" + input)
text = str(text, 'utf-8')
data = web.json(text)
answer = ""
if "error" in data:
answer = data["error"]
else:
answer = (data["title"] +
" by " + data["author"] +
" - " + data["link"])
phenny.reply(answer)
mod.commands = ['mod']
mod.example = '.mod party_mod'
if __name__ == '__main__':
print(__doc__)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment