Skip to content
GitLab
Explorer
Connexion
Navigation principale
Rechercher ou aller à…
Projet
stickerpicker
Gestion
Activité
Membres
Labels
Programmation
Tickets
Tableaux des tickets
Jalons
Wiki
Wiki externe
Code
Requêtes de fusion
Dépôt
Branches
Validations
Étiquettes
Graphe du dépôt
Comparer les révisions
Extraits de code
Compilation
Pipelines
Jobs
Planifications de pipeline
Artéfacts
Déploiement
Releases
Registre de paquets
Registre de conteneurs
Registre de modèles
Opération
Environnements
Modules Terraform
Surveillance
Incidents
Analyse
Données d'analyse des chaînes de valeur
Analyse des contributeurs
Données d'analyse CI/CD
Données d'analyse du dépôt
Expériences du modèle
Aide
Aide
Support
Documentation de GitLab
Comparer les forfaits GitLab
Forum de la communauté GitLab
Contribuer à GitLab
Donner votre avis
Raccourcis clavier
?
Extraits de code
Groupes
Projets
Afficher davantage de fils d'Ariane
salixor
stickerpicker
Validations
4ce90892
Valider
4ce90892
rédigé
6 sept. 2020
par
Tulir Asokan
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
Stop using ID field from telegram metadata in widget
parent
522e45a4
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Modifications
3
Afficher les modifications d'espaces
En ligne
Côte à côte
Affichage de
3 fichiers modifiés
import.py
+24
-13
24 ajouts, 13 suppressions
import.py
web/index.js
+1
-1
1 ajout, 1 suppression
web/index.js
web/widget-api.js
+4
-2
4 ajouts, 2 suppressions
web/widget-api.js
avec
29 ajouts
et
16 suppressions
import.py
+
24
−
13
Voir le fichier @
4ce90892
...
...
@@ -87,6 +87,7 @@ if TYPE_CHECKING:
body
:
str
url
:
str
info
:
MatrixMediaInfo
id
:
str
def
convert_image
(
data
:
bytes
)
->
(
bytes
,
int
,
int
):
...
...
@@ -113,12 +114,8 @@ async def reupload_document(client: TelegramClient, document: Document) -> 'Matr
else
:
width
=
int
(
width
/
(
height
/
256
))
height
=
256
body
=
""
for
attr
in
document
.
attributes
:
if
isinstance
(
attr
,
DocumentAttributeSticker
):
body
=
attr
.
alt
return
{
"
body
"
:
body
,
"
body
"
:
""
,
"
url
"
:
mxc
,
"
info
"
:
{
"
w
"
:
width
,
...
...
@@ -152,6 +149,21 @@ def add_to_index(name: str) -> None:
print
(
f
"
Added
{
name
}
to
{
index_path
}
"
)
def
add_meta
(
document
:
Document
,
info
:
'
MatrixStickerInfo
'
,
pack
:
StickerSetFull
)
->
None
:
for
attr
in
document
.
attributes
:
if
isinstance
(
attr
,
DocumentAttributeSticker
):
info
[
"
body
"
]
=
attr
.
alt
info
[
"
id
"
]
=
str
(
document
.
id
)
info
[
"
net.maunium.telegram.sticker
"
]
=
{
"
pack
"
:
{
"
id
"
:
str
(
pack
.
set
.
id
),
"
short_name
"
:
pack
.
set
.
short_name
,
},
"
id
"
:
str
(
document
.
id
),
"
emoticons
"
:
[],
}
async
def
reupload_pack
(
client
:
TelegramClient
,
pack
:
StickerSetFull
)
->
None
:
if
pack
.
set
.
animated
:
print
(
"
Animated stickerpacks are currently not supported
"
)
...
...
@@ -183,18 +195,17 @@ async def reupload_pack(client: TelegramClient, pack: StickerSetFull) -> None:
print
(
f
"
Skipped reuploading
{
document
.
id
}
"
)
except
KeyError
:
reuploaded_documents
[
document
.
id
]
=
await
reupload_document
(
client
,
document
)
reuploaded_documents
[
document
.
id
][
"
net.maunium.telegram.sticker
"
]
=
{
"
pack
"
:
{
"
id
"
:
str
(
pack
.
set
.
id
),
"
short_name
"
:
pack
.
set
.
short_name
,
},
"
id
"
:
str
(
document
.
id
),
"
emoticons
"
:
[],
}
# Always ensure the body and telegram metadata is correct
add_meta
(
document
,
reuploaded_documents
[
document
.
id
],
pack
)
for
sticker
in
pack
.
packs
:
if
not
sticker
.
emoticon
:
continue
for
document_id
in
sticker
.
documents
:
doc
=
reuploaded_documents
[
document_id
]
# If there was no sticker metadata, use the first emoji we find
if
doc
[
"
body
"
]
==
""
:
doc
[
"
body
"
]
=
sticker
.
emoticon
doc
[
"
net.maunium.telegram.sticker
"
][
"
emoticons
"
].
append
(
sticker
.
emoticon
)
with
open
(
pack_path
,
"
w
"
)
as
pack_file
:
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
web/index.js
+
1
−
1
Voir le fichier @
4ce90892
...
...
@@ -143,7 +143,7 @@ const Pack = ({ pack }) => html`
<h1>
${
pack
.
title
}
</h1>
<div class="sticker-list">
${
pack
.
stickers
.
map
(
sticker
=>
html
`
<
${
Sticker
}
key=
${
sticker
[
"
net.maunium.telegram.sticker
"
]
.
id
}
content=
${
sticker
}
/>
<
${
Sticker
}
key=
${
sticker
.
id
}
content=
${
sticker
}
/>
`
)}
</div>
</section>
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
web/widget-api.js
+
4
−
2
Voir le fichier @
4ce90892
...
...
@@ -35,17 +35,19 @@ window.onmessage = event => {
export
function
sendSticker
(
content
)
{
const
data
=
{
content
,
content
:
{...
content
}
,
// `name` is for Element Web (and also the spec)
// Element Android uses content -> body as the name
name
:
content
.
body
,
}
// Custom field that stores the ID even for non-telegram stickers
delete
data
.
content
.
id
// This is for Element iOS
const
widgetData
=
{
...
data
,
description
:
content
.
body
,
file
:
`
${
content
[
"
net.maunium.telegram.sticker
"
]
.
id
}
.png`
,
file
:
`
${
content
.
id
}
.png`
,
}
// Element iOS explodes if there are extra fields present
delete
widgetData
.
content
[
"
net.maunium.telegram.sticker
"
]
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
Aperçu
0%
Chargement en cours
Veuillez réessayer
ou
joindre un nouveau fichier
.
Annuler
You are about to add
0
people
to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Enregistrer le commentaire
Annuler
Please
se connecter
to comment