Add modsearch module

master
sfan5 2015-03-09 20:25:50 +01:00
parent fc06ee7585
commit e80a1a669e
2 changed files with 31 additions and 0 deletions

View File

@ -85,4 +85,6 @@ Required arguments are enclosed in { and }, optional arguments are enclosed in [
<tr> <td>!btc [currency]</td> <td>Get Bitcoin price for specified currency</td> <td>Anyone</td> </tr>
<tr> <td><b>tell.py</b></td> <td></td> <td></td> </tr>
<tr> <td>!tell {nick} {message}</td> <td>Tell somebody a message</td> <td>Anyone</td> </tr>
<tr> <td><b>modsearch.py</b></td> <td></td> <td></td> </tr>
<tr> <td>!mod {modname}</td> <td>Searches for a mod</td> <td>Anyone</td> </tr>
</table>

29
modsearch.py Normal file
View File

@ -0,0 +1,29 @@
#!/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?q="
text, sc = web.get(uri + input.group(2))
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__)