From 6006f4cf759c76b4d52a49c2093087c816557dd1 Mon Sep 17 00:00:00 2001 From: stef-devs Date: Sat, 18 Jun 2022 11:58:15 +0200 Subject: [PATCH] Create .env for token and password --- .gitignore | 4 +++- index.py | 13 ++++++++----- nuvola.py | 0 requirements.txt | 23 +++++++++++++---------- 4 files changed, 24 insertions(+), 16 deletions(-) create mode 100644 nuvola.py diff --git a/.gitignore b/.gitignore index d43b421..7a54a3e 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ -ffmpeg.exe \ No newline at end of file +ffmpeg.exe +.env +test.py \ No newline at end of file diff --git a/index.py b/index.py index 18bb4c3..9c635d4 100644 --- a/index.py +++ b/index.py @@ -17,6 +17,7 @@ import json import goslate import urllib.request import urllib.parse +from dotenv import load_dotenv from yt_dlp import YoutubeDL from platform import system from tqdm.auto import tqdm @@ -28,7 +29,8 @@ from pytube import YouTube from bs4 import BeautifulSoup from gc import callbacks -API_TOKEN = '5407819601:AAEfiaw8ZNlyBHftLsJR5VAcMyv257tWHMY' +load_dotenv() +API_TOKEN = os.getenv('BOT_TOKEN') bot = telebot.TeleBot(API_TOKEN) print("Il bot si è avviato con successo!") @@ -95,13 +97,14 @@ def meteo(pm): def meteo_step(message): city = message.text - response = requests.get("https://api.openweathermap.org/data/2.5/weather?q="+city+",it&APPID=dd9c01763daea0b5539db05fbfbe4cb6").json() + token_weather = os.environ.get('WEATHER_TOKEN') + response = requests.get("https://api.openweathermap.org/data/2.5/weather?q="+city+",it&APPID="+token_weather).json() + print(response) weather = response['weather'][0]['main'] temp = response['main']['temp'] - weather_translate = goslate.Goslate(service_urls=['https://translate.google.it']).translate(weather, 'it') temp = temp - 273.15 bot.send_message(message.chat.id, "🌡️ La temperatura in " + city + " è di " + str(temp) + "°C") - bot.send_message(message.chat.id, "🌧️ La condizione è " + weather_translate) + bot.send_message(message.chat.id, "🌧️ La condizione è " + weather) #Command /stats @bot.message_handler(commands=['stats']) @@ -134,7 +137,7 @@ def pastebin_step(message): chat = message.chat.id text = message.text site = 'https://pastebin.com/api/api_post.php' - dev_key = 'V701_05L-yFOUH_0J24VFiJQQ1WwHrbO' + dev_key = os.environ.get('PASTEBIN_TOKEN') code = text our_data = urllib.parse.urlencode({"api_dev_key": dev_key, "api_option": "paste", "api_paste_code": code}) our_data = our_data.encode() diff --git a/nuvola.py b/nuvola.py new file mode 100644 index 0000000..e69de29 diff --git a/requirements.txt b/requirements.txt index 4598d87..e37656c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,12 +1,12 @@ # Automatically generated by https://github.com/damnever/pigar. -# D:\Progetti Github\RetniNet\index.py: 27 +# D:\Progetti Github\RetniNet\index.py: 29 bs4 == 0.0.1 -# D:\Progetti Github\RetniNet\index.py: 18 +# D:\Progetti Github\RetniNet\index.py: 17 goslate == 1.5.4 -# D:\Progetti Github\RetniNet\index.py: 24 +# D:\Progetti Github\RetniNet\index.py: 26 jmespath == 1.0.0 # D:\Progetti Github\RetniNet\index.py: 1 @@ -15,23 +15,26 @@ psutil == 5.9.1 # D:\Progetti Github\RetniNet\index.py: 3 pyfiglet == 0.8.post1 -# D:\Progetti Github\RetniNet\index.py: 11 +# D:\Progetti Github\RetniNet\index.py: 20 +python_dotenv == 0.20.0 + +# D:\Progetti Github\RetniNet\index.py: 10 python_ffmpeg == 1.0.14 -# D:\Progetti Github\RetniNet\index.py: 14 +# D:\Progetti Github\RetniNet\index.py: 13 python_weather == 0.3.7 -# D:\Progetti Github\RetniNet\index.py: 26 +# D:\Progetti Github\RetniNet\index.py: 28 pytube == 12.1.0 -# D:\Progetti Github\RetniNet\index.py: 13,16 +# D:\Progetti Github\RetniNet\index.py: 12,15 requests == 2.28.0 -# D:\Progetti Github\RetniNet\index.py: 25 +# D:\Progetti Github\RetniNet\index.py: 27 telebot == 0.0.4 -# D:\Progetti Github\RetniNet\index.py: 21 +# D:\Progetti Github\RetniNet\index.py: 23 tqdm == 4.64.0 -# D:\Progetti Github\RetniNet\index.py: 19 +# D:\Progetti Github\RetniNet\index.py: 21 yt_dlp == 2022.5.18