Now it's all about .env - I started making Whatsapp bot

This commit is contained in:
Stefano Assenzo 2023-01-28 17:39:21 +00:00 committed by GitHub
parent 76af099702
commit 23ac13f5d1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 2 deletions

View File

@ -14,4 +14,12 @@ DOWNLOAD_FOLDER = ""
USERNAME_NUVOLA = ""
PASSWORD_NUVOLA = ""
DISCORD_TOKEN = ""
# Discord
DISCORD_TOKEN = ""
GENERAL_ID = ""
# Whatsapp
SID = ""
AUTHTOKEN = ""
PHONE_NUMBER_BOT = ""
PHONE_NUMBER_PERSONAL = ""

View File

@ -18,6 +18,7 @@ import time
load_dotenv() # Load .env file
DISCORD_TOKEN = os.getenv('DISCORD_TOKEN') # Discord token
GENERAL_ID = os.getenv('GENERAL_ID') # Channel ID
PASSWORD_MONGODB = os.getenv('PASSWORD_MONGODB') # Password for MongoDB
URL_MONGODB = os.getenv('URL_MONGODB') # URL for MongoDB
mongo_url = "mongodb+srv://elci:" + urllib.parse.quote_plus(PASSWORD_MONGODB) + URL_MONGODB # URL for MongoDB (with password)
@ -68,7 +69,7 @@ async def orario():
send_screenshot += 1
else:
pass
channel = bot.get_channel(1063753802638954519)
channel = bot.get_channel(GENERAL_ID)
await channel.send(f"Day: {day}, Hour school: {i}, Subject found: {subject['Subject']} at index: {i}")
send_screenshot = 0

View File

@ -0,0 +1,13 @@
from twilio.rest import Client
import os
SID = os.getenv('SID')
AUTH_TOKEN = os.getenv('AUTHTOKEN')
PHONE_NUMBER_BOT = os.getenv('PHONE_NUMBER_BOT')
PHONE_NUMBER_PERSONAL = os.getenv('PHONE_NUMBER_PERSONAL')
client = Client(SID, AUTH_TOKEN)
message=client.messages.create(to=PHONE_NUMBER_PERSONAL,
from_=PHONE_NUMBER_BOT,
body="Hello from Python!")