initial commit

This commit is contained in:
Jared McKnight 2018-02-13 19:44:03 -05:00
commit 7dc839c1dd
No known key found for this signature in database
GPG key ID: DB3C3196E89FCC30
5 changed files with 149 additions and 0 deletions

13
.editorconfig Normal file
View file

@ -0,0 +1,13 @@
# http://EditorConfig.org
root = true
[*]
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = space
indent_size = 4
charset = utf-8
[*.md]
trim_trailing_whitespace = false

101
.gitignore vendored Normal file
View file

@ -0,0 +1,101 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
target/
# Jupyter Notebook
.ipynb_checkpoints
# pyenv
.python-version
# celery beat schedule file
celerybeat-schedule
# SageMath parsed files
*.sage.py
# dotenv
.env
# virtualenv
.venv
venv/
ENV/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/

9
dog.plug Normal file
View file

@ -0,0 +1,9 @@
[Core]
Name = Dog
Module = dog
[Python]
Version = 3
[Documentation]
Description = Retrieve random dog images

25
dog.py Normal file
View file

@ -0,0 +1,25 @@
import logging
import json
from errbot import botcmd, BotPlugin
import requests
class Dog(BotPlugin):
"""Get random dog image URLs"""
BASE_URL = 'https://dog.ceo/api'
@botcmd
def doggo(self, msg, args):
url = '{}/breeds/image/random'.format(self.BASE_URL)
try:
resp = requests.get(url)
resp.raise_for_status()
except requests.exceptions.HTTPError as e:
logging.debug(e)
return 'Unable to return a dog image'
return resp.json()['message']

1
requirements.txt Normal file
View file

@ -0,0 +1 @@
requests==2.18.4