Merge pull request 'allow for duplicate alter_text' (#15) from zincentimeter/stickerbridge:main into main

Reviewed-on: https://codeberg.org/Didek/stickerbridge/pulls/15
This commit is contained in:
Dawid Rejowski 2024-04-12 20:05:39 +00:00
commit 909ca1b0c1

View file

@ -15,6 +15,13 @@ class MatrixStickerset:
} }
def add_sticker(self, mxc_uri: str, alt_text: str): def add_sticker(self, mxc_uri: str, alt_text: str):
if alt_text in self._content['images']:
duplicate_counter = 1
alt_text = alt_text + '-' + str(duplicate_counter)
while (alt_text in self._content['images']):
duplicate_counter += 1
alt_text = alt_text.split('-')[0] + '-' + str(duplicate_counter)
print(alt_text)
self._content['images'][alt_text] = { self._content['images'][alt_text] = {
"url": mxc_uri, "url": mxc_uri,
"usage": ["sticker"] "usage": ["sticker"]