commit 7dc839c1dd7c0765282cc09897d6cd419c36dfeb Author: Jared McKnight Date: Tue Feb 13 19:44:03 2018 -0500 initial commit diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..e949e54 --- /dev/null +++ b/.editorconfig @@ -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 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7bbc71c --- /dev/null +++ b/.gitignore @@ -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/ diff --git a/dog.plug b/dog.plug new file mode 100644 index 0000000..4ebafa5 --- /dev/null +++ b/dog.plug @@ -0,0 +1,9 @@ +[Core] +Name = Dog +Module = dog + +[Python] +Version = 3 + +[Documentation] +Description = Retrieve random dog images diff --git a/dog.py b/dog.py new file mode 100644 index 0000000..79e247b --- /dev/null +++ b/dog.py @@ -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'] diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..271baf7 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +requests==2.18.4