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

This commit is contained in:
2024-09-26 23:16:40 +02:00
10 changed files with 44 additions and 35 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
@@ -156,7 +156,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)
@@ -173,8 +173,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.
+21 -5
View File
@@ -2,9 +2,9 @@ import datetime
import random
import xlsxwriter
from src.person_name.cython_extract_methods import filter_already_validated_contacts, read_pinyin_list_from_file
from src.db.mongo_manager import MONGO_STORE_MANAGER
from src.person_name.cython_extract_methods import filter_already_validated_contacts, read_pinyin_list_from_file
from src.pojo.contact_pojo import ContactPojo
from src.utils.contacts.generate_random_passport_id import get_random_passport_id_number
from src.utils.excel_reader import read_contacts, fr_phone_number_prefix, get_random_fr_phone_numbers, ExcelHelper
@@ -138,7 +138,19 @@ def generate_all_contact_list():
write_new_contacts_to_excel(_all_contacts, file_name="all")
def get_old_validated_contact_list():
def write_to_black_list(contacts: list):
for contact in contacts:
MONGO_STORE_MANAGER.insert_blacklist_contact(contact)
def get_contact_list_not_received_mail():
_contact_list = MONGO_STORE_MANAGER.get_all_successful_items_for_day()
for _contact in _contact_list:
if not _contact.url_validated:
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 = []
@@ -172,11 +184,15 @@ def get_old_validated_contact_list():
# 把新的联系人存到网上
if __name__ == '__main__':
contacts_to_book = upload_contacts_list()
MONGO_STORE_MANAGER.upload_contact_list(contacts_to_book)
# 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)
# get_old_validated_contact_list()
# 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()
+3 -6
View File
@@ -9,9 +9,8 @@ class BlackContactPojo(ContactPojo):
def __init__(self, phone_number: str, passport_number: str, last_name: str, first_name: str, mail: str,
update_at_in_s: Union[float, None] = None,
ccid: str = "",
position: int = 0, ):
super().__init__(phone_number, passport_number, last_name, first_name, mail, ccid, position)
):
super().__init__(phone_number, passport_number, last_name, first_name, mail, store="random")
if update_at_in_s:
self.update_at_in_s = update_at_in_s
else:
@@ -24,15 +23,13 @@ class BlackContactPojo(ContactPojo):
@staticmethod
def from_firestore_dict(source):
ccid = source['ccid']
phone = source['phone']
position = source['position']
passport = source['passport']
email = source['mail']
last_name = source['last_name']
first_name = source['first_name']
update_at_in_s = source['update_at_in_s']
result = BlackContactPojo(ccid=ccid, phone_number=phone, passport_number=passport, position=position,
result = BlackContactPojo(phone_number=phone, passport_number=passport,
mail=email, update_at_in_s=update_at_in_s,
last_name=last_name, first_name=first_name)
return result