added all files

This commit is contained in:
nanometer5088
2023-03-17 06:20:59 -03:00
parent 71d4348048
commit 063ba4a8d0
5 changed files with 64 additions and 0 deletions

3
.gitignore vendored
View File

@@ -127,3 +127,6 @@ dmypy.json
# Pyre type checker
.pyre/
# Project-specific files
PyWhatKit_DB.txt

BIN
example.xlsx Normal file

Binary file not shown.

13
main.py Normal file
View File

@@ -0,0 +1,13 @@
import pywhatkit
import time
from src.file import read_excel_file, saudacao
from src.contants import MESSAGE
file_path = "example.xlsx"
name, phone_no, sex, messages = read_excel_file(file_path)
for i in range(len(phone_no)):
message = f"{saudacao()}, {name[i]}.\n{MESSAGE[f'{int(messages[i])}']}"
pywhatkit.sendwhatmsg_instantly(phone_no[i], message, tab_close=True)
time.sleep(3)

7
src/contants.py Normal file
View File

@@ -0,0 +1,7 @@
MESSAGE = {
"1": "lorem ipsum 1",
"2": "lorem ipsum 2",
"3": "lorem ipsum 3",
"4": "lorem ipsum 4",
"5": "lorem ipsum 5"
}

41
src/file.py Normal file
View File

@@ -0,0 +1,41 @@
import openpyxl
def read_excel_file(filename):
# Load the workbook
wb = openpyxl.load_workbook(filename)
# Select the active worksheet
ws = wb.active
# Create empty lists to store the data
names = []
phones = []
sexes = []
messages = []
# Iterate through each row (excluding the first row)
for row in ws.iter_rows(min_row=2, values_only=True):
# Extract the data from the columns
name = row[0]
phone = row[1]
sex = row[2]
message = row[3]
# Append the data to the relevant list
names.append(name)
phones.append("+" + str(phone))
sexes.append(sex)
messages.append(str(message))
# Return the sorted lists
return names, phones, sexes, messages
def saudacao():
import datetime
hour = int(f"{datetime.datetime.now()}".split()[1].split(":")[0])
if hour >= 18 or hour < 6:
return "Boa noite"
elif hour >= 6 and hour < 12:
return "Bom dia"
elif hour >= 12 and hour < 18:
return "Boa tarde"