Merge pull request #5 from nim65s/topic/pr/4

update aiohttp use and docs
This commit is contained in:
Guilhem Saurel 2021-05-30 22:12:57 +02:00 committed by GitHub
commit d3d5ea7df2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View file

@ -11,6 +11,8 @@ environment variables:
- `MATRIX_ID`: the user id of the bot on this server - `MATRIX_ID`: the user id of the bot on this server
- `MATRIX_PW`: the password for this user - `MATRIX_PW`: the password for this user
- `API_KEY`: a secret to share with the users of the service - `API_KEY`: a secret to share with the users of the service
- `HOST`: HOST to listen on, all interfaces if `''` (default).
- `PORT`: PORT to listed on, default to 4785.
## Dev ## Dev

View file

@ -18,7 +18,7 @@ from markdown import markdown
from nio import AsyncClient from nio import AsyncClient
from nio.exceptions import LocalProtocolError from nio.exceptions import LocalProtocolError
SERVER_ADDRESS = ('', int(os.environ.get('PORT', 4785))) SERVER_ADDRESS = (os.environ.get('INTERFACE', ''), int(os.environ.get('PORT', 4785)))
MATRIX_URL = os.environ.get('MATRIX_URL', 'https://matrix.org') MATRIX_URL = os.environ.get('MATRIX_URL', 'https://matrix.org')
MATRIX_ID = os.environ.get('MATRIX_ID', '@wwm:matrix.org') MATRIX_ID = os.environ.get('MATRIX_ID', '@wwm:matrix.org')
MATRIX_PW = os.environ['MATRIX_PW'] MATRIX_PW = os.environ['MATRIX_PW']
@ -46,7 +46,7 @@ async def handler(request):
if data['key'] != API_KEY: if data['key'] != API_KEY:
return create_json_response(HTTPStatus.UNAUTHORIZED, 'Invalid API key') return create_json_response(HTTPStatus.UNAUTHORIZED, 'Invalid API key')
room_id = str(request.rel_url)[1:] room_id = request.path[1:]
content = { content = {
'msgtype': 'm.text', 'msgtype': 'm.text',
'body': data['text'], 'body': data['text'],