Created
May 11, 2015 17:57
-
-
Save zrod/3bc5c1f1b9a529f9c124 to your computer and use it in GitHub Desktop.
php-br.py modulo para willie
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding=utf8 | |
""" | |
php-br.py - Pega informacoes do www.php-br.org | |
""" | |
from __future__ import unicode_literals | |
import json | |
import willie.web as web | |
import willie.module | |
@willie.module.commands('artigo') | |
@willie.module.example('.artigo 39', 'Retorna dados do artigo ID do php-br.org') | |
def movie(bot, trigger): | |
""" | |
Retorna dados de um artigo especifico. | |
""" | |
if not trigger.group(2): | |
return | |
word = trigger.group(2).rstrip() | |
uri = "http://www.php-br.org/api/v1/artigo/" + word | |
u = web.get(uri, 30) | |
data = json.loads(u) # data is a Dict containing all the information we need | |
message = ' | Titulo: ' + data['titulo'] + \ | |
' | Autor: ' + data['autor'] + \ | |
' | Link: ' + data['url'] | |
bot.say(message) | |
if __name__ == "__main__": | |
from willie.test_tools import run_example_tests | |
run_example_tests(__file__) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment