Add json for save the name files upload.

This commit is contained in:
stef-devs 2022-06-24 11:24:26 +02:00
parent 18bd748b74
commit c7e7810bc5
2 changed files with 14 additions and 1 deletions

4
.gitignore vendored
View File

@ -5,4 +5,6 @@ music_cache
nuvola.py nuvola.py
debug.log debug.log
nuvola.txt nuvola.txt
test.py test.py
*.pdf
data.json

View File

@ -21,6 +21,7 @@ import deepl
import spotipy import spotipy
import pyshorteners import pyshorteners
import pdf2docx import pdf2docx
import ndjson
from random import randint from random import randint
from random import random from random import random
from fileinput import filename from fileinput import filename
@ -372,6 +373,7 @@ def cloud(message):
bot.register_next_step_handler(sent_msg, cloud_step) bot.register_next_step_handler(sent_msg, cloud_step)
def cloud_step(message): def cloud_step(message):
id = message.from_user.id
file_name = message.document.file_name file_name = message.document.file_name
file_info = bot.get_file(message.document.file_id) file_info = bot.get_file(message.document.file_id)
downloaded_file = bot.download_file(file_info.file_path) downloaded_file = bot.download_file(file_info.file_path)
@ -389,5 +391,14 @@ def cloud_step(message):
os.replace(file_name, 'cloud/'+file_name) os.replace(file_name, 'cloud/'+file_name)
bot.send_message(message.chat.id, "Il tuo file è stato caricato con successo! Ecco l'id del tuo file "+new_name) bot.send_message(message.chat.id, "Il tuo file è stato caricato con successo! Ecco l'id del tuo file "+new_name)
bot.send_message(message.chat.id, "Se vuoi scaricare il file fai /cloud download + l'id del file") bot.send_message(message.chat.id, "Se vuoi scaricare il file fai /cloud download + l'id del file")
dic_exm ={
"filename" : new_name,
"user_id" : id,
}
with open('data.json', 'a') as f:
json.dump(dic_exm, f, indent=2)
f.write('\n')
bot.polling() bot.polling()