Merge branch 'master' of bitbucket.org:panleicim/appointment_tool

This commit is contained in:
2024-09-26 22:15:37 +02:00
10 changed files with 60 additions and 27 deletions
+3
View File
@@ -4,10 +4,13 @@ pojo/__pycache__/
appointment.log
utils/*.log
.~contact.xlsx
*.xlsx
*.so
.env
./venv
out
lib
*.txt
appointment_*.log
./build
venv
+1
View File
@@ -14,6 +14,7 @@ from src.pojo.mail.mail_pojo import MailAddress
from src.pojo.users.regisered_user_pojo import RegisteredUserPojo
MONGO_DB_URL = "mongo.lpaconsulting.fr"
# MONGO_DB_URL = "clusterfr.zlmpq.mongodb.net"
CAPTCHA_ERROR_COLLECTION_PREFIX = "CAPTCHA_ERROR_"
BLACK_LIST = "BLACK_LIST"
ACCEPTED_APPOINTMENT_LIST = "ACCEPTED_APPOINTMENT_LIST"
+5 -15
View File
@@ -10,14 +10,14 @@ from builtins import list
from src.db.mongo_manager import MONGO_STORE_MANAGER
from src.logs.AppLogging import init_logger
from src.mail.mail_constants import DOMAIN_163, DOMAIN_YAHOO, DOMAIN_SINA, IMAP_SERVER_163, YAHOO_IMAP_SERVER, \
IMAP_SERVER_SINA, AOL_IMAP_SERVER
IMAP_SERVER_SINA, AOL_IMAP_SERVER, create_imap
from src.pojo.accepted_appointment_pojo import AcceptedAppointmentPojo
from src.pojo.mail.mail_pojo import MailPojo
INVOICE_SUBJECT_fr = 'Votre facture'
INVOICE_SUBJECT_EN = 'Your invoice'
VALIDATION_URL_REGEX = """https:\/\/rendezvousparis.hermes.com\/client\/register\/[A-Z0-9]+\/validate.code=[A-Z0-9]+"""
HERMES_INVOICE_EMAIL = "no-reply@ereceipt.hermes.com"
HERMES_INVOICE_EMAIL = "no-reply@hermes.com"
date_format = "%d-%b-%Y" # DD-Mon-YYYY e.g., 3-Mar-2014
@@ -33,20 +33,9 @@ class InvoiceGetter():
l = i.decode().split(' "/" ')
print(l[0] + " = " + l[1])
def create_imap(self):
# create an IMAP4 class with SSL
if DOMAIN_163 in self.login:
imap = imaplib.IMAP4_SSL(IMAP_SERVER_163)
elif DOMAIN_YAHOO in self.login:
imap = imaplib.IMAP4_SSL(YAHOO_IMAP_SERVER)
elif DOMAIN_SINA in self.login:
imap = imaplib.IMAP4_SSL(IMAP_SERVER_SINA)
else:
imap = imaplib.IMAP4_SSL(AOL_IMAP_SERVER)
return imap
def read_emails(self, mails_messages: list) -> list:
imap = self.create_imap()
imap = create_imap(self.login)
# authenticate
type, dat = imap.login(self.login, self.password)
@@ -128,7 +117,8 @@ def get_invoices():
# get email address
mail_list = MONGO_STORE_MANAGER.get_destination_emails()
mail_list_to_check = []
yesterday = str(datetime.date.today() - datetime.timedelta(days=1))
# yesterday = str(datetime.date.today() - datetime.timedelta(days=2))
yesterday = str(datetime.date.today())
collection = MONGO_STORE_MANAGER.get_accepted_items_for_one_day(yesterday)
for valid_appointment in collection:
accepted_pojo = AcceptedAppointmentPojo.from_reserve(valid_appointment)
+1 -1
View File
@@ -58,7 +58,7 @@ if __name__ == '__main__':
# remove_invalid_email()
mail_list = MONGO_STORE_MANAGER.get_destination_emails()
# excel_reader = ExcelHelper()ge
# excel_reader = ExcelHelper()
# mail_list = excel_reader.read_mails_and_pwd(file_name="/Users/lpan/Downloads/hotmail_list.xlsx")
# mail_address1 = MailAddress(mail="christinnyua@gmx.net", password="q1J1HHY2sXN")
# mail_list = [mail_address1]
+3 -1
View File
@@ -155,7 +155,7 @@ def accept_appointment_found(accepted_result_list: list):
for user in _all_register_account:
if user.mail == result.email:
result.account_password = user.password
mailer.send_email(result, to_all=True)
mailer.send_email(result, to_all=False)
MONGO_STORE_MANAGER.update_reserve_result(reserve.id, ResultEnum.ACCEPTED, reserve.message)
# sginal.send_result(result)
@@ -172,8 +172,10 @@ def find_confirmation_contacts_for_today():
for _item in _all_appointments_today:
for _mail in _all_mail_list:
if _mail.mail == _item.mail:
if _item.url_validated is True:
_mail_list_to_scan.append(_mail)
break
print("Found {} emails to scan".format(len(_mail_list_to_scan)))
return _mail_list_to_scan
+1 -1
View File
@@ -24,7 +24,7 @@ HERMES_EMAIL = "no-reply@hermes.com"
EMAIL_ADDRESS_REGEX = r'\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,7}\b'
date_format = "%d-%b-%Y" # DD-Mon-YYYY e.g., 3-Mar-2014
REDIRECTION_MAILS = "chenpeijun@aol.com,hongjiang176@aol.com,ciyuexie@aol.com,rutger.62@aol.com,ciccidaniel@aol.com,armasgoodman@aol.com,wknd.gemerine@aol.com,rafmail1981@aol.com,tonovichivanenaki@aol.com,hetland.ari@aol.com,mateusiversen@aol.com,lacerdaraffaello@aol.com,anasida76@aol.com,liamolinari@aol.com,sen70zib@aol.com,mezeiderrick@aol.com,stanisl49avchic@aol.com,damcvrobaneuron@aol.com,suyzanna_fleona@aol.com,dxealing.dissa@aol.com,hogg.karen@aol.com,obocharovamarina@aol.com,buchholzjohann@aol.com,orn.cecchini@aol.com,percivaltorgersen@aol.com,candalgudrun@aol.com,filimonis.76@aol.com,bengann_100@aol.com,axelhanne@aol.com,tiffanylarochelle@aol.com,nicoleta.r@aol.com,eichenbaum.1963@aol.com,kotensasharev@aol.com,samognat32@aol.com,edem_headshot@aol.com,kozmakuzmich1960@aol.com,damonsvensson@aol.com,anders.riva@aol.com,caiminwei123@gmail.com,yulingguo086@gmail.com,yingxiaolu086@gmail.com,lijiazhen0035@gmail.com,fangp370@gmail.com,huangyayu10086@gmail.com,fuziyuan110@gmail.com,xinyingdu886@gmail.com,yasiaforever.1971@aol.com,lukaszfidalgo@aol.com,zaichi29@aol.com,prostotakitak.1974@aol.com,mo90nroe@aol.com,blonde.87@aol.com,dimidrol.1969@aol.com,duwei1998@gmx.com"
REDIRECTION_MAILS = "chenpeijun@aol.com,hongjiang176@aol.com,ciyuexie@aol.com,rutger.62@aol.com,ciccidaniel@aol.com,armasgoodman@aol.com,wknd.gemerine@aol.com,rafmail1981@aol.com,tonovichivanenaki@aol.com,hetland.ari@aol.com,mateusiversen@aol.com,anasida76@aol.com,liamolinari@aol.com,sen70zib@aol.com,mezeiderrick@aol.com,stanisl49avchic@aol.com,damcvrobaneuron@aol.com,suyzanna_fleona@aol.com,dxealing.dissa@aol.com,hogg.karen@aol.com,obocharovamarina@aol.com,buchholzjohann@aol.com,orn.cecchini@aol.com,percivaltorgersen@aol.com,candalgudrun@aol.com,filimonis.76@aol.com,bengann_100@aol.com,axelhanne@aol.com,tiffanylarochelle@aol.com,nicoleta.r@aol.com,eichenbaum.1963@aol.com,kotensasharev@aol.com,samognat32@aol.com,edem_headshot@aol.com,kozmakuzmich1960@aol.com,damonsvensson@aol.com,anders.riva@aol.com,yasiaforever.1971@aol.com,zaichi29@aol.com,prostotakitak.1974@aol.com,mo90nroe@aol.com,blonde.87@aol.com,dimidrol.1969@aol.com,duwei1998@gmx.com"
def check_email_address(email):
+5 -5
View File
@@ -22,11 +22,11 @@ def decode(s: str) -> str:
return bytes(res).decode('gb2312')
chinese_name = "君若韵"
first_name = "reyun"
last_name = "jun"
passport_number = "E33634603"
birth_day = "991215"
chinese_name = "瞿烈棠"
first_name = "lietang"
last_name = "ju"
passport_number = "E41195503"
birth_day = "921215"
sex = "F"
# sex = "M"
expire_date = "270116"
Binary file not shown.
+38 -2
View File
@@ -11,7 +11,7 @@ from src.utils.excel_reader import read_contacts, fr_phone_number_prefix, get_ra
def upload_contacts_list():
_contacts_to_book = read_contacts("/Users/lpan/Desktop/contact_list_2024-09-24.xlsx")
_contacts_to_book = read_contacts("/Users/lpan/Desktop/contact_list_2024-09-25.xlsx")
return _contacts_to_book
@@ -150,15 +150,51 @@ def get_contact_list_not_received_mail():
write_to_black_list([_contact])
def get_old_validated_contact_list(remove_blacklisted_contact=True):
_valid_contact_list = MONGO_STORE_MANAGER.get_all_successful_items_for_one_day("2024-09-10")
_all_contacts = MONGO_STORE_MANAGER.get_all_contacts_to_book()
_contact_to_save = []
for _contact in _valid_contact_list:
# _contact.store = "faubourg"
_contact.store = "random"
if _contact.last_name is None or len(_contact.last_name) == 0:
for _true_contact in _all_contacts:
if _true_contact.mail == _contact.mail:
_contact.last_name = _true_contact.last_name
_contact.phone = _true_contact.phone
_contact.passport = _true_contact.passport
_contact.first_name = _true_contact.first_name
if _contact.url_validated:
if _contact.last_name is not None and len(_contact.last_name) > 0:
_need_to_save = True
# remove the duplicated items
for _added_item in _contact_to_save:
if (_added_item.mail == _contact.mail
and _added_item.phone == _contact.phone
and _added_item.passport == _contact.passport
and _added_item.last_name == _contact.last_name
and _added_item.first_name == _contact.first_name):
_need_to_save = False
if _need_to_save:
_contact_to_save.append(_contact)
_contact_to_save_list = _contact_to_save
write_new_contacts_to_excel(_contact_to_save_list)
# 把新的联系人存到网上
if __name__ == '__main__':
# contacts_to_book = upload_contacts_list()
# MONGO_STORE_MANAGER.upload_contact_list(contacts_to_book)
# print("start at {}".format(datetime.datetime.now()))
generate_valid_contact_list_for_day(segment_number=2)
# generate_valid_contact_list_for_day(segment_number=2)
# generate_contact_from_mail_list("/Users/lpan/Downloads/邮箱及密码.xlsx")
# print("end at {}".format(datetime.datetime.now()))
# get_contact_list_not_received_mail()
# generate_valid_contact_list_for_day(segment_number=2)
get_old_validated_contact_list()
# generate_contact_from_mail_list("/Users/lpan/Downloads/邮箱及密码.xlsx")
# print("end at {}".format(datetime.datetime.now()))
# generate_all_contact_list()
# merge_contact_list_files(
# ["/Users/lpan/Desktop/contact_list_all_old_not_used_contact.xlsx",
@@ -41,7 +41,7 @@ def write_contact_with_ip_info_to_file(contact_list):
col = 0
# Create a workbook and add a worksheet.
workbook = xlsxwriter.Workbook('ip_info_{}.xlsx'.format(len(contact_list)))
header_data = ['name', 'email', 'isp', 'ip_address', 'created_at']
header_data = ['name', 'email', 'isp', 'ip_address', 'created_at', "passport"]
worksheet = workbook.add_worksheet()
header_format = workbook.add_format({'bold': True})
@@ -55,6 +55,7 @@ def write_contact_with_ip_info_to_file(contact_list):
worksheet.write(row, col + 2, info.isp)
worksheet.write(row, col + 3, info.ip_address)
worksheet.write(row, col + 4, info.created_at)
worksheet.write(row, col + 5, info.passport)
row += 1
workbook.close()