Fix string and add file_name in vodynoi/gen_table.py
This commit is contained in:
parent
0a52d81b40
commit
a0fa90c915
2 changed files with 8 additions and 4 deletions
BIN
vodynoi/26.08-26.11.24.xlsx
Normal file
BIN
vodynoi/26.08-26.11.24.xlsx
Normal file
Binary file not shown.
|
|
@ -9,10 +9,14 @@ from dateutil.relativedelta import relativedelta
|
|||
# Load information for owencloud and telegram
|
||||
load_dotenv()
|
||||
|
||||
|
||||
to = int(datetime.now().timestamp()* 1000)
|
||||
from_ = int((datetime.now() - relativedelta(months=3)).timestamp()* 1000)
|
||||
to_formatted = (datetime.now())
|
||||
from_formatted = to_formatted - relativedelta(months=3)
|
||||
from_str = from_formatted.strftime('%d.%m')
|
||||
to_str = to_formatted.strftime('%d.%m.%y')
|
||||
file_name = f"{from_str}-{to_str}.xlsx"
|
||||
|
||||
def send_telegram():
|
||||
token = os.getenv("TELEGRAM_TOKEN")
|
||||
|
|
@ -21,8 +25,8 @@ def send_telegram():
|
|||
raise ValueError("Telegram токен или ID канала не заданы в .env")
|
||||
|
||||
url = f"https://api.telegram.org/bot{token}/sendDocument"
|
||||
comment = f"С: {from_formatted}\nДо: {to_formatted}"
|
||||
with open('tmp.xlsx', 'rb') as file:
|
||||
comment = f"Начало: {from_str}\nКонец: {to_str}"
|
||||
with open(file_name, 'rb') as file:
|
||||
r = requests.post(url, data={
|
||||
"chat_id": channel_id,
|
||||
"caption": comment
|
||||
|
|
@ -87,8 +91,8 @@ def main():
|
|||
return
|
||||
|
||||
#nswer = req.json()
|
||||
print("Now i save fia")
|
||||
with open('tmp.xlsx', 'wb') as ff:
|
||||
#print("Now i save fia")
|
||||
with open(file_name, 'wb') as ff:
|
||||
ff.write(req.content)
|
||||
|
||||
send_telegram()
|
||||
|
|
|
|||
Loading…
Reference in a new issue