Skip to content

Instantly share code, notes, and snippets.

@zrod
Created May 11, 2015 17:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zrod/3bc5c1f1b9a529f9c124 to your computer and use it in GitHub Desktop.
Save zrod/3bc5c1f1b9a529f9c124 to your computer and use it in GitHub Desktop.
php-br.py modulo para willie
# 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