Skip to content

Commit

Permalink
Merge pull request #48 from OrBin/dev
Browse files Browse the repository at this point in the history
Merging dev to master (for version 1.0.6)
  • Loading branch information
meirhalachmi committed Mar 20, 2019
2 parents 180d793 + 87a2a55 commit 7020572
Show file tree
Hide file tree
Showing 55 changed files with 985 additions and 157 deletions.
3 changes: 1 addition & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
token*.txt
users.json
*.log
6 changes: 2 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,5 @@ venv.bak/
**/.idea

# Project-specific ignores
token*.txt
users.json
gramhopper/rule_handlers.py
rules.yml
*.log
pytype_output/**
5 changes: 5 additions & 0 deletions .pylintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[basic]
disable=missing-docstring

[design]
min-public-methods=1
45 changes: 45 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
dist: xenial
language: python
python:
- 3.7
install:
- pip install -r requirements.txt
- pip install pylint flake8 pytype pytest
- cp -R tests/assets/.gramhopper ~/.gramhopper

stages:
- lint
- test

- name: build
if: (branch != master && tag IS blank) || type != push

- name: deploy docker image
if: (branch = master || tag IS present) && type = push

jobs:
include:
- stage: lint
script:
- pylint ./*.py ./gramhopper
- pylint --rcfile=./tests/tests.pylintrc ./tests
- flake8 --exclude=venv
- pytype --config ./setup.cfg -V $TRAVIS_PYTHON_VERSION ./*.py ./gramhopper
- stage: test
script:
- pytest
- stage: build
script:
- python setup.py sdist bdist_wheel
- docker build -t $DOCKER_IMAGE_NAME .
- stage: deploy docker image
script:
- |
if [ ! -z "$TRAVIS_TAG" ]; then
export IMAGE_TAG=$TRAVIS_TAG
else
export IMAGE_TAG='latest'
fi
- docker build -t $DOCKER_IMAGE_NAME:$IMAGE_TAG .
- echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
- docker push $DOCKER_IMAGE_NAME:$IMAGE_TAG
14 changes: 10 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
FROM python:3.7-alpine
FROM python:3.7-slim as builder

COPY . /app
WORKDIR /app/bot_engine
RUN pip install -r ../requirements.txt
WORKDIR /app/
RUN python setup.py bdist_wheel

CMD python bot.py

FROM python:3.7-slim

COPY --from=builder /app/dist/gramhopper-*.whl /
RUN pip install /gramhopper-*.whl && rm /gramhopper-*.whl

CMD gramhopper
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,18 @@
A bot platform for automatic responses based on various triggers.

## Install
#### Using pip
Install the latest version:

```bash
$ pip install gramhopper
```

#### Using docker
Pull the latest image:
```bash
$ docker pull orbin/gramhopper:latest
```

## Configure

### Create a bot
Expand Down Expand Up @@ -109,6 +115,13 @@ will yield the following conversation:

## Run
To run gramhopper, just run:
#### From installed package

```bash
$ gramhopper
```

#### From docker image
```bash
$ docker run -it -v /your/configuration/dir:/root/.gramhopper orbin/gramhopper:latest
```
Empty file added __init__.py
Empty file.
20 changes: 20 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
SPHINXPROJ = gramhopper
SOURCEDIR = source
BUILDDIR = build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
36 changes: 36 additions & 0 deletions docs/make.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
@ECHO OFF

pushd %~dp0

REM Command file for Sphinx documentation

if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=source
set BUILDDIR=build
set SPHINXPROJ=gramhopper

if "%1" == "" goto help

%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.http://sphinx-doc.org/
exit /b 1
)

%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%
goto end

:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%

:end
popd
161 changes: 161 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
# -*- coding: utf-8 -*-
#
# Configuration file for the Sphinx documentation builder.
#
# This file does only contain a selection of the most common options. For a
# full list see the documentation:
# http://www.sphinx-doc.org/en/master/config

# -- Path setup --------------------------------------------------------------

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
import os
import sys
sys.path.insert(0, os.path.abspath('../..'))
sys.path.insert(0, os.path.abspath('../../gramhopper/'))


# -- Project information -----------------------------------------------------

project = 'gramhopper'
copyright = '2019, Or Bin, Meir Halachmi'
author = 'Or Bin, Meir Halachmi'

# The short X.Y version
version = ''
# The full version, including alpha/beta/rc tags
release = '1.0.4'


# -- General configuration ---------------------------------------------------

# If your documentation needs a minimal Sphinx version, state it here.
#
# needs_sphinx = '1.0'

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.coverage',
]

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
#
# source_suffix = ['.rst', '.md']
source_suffix = '.rst'

# The master toctree document.
master_doc = 'index'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path .
exclude_patterns = []

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'


# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'sphinx_rtd_theme'

# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#
# html_theme_options = {}

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']

# Custom sidebar templates, must be a dictionary that maps document names
# to template names.
#
# The default sidebars (for documents that don't match any pattern) are
# defined by theme itself. Builtin themes are using these templates by
# default: ``['localtoc.html', 'relations.html', 'sourcelink.html',
# 'searchbox.html']``.
#
# html_sidebars = {}


# -- Options for HTMLHelp output ---------------------------------------------

# Output file base name for HTML help builder.
htmlhelp_basename = 'gramhopperdoc'


# -- Options for LaTeX output ------------------------------------------------

latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#
# 'papersize': 'letterpaper',

# The font size ('10pt', '11pt' or '12pt').
#
# 'pointsize': '10pt',

# Additional stuff for the LaTeX preamble.
#
# 'preamble': '',

# Latex figure (float) alignment
#
# 'figure_align': 'htbp',
}

# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'gramhopper.tex', 'gramhopper Documentation',
'Or Bin, Meir Halachmi', 'manual'),
]


# -- Options for manual page output ------------------------------------------

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'gramhopper', 'gramhopper Documentation',
[author], 1)
]


# -- Options for Texinfo output ----------------------------------------------

# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'gramhopper', 'gramhopper Documentation',
author, 'gramhopper', 'One line description of project.',
'Miscellaneous'),
]


# -- Extension configuration -------------------------------------------------
13 changes: 13 additions & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.. gramhopper documentation master file, created by
sphinx-quickstart on Tue Feb 12 20:44:58 2019.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Welcome to gramhopper's documentation!
======================================

.. toctree::
:caption: Content

triggers/index
responses/index
6 changes: 6 additions & 0 deletions docs/source/responses/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Responses
=========

.. toctree::
match-responses
preset-responses
23 changes: 23 additions & 0 deletions docs/source/responses/match-responses.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Match Responses
===============
There are some matched-based responses, which should normally come after a regexp trigger

.. TODO link to regexp trigger doc here.
.. autoclass:: gramhopper.responses.match_responses.MatchResponses
:members:

match.message
-------------
.. autoclass:: gramhopper.responses.match_responses._MatchMessageResponse
:members:

.. automethod:: __init__


match.reply
-----------
.. autoclass:: gramhopper.responses.match_responses._MatchReplyResponse
:members:

.. automethod:: __init__

0 comments on commit 7020572

Please sign in to comment.