Skip to content

Commit

Permalink
update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
gotlium committed Feb 15, 2016
1 parent 65dd91b commit 98c80c5
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docs/deploy.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Login as `matterbot`::
sudo -i -u matterbot


Clone your project::
Clone your project (before create git repository with `settings.py`)::

$ git clone https://github.com/USER/REPO.git ~/mybot

Expand Down
46 changes: 46 additions & 0 deletions docs/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,49 @@ Run the bot::

$ MATTERMOST_BOT_SETTINGS_MODULE=settings matterbot


Integration with Django
-----------------------

Create bot_settings on your project and after you can create `django` command::

import logging
import sys

from django.core.management.base import BaseCommand
from django.conf import settings

from mattermost_bot import bot, settings


class Command(BaseCommand):

def handle(self, **options):

logging.basicConfig(**{
'format': '[%(asctime)s] %(message)s',
'datefmt': '%m/%d/%Y %H:%M:%S',
'level': logging.DEBUG if settings.DEBUG else logging.INFO,
'stream': sys.stdout,
})

try:
b = bot.Bot()
b.run()
except KeyboardInterrupt:
pass


Modify `manage.py`::

#!/usr/bin/env python
import os
import sys

if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "project.settings")
os.environ.setdefault("MATTERMOST_BOT_SETTINGS_MODULE", "project.bot_settings")

from django.core.management import execute_from_command_line

execute_from_command_line(sys.argv)

0 comments on commit 98c80c5

Please sign in to comment.