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
522e45a4
Valider
522e45a4
rédigé
Il y a 4 ans
par
Tulir Asokan
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
Store IDs as strings and keep all emoticons. Fixes #12
parent
c106c99b
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Modifications
1
Afficher les modifications d'espaces
En ligne
Côte à côte
Affichage de
1 fichier modifié
import.py
+21
-14
21 ajouts, 14 suppressions
import.py
avec
21 ajouts
et
14 suppressions
import.py
+
21
−
14
Voir le fichier @
522e45a4
...
@@ -18,7 +18,7 @@ from PIL import Image
...
@@ -18,7 +18,7 @@ from PIL import Image
from
telethon
import
TelegramClient
from
telethon
import
TelegramClient
from
telethon.tl.functions.messages
import
GetAllStickersRequest
,
GetStickerSetRequest
from
telethon.tl.functions.messages
import
GetAllStickersRequest
,
GetStickerSetRequest
from
telethon.tl.types.messages
import
AllStickers
from
telethon.tl.types.messages
import
AllStickers
from
telethon.tl.types
import
InputStickerSetShortName
,
Document
from
telethon.tl.types
import
InputStickerSetShortName
,
Document
,
DocumentAttributeSticker
from
telethon.tl.types.messages
import
StickerSet
as
StickerSetFull
from
telethon.tl.types.messages
import
StickerSet
as
StickerSetFull
parser
=
argparse
.
ArgumentParser
()
parser
=
argparse
.
ArgumentParser
()
...
@@ -71,6 +71,9 @@ async def upload(data: bytes, mimetype: str, filename: str) -> str:
...
@@ -71,6 +71,9 @@ async def upload(data: bytes, mimetype: str, filename: str) -> str:
if
TYPE_CHECKING
:
if
TYPE_CHECKING
:
from
typing
import
TypedDict
class
MatrixMediaInfo
(
TypedDict
):
class
MatrixMediaInfo
(
TypedDict
):
w
:
int
w
:
int
h
:
int
h
:
int
...
@@ -110,8 +113,12 @@ async def reupload_document(client: TelegramClient, document: Document) -> 'Matr
...
@@ -110,8 +113,12 @@ async def reupload_document(client: TelegramClient, document: Document) -> 'Matr
else
:
else
:
width
=
int
(
width
/
(
height
/
256
))
width
=
int
(
width
/
(
height
/
256
))
height
=
256
height
=
256
body
=
""
for
attr
in
document
.
attributes
:
if
isinstance
(
attr
,
DocumentAttributeSticker
):
body
=
attr
.
alt
return
{
return
{
"
body
"
:
""
,
"
body
"
:
body
,
"
url
"
:
mxc
,
"
url
"
:
mxc
,
"
info
"
:
{
"
info
"
:
{
"
w
"
:
width
,
"
w
"
:
width
,
...
@@ -163,7 +170,7 @@ async def reupload_pack(client: TelegramClient, pack: StickerSetFull) -> None:
...
@@ -163,7 +170,7 @@ async def reupload_pack(client: TelegramClient, pack: StickerSetFull) -> None:
try
:
try
:
with
open
(
pack_path
)
as
pack_file
:
with
open
(
pack_path
)
as
pack_file
:
existing_pack
=
json
.
load
(
pack_file
)
existing_pack
=
json
.
load
(
pack_file
)
already_uploaded
=
{
sticker
[
"
net.maunium.telegram.sticker
"
][
"
id
"
]:
sticker
already_uploaded
=
{
int
(
sticker
[
"
net.maunium.telegram.sticker
"
][
"
id
"
]
)
:
sticker
for
sticker
in
existing_pack
[
"
stickers
"
]}
for
sticker
in
existing_pack
[
"
stickers
"
]}
print
(
f
"
Found
{
len
(
already_uploaded
)
}
already reuploaded stickers
"
)
print
(
f
"
Found
{
len
(
already_uploaded
)
}
already reuploaded stickers
"
)
except
FileNotFoundError
:
except
FileNotFoundError
:
...
@@ -176,26 +183,26 @@ async def reupload_pack(client: TelegramClient, pack: StickerSetFull) -> None:
...
@@ -176,26 +183,26 @@ async def reupload_pack(client: TelegramClient, pack: StickerSetFull) -> None:
print
(
f
"
Skipped reuploading
{
document
.
id
}
"
)
print
(
f
"
Skipped reuploading
{
document
.
id
}
"
)
except
KeyError
:
except
KeyError
:
reuploaded_documents
[
document
.
id
]
=
await
reupload_document
(
client
,
document
)
reuploaded_documents
[
document
.
id
]
=
await
reupload_document
(
client
,
document
)
reuploaded_documents
[
document
.
id
][
"
net.maunium.telegram.sticker
"
]
=
{
for
sticker
in
pack
.
packs
:
for
document_id
in
sticker
.
documents
:
doc
=
reuploaded_documents
[
document_id
]
doc
[
"
body
"
]
=
sticker
.
emoticon
doc
[
"
net.maunium.telegram.sticker
"
]
=
{
"
pack
"
:
{
"
pack
"
:
{
"
id
"
:
pack
.
set
.
id
,
"
id
"
:
str
(
pack
.
set
.
id
)
,
"
short_name
"
:
pack
.
set
.
short_name
,
"
short_name
"
:
pack
.
set
.
short_name
,
},
},
"
id
"
:
document
_
id
,
"
id
"
:
str
(
document
.
id
)
,
"
emoticon
"
:
sticker
.
emoticon
,
"
emoticon
s
"
:
[]
,
}
}
for
sticker
in
pack
.
packs
:
for
document_id
in
sticker
.
documents
:
doc
=
reuploaded_documents
[
document_id
]
doc
[
"
net.maunium.telegram.sticker
"
][
"
emoticons
"
].
append
(
sticker
.
emoticon
)
with
open
(
pack_path
,
"
w
"
)
as
pack_file
:
with
open
(
pack_path
,
"
w
"
)
as
pack_file
:
json
.
dump
({
json
.
dump
({
"
title
"
:
pack
.
set
.
title
,
"
title
"
:
pack
.
set
.
title
,
"
short_name
"
:
pack
.
set
.
short_name
,
"
short_name
"
:
pack
.
set
.
short_name
,
"
id
"
:
pack
.
set
.
id
,
"
id
"
:
str
(
pack
.
set
.
id
)
,
"
hash
"
:
pack
.
set
.
hash
,
"
hash
"
:
str
(
pack
.
set
.
hash
)
,
"
stickers
"
:
list
(
reuploaded_documents
.
values
()),
"
stickers
"
:
list
(
reuploaded_documents
.
values
()),
},
pack_file
,
ensure_ascii
=
False
)
},
pack_file
,
ensure_ascii
=
False
)
print
(
f
"
Saved
{
pack
.
set
.
title
}
as
{
pack
.
set
.
short_name
}
.json
"
)
print
(
f
"
Saved
{
pack
.
set
.
title
}
as
{
pack
.
set
.
short_name
}
.json
"
)
...
...
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
Veuillez vous
inscrire
ou vous
se connecter
pour commenter