Implement no-show-image-url
This commit is contained in:
parent
af7731f00e
commit
f44c06daa0
@ -45,6 +45,8 @@ 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)
|
||||||
@ -249,13 +251,17 @@ 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:
|
||||||
# Create the URL and shorten it
|
if PRINT_URL_WITH_IMAGE:
|
||||||
url_str = MATRIX_HOST_EXT + \
|
# Create the URL and shorten it
|
||||||
'_matrix/media/r0/download/{}{}' \
|
url_str = MATRIX_HOST_EXT + \
|
||||||
.format(url.netloc, quote(url.path))
|
'_matrix/media/r0/download/{}{}' \
|
||||||
url_str = await shorten_url(url_str)
|
.format(url.netloc, quote(url.path))
|
||||||
|
url_str = await shorten_url(url_str)
|
||||||
|
url_str = ' (' + url_str + ')'
|
||||||
|
else:
|
||||||
|
url_str = ''
|
||||||
|
|
||||||
caption = '<{}> {} ({})'.format(displayname,
|
caption = '<{}> {}{}'.format(displayname,
|
||||||
content['body'], url_str)
|
content['body'], url_str)
|
||||||
response = await group.send_photo(img_file, caption=caption)
|
response = await group.send_photo(img_file, caption=caption)
|
||||||
except:
|
except:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user