From 87a179cf64a89a9040fdd6ff81bf78d1ea981e68 Mon Sep 17 00:00:00 2001 From: Sijmen Schoon Date: Fri, 10 Nov 2017 17:31:12 +0100 Subject: [PATCH] Create README and move host to config --- README.md | 8 ++++++++ api.py | 5 ++--- config.py.example | 6 +++++- 3 files changed, 15 insertions(+), 4 deletions(-) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..05ca40f --- /dev/null +++ b/README.md @@ -0,0 +1,8 @@ +# pimpybot + +## Set-up +Copy `config.py.example` to `config.py`, and edit it as the comments say. + +Then, create a virtualenv (or not), then run `pip3 install -r requirements.txt` + +*Note: pimpybot requires Python 3.6.* diff --git a/api.py b/api.py index 9428616..023cab3 100644 --- a/api.py +++ b/api.py @@ -1,8 +1,7 @@ import urllib.parse import aiohttp -SCHEME = 'http' -NETLOC = 'localhost:5000' +from config import VIA_HOST, VIA_SCHEME class ApiError(Exception): pass @@ -16,7 +15,7 @@ class InternalServerError(ApiError): pass def build_url(path, query_args=None): query = urllib.parse.urlencode(query_args if query_args else {}) parse_result = urllib.parse.ParseResult( - scheme=SCHEME, netloc=NETLOC, path=path, + scheme=VIA_SCHEME, netloc=VIA_HOST, path=path, params='', query=query, fragment='') return urllib.parse.urlunparse(parse_result) diff --git a/config.py.example b/config.py.example index b510948..199f875 100644 --- a/config.py.example +++ b/config.py.example @@ -1,3 +1,4 @@ +# Telegram bot token, as [BotFather](http://tg.me/BotFather) sends it. TG_TOKEN = '' # Dictionary from Telegram user ID to their via API access token. @@ -8,4 +9,7 @@ USER_TOKENS = { # Dictionary from Telegram to via group ID. VIA_GROUPS = { -1020304050: 12, -} \ No newline at end of file +} + +VIA_SCHEME = 'http' +VIA_HOST = 'localhost:5000'