Skip to content

Commit

Permalink
Merge pull request #13 from ineshbose/updates
Browse files Browse the repository at this point in the history
Leap to v1.11.0
  • Loading branch information
ineshbose authored Aug 11, 2020
2 parents 9a3f57c + 70ceb40 commit 3fa8975
Show file tree
Hide file tree
Showing 63 changed files with 1,400 additions and 954 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,7 @@ dmypy.json
.pytype/

# Cython debug symbols
cython_debug/
cython_debug/

# Misc
*.key
2 changes: 1 addition & 1 deletion Procfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
web: gunicorn app:app
web: gunicorn --workers 1 run:app
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ Access tokens, keys, etc. have been hidden from the repository for obvious reaso
```python
import os

xyz = os.environ["XYZ_KEY"]
xyz = os.environ.get("XYZ_KEY")
```

You **must** replace these with your own. You can either just replace `os.environ[]` with the value (**this is discouraged**), or use
You **must** replace these with your own. You can either just replace `os.environ.get()` with the value (**this is discouraged**), or use

```sh
$ set XYZ_KEY="random_key_value"
Expand Down Expand Up @@ -92,7 +92,7 @@ cal_url = "link/to/timetable.ics" # University ICS link
```


Templates should also be tailored to your need. Go through the files in [templates](templates) and [static](static).
Templates should also be tailored to your need. Go through the files in [templates](https://github.com/ineshbose/boyd_bot_messenger/blob/master/boyd_bot/templates) and [static](https://github.com/ineshbose/boyd_bot_messenger/blob/master/boyd_bot/static).

### Deployment

Expand Down
Empty file removed __init__.py
Empty file.
158 changes: 0 additions & 158 deletions app.py

This file was deleted.

73 changes: 73 additions & 0 deletions boyd_bot/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import os
import logging
from flask import Flask, Blueprint


app = Flask(__name__)
app.logger.setLevel(logging.DEBUG)

app_url = os.environ.get("APP_URL", "http://127.0.0.1")
app.config["SECRET_KEY"] = os.environ.get("FLASK_KEY")

from . import _config

blueprint = Blueprint("boyd_bot", __name__, template_folder="templates")

from . import views
from .forms import *

webhook_token = os.environ.get("VERIFY_TOKEN")
wb_arg_name = os.environ.get("WB_ARG_NAME")


from .timetable import Timetable

timetable = Timetable(
"https://frontdoor.spa.gla.ac.uk/spacett/download/uogtimetable.ics"
)


from .services.guard import Guard

guard = Guard(key=os.environ.get("GUARD_KEY"))


from .services.database import Database

db = Database(
db_token=os.environ.get("DB_MAIN_TOKEN"),
key1=os.environ.get("DB_KEY1", "key1"),
key2=os.environ.get("DB_KEY2", "key2"),
)


from .services.parser import Parser

parser = Parser()


from .services.platform import Platform

platform = Platform(platform_token=os.environ.get("PLATFORM_TOKEN"))


def log(message):
app.logger.info(message)


from .app import *

app.register_blueprint(blueprint, url_prefix=app.config["URL_ROOT"])


@app.after_request
def secure_http_header(response):
response.headers[
"Strict-Transport-Security"
] = "max-age=31536000; includeSubDomains"
response.headers["Content-Security-Policy"] = "default-src * 'unsafe-inline'"
response.headers["X-Frame-Options"] = "SAMEORIGIN"
response.headers["X-Content-Type-Options"] = "nosniff"
response.headers["Referrer-Policy"] = "same-origin"
response.headers["Feature-Policy"] = "none"
return response
27 changes: 27 additions & 0 deletions boyd_bot/_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from . import app


# URL root for the app
app.config["URL_ROOT"] = "/"


# Template Option
app.config["TEMPLATES"] = {
"REG_FORM": "uni_theme_reg.html", # uni_theme or default
}


# Simple string messages that can be replaced
app.config["MSG"] = {
"REG_ACKNOWLEDGE": "Alrighty! We can get started. :D",
"SUCCESS_MSG": "Login successful! You can now close this page and chat to the bot.",
"ONE_TIME_DONE": "You were logged out and since we don't have your credentials, you'll have to register again!",
"ERROR_MSG": "I'm sorry, something went wrong understanding that. :(",
}


# Features you can switch on/off
app.config["FEATURES"] = {
"ONE_TIME_USE": True, # On-going issue (read https://github.com/ineshbose/boyd_bot_messenger/issues/8)
"DEMO": True, # Works for chatbots without platform user-accounts (eg Dialogflow Web Demo / Embedded)
}
Loading

0 comments on commit 3fa8975

Please sign in to comment.