Compare commits
No commits in common. "no-show-image-url" and "master" have entirely different histories.
no-show-im
...
master
@ -42,7 +42,6 @@ First, copy config.json.example to config.json. Then fill in the fields:
|
|||||||
* `hosts.bare`: Just the (sub)domain of the server.
|
* `hosts.bare`: Just the (sub)domain of the server.
|
||||||
* `user_id_format`: A Python `str.format`-style string to format user IDs as
|
* `user_id_format`: A Python `str.format`-style string to format user IDs as
|
||||||
* `db_url`: A SQLAlchemy URL for the database. See the [SQLAlchemy docs](http://docs.sqlalchemy.org/en/latest/core/engines.html).
|
* `db_url`: A SQLAlchemy URL for the database. See the [SQLAlchemy docs](http://docs.sqlalchemy.org/en/latest/core/engines.html).
|
||||||
* `print_url_with_image`: Set to `false` to disable sending the Matrix url of an image to Telegram.
|
|
||||||
|
|
||||||
**Synapse configuration**
|
**Synapse configuration**
|
||||||
|
|
||||||
|
@ -15,7 +15,5 @@
|
|||||||
"user_id_format": "@telegram_{}:DOMAIN.TLD",
|
"user_id_format": "@telegram_{}:DOMAIN.TLD",
|
||||||
"db_url": "sqlite:///database.db",
|
"db_url": "sqlite:///database.db",
|
||||||
|
|
||||||
"print_url_with_image": true,
|
|
||||||
|
|
||||||
"as_port": 5000
|
"as_port": 5000
|
||||||
}
|
}
|
||||||
|
@ -46,8 +46,6 @@ try:
|
|||||||
DATABASE_URL = CONFIG['db_url']
|
DATABASE_URL = CONFIG['db_url']
|
||||||
|
|
||||||
AS_PORT = CONFIG['as_port'] if 'as_port' in CONFIG else 5000
|
AS_PORT = CONFIG['as_port'] if 'as_port' in CONFIG else 5000
|
||||||
|
|
||||||
PRINT_URL_WITH_IMAGE = CONFIG['print_url_with_image'] if 'print_url_with_image' in CONFIG else True
|
|
||||||
except (OSError, IOError) as exception:
|
except (OSError, IOError) as exception:
|
||||||
print('Error opening config file:')
|
print('Error opening config file:')
|
||||||
print(exception)
|
print(exception)
|
||||||
@ -252,18 +250,13 @@ async def matrix_transaction(request):
|
|||||||
# Download the file
|
# Download the file
|
||||||
await download_matrix_file(url, content['body'])
|
await download_matrix_file(url, content['body'])
|
||||||
with open('/tmp/{}'.format(content['body']), 'rb') as img_file:
|
with open('/tmp/{}'.format(content['body']), 'rb') as img_file:
|
||||||
if PRINT_URL_WITH_IMAGE:
|
# Create the URL and shorten it
|
||||||
# Create the URL and shorten it
|
url_str = MATRIX_HOST_EXT + \
|
||||||
url_str = MATRIX_HOST_EXT + \
|
'_matrix/media/r0/download/{}{}' \
|
||||||
'_matrix/media/r0/download/{}{}' \
|
.format(url.netloc, quote(url.path))
|
||||||
.format(url.netloc, quote(url.path))
|
url_str = await shorten_url(url_str)
|
||||||
url_str = await shorten_url(url_str)
|
|
||||||
url_str = ' (' + url_str + ')'
|
|
||||||
else:
|
|
||||||
url_str = ''
|
|
||||||
|
|
||||||
caption = '<{}> {}{}'.format(displayname,
|
caption = '{} sent an image'.format(displayname)
|
||||||
content['body'], url_str)
|
|
||||||
response = await group.send_photo(img_file, caption=caption)
|
response = await group.send_photo(img_file, caption=caption)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
Loading…
Reference in New Issue
Block a user