Skip to content

Commit

Permalink
Merge branch 'release/0.0.3' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
stivenramireza committed Mar 14, 2021
2 parents 64fc266 + adf2052 commit 095361a
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 10 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v0.0.2a
release_name: v0.0.2a
tag_name: v0.0.3
release_name: v0.0.3
body: |
Adding DESIRED_DATE as environment variable
logout_from_website() method added
draft: false
prerelease: false

Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
__pycache__
__pycache__
Pipfile
2 changes: 1 addition & 1 deletion __version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.0.2a'
__version__ = '0.0.3'
9 changes: 5 additions & 4 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
IDENTIFICATION,
PASSWORD,
HEADQUARTER_NAME,
DESIRED_DATE,
DESIRED_TIME,
WHATSAPP_URL,
CHAT_NAME,
Expand All @@ -15,10 +16,10 @@
from smartfit_booking.website_bot import (
initialize,
login_to_website,
answer_questionnaire,
search_headquarter,
book_hour,
get_qr_code,
logout_from_website,
login_to_whatsapp,
search_chat,
send_message
Expand All @@ -37,10 +38,10 @@ def main():
""" book_an_hour """
driver = initialize(DRIVER_PATH, OUTPUT_PATH, CHROME_PROFILE_PATH)
login_to_website(driver, WEBSITE_URL, IDENTIFICATION, PASSWORD)
answer_questionnaire(driver)
search_headquarter(driver, HEADQUARTER_NAME)
book_hour(driver, DESIRED_TIME)
book_hour(driver, DESIRED_DATE, DESIRED_TIME)
qr_code_url = get_qr_code(driver)
logout_from_website(driver)

""" download_qr_code """
response = get_data(qr_code_url)
Expand All @@ -50,7 +51,7 @@ def main():
""" send_whatsapp_message """
login_to_whatsapp(driver, WHATSAPP_URL)
search_chat(driver, CHAT_NAME)
send_message(driver, image_path, PERSON_NAME, DESIRED_TIME)
send_message(driver, image_path, PERSON_NAME, DESIRED_DATE, DESIRED_TIME)
remove_file(image_path)

if __name__ == '__main__':
Expand Down
1 change: 1 addition & 0 deletions secrets.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
IDENTIFICATION = os.environ.get('IDENTIFICATION')
PASSWORD = os.environ.get('PASSWORD')
HEADQUARTER_NAME = os.environ.get('HEADQUARTER_NAME')
DESIRED_DATE = os.environ.get('DESIRED_DATE')
DESIRED_TIME = os.environ.get('DESIRED_TIME')
WHATSAPP_URL = os.environ.get('WHATSAPP_URL')
CHAT_NAME = os.environ.get('CHAT_NAME')
Expand Down
14 changes: 13 additions & 1 deletion smartfit_booking/website_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,18 @@ def get_qr_code(driver: object) -> str:
driver.quit()
raise

def logout_from_website(driver: object) -> None:
try:
logout_button = WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.XPATH, '//button[@aria-label="logout"]'))
)
logout_button.click()
time.sleep(10)
logger.info('Logout from website has been successfully')
except Exception as error:
logger.error(f'Error to logout from website: {error}')
raise

def login_to_whatsapp(driver: object, whatsapp_url: str) -> None:
try:
driver.get(whatsapp_url) # Already authenticated
Expand All @@ -135,7 +147,7 @@ def login_to_whatsapp(driver: object, whatsapp_url: str) -> None:

def search_chat(driver: object, chat_name: str) -> None:
try:
search_box = WebDriverWait(driver, 10).until(
search_box = WebDriverWait(driver, 500).until(
EC.presence_of_element_located((By.XPATH, '//div[@contenteditable="true"][@data-tab="3"]'))
)
search_box.clear()
Expand Down

0 comments on commit 095361a

Please sign in to comment.