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 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)

View File

@ -1,3 +1,4 @@
# Telegram bot token, as [BotFather](http://tg.me/BotFather) sends it.
TG_TOKEN = '<getthisfrombotfather>'
# 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,
}
}
VIA_SCHEME = 'http'
VIA_HOST = 'localhost:5000'