Create README and move host to config

This commit is contained in:
Sijmen 2017-11-10 17:31:12 +01:00
parent 46c401d82c
commit 87a179cf64
3 changed files with 15 additions and 4 deletions

8
README.md Normal file
View file

@ -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.*

5
api.py
View file

@ -1,8 +1,7 @@
import urllib.parse import urllib.parse
import aiohttp import aiohttp
SCHEME = 'http' from config import VIA_HOST, VIA_SCHEME
NETLOC = 'localhost:5000'
class ApiError(Exception): pass class ApiError(Exception): pass
@ -16,7 +15,7 @@ class InternalServerError(ApiError): pass
def build_url(path, query_args=None): def build_url(path, query_args=None):
query = urllib.parse.urlencode(query_args if query_args else {}) query = urllib.parse.urlencode(query_args if query_args else {})
parse_result = urllib.parse.ParseResult( parse_result = urllib.parse.ParseResult(
scheme=SCHEME, netloc=NETLOC, path=path, scheme=VIA_SCHEME, netloc=VIA_HOST, path=path,
params='', query=query, fragment='') params='', query=query, fragment='')
return urllib.parse.urlunparse(parse_result) return urllib.parse.urlunparse(parse_result)

View file

@ -1,3 +1,4 @@
# Telegram bot token, as [BotFather](http://tg.me/BotFather) sends it.
TG_TOKEN = '<getthisfrombotfather>' TG_TOKEN = '<getthisfrombotfather>'
# Dictionary from Telegram user ID to their via API access token. # Dictionary from Telegram user ID to their via API access token.
@ -9,3 +10,6 @@ USER_TOKENS = {
VIA_GROUPS = { VIA_GROUPS = {
-1020304050: 12, -1020304050: 12,
} }
VIA_SCHEME = 'http'
VIA_HOST = 'localhost:5000'