Skip to content
This repository has been archived by the owner on Dec 2, 2022. It is now read-only.

Commit

Permalink
Remove Telegram
Browse files Browse the repository at this point in the history
  • Loading branch information
BCN-Cita committed Nov 29, 2021
1 parent e74e7bb commit eafafe4
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 26 deletions.
25 changes: 0 additions & 25 deletions bcncita/cita.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import Select
from selenium.webdriver.support.wait import WebDriverWait
from telegram.ext import Updater

from .speaker import new_speaker

Expand Down Expand Up @@ -171,15 +170,12 @@ class CustomerProfile:
max_date: Optional[str] = None # "dd/mm/yyyy"
save_artifacts: bool = False
sms_webhook_token: Optional[str] = None
telegram_token: Optional[str] = None
telegram_chat_id: Optional[str] = None
wait_exact_time: Optional[list] = None # [[minute, second]]

# Internals
bot_result: bool = False
first_load: Optional[bool] = True # Wait more on the first load to cache stuff
log_settings: Optional[dict] = field(default_factory=lambda: {"stream": sys.stdout})
updater: Any = object()
recaptcha_solver: Any = None
image_captcha_solver: Any = None
current_solver: Any = None
Expand Down Expand Up @@ -223,9 +219,6 @@ def try_cita(context: CustomerProfile, cycles: int = CYCLES):
)
if context.sms_webhook_token:
delete_message(context.sms_webhook_token)

if context.telegram_token:
context.updater = Updater(token=context.telegram_token, use_context=True)
success = False
result = False
for i in range(cycles):
Expand Down Expand Up @@ -664,8 +657,6 @@ def phone_mail(driver: webdriver, context: CustomerProfile, retry: bool = False)


def confirm_appointment(driver: webdriver, context: CustomerProfile):
bot = context.updater.dispatcher.bot
chat_id = context.telegram_chat_id
driver.find_element_by_id("chkTotal").send_keys(Keys.SPACE)
driver.find_element_by_id("enviarCorreo").send_keys(Keys.SPACE)

Expand All @@ -679,37 +670,21 @@ def confirm_appointment(driver: webdriver, context: CustomerProfile):
context.bot_result = True
code = driver.find_element_by_id("justificanteFinal").text
logging.info(f"[Step 6/6] Justificante cita: {code}")
caption = f"Cita confirmed! {code}"
if context.save_artifacts:
image_name = f"CONFIRMED-CITA-{ctime}.png".replace(":", "-")
driver.save_screenshot(image_name)
if chat_id:
bot.send_photo(
chat_id=chat_id,
photo=open(os.path.join(os.getcwd(), image_name), "rb"),
caption=caption,
)
# TODO: fix saving to PDF
# btn = driver.find_element_by_id("btnImprimir")
# btn.send_keys(Keys.ENTER)
# # Give some time to save appointment pdf
# time.sleep(5)
elif chat_id:
bot.send_message(chat_id=chat_id, text=caption)

return True
elif "Lo sentimos, el código introducido no es correcto" in resp_text:
logging.error("Incorrect code entered")
if chat_id:
bot.send_message(chat_id=chat_id, text="Incorrect code entered")
else:
error_name = f"error-{ctime}.png".replace(":", "-")
driver.save_screenshot(error_name)
if chat_id:
bot.send_photo(
chat_id=chat_id, photo=open(os.path.join(os.getcwd(), error_name), "rb"),
)
bot.send_message(chat_id=chat_id, text="Something went wrong")

return None

Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
selenium==3.141.0
python-telegram-bot==12.8
Mako==1.1.3
anticaptchaofficial==1.0.31
requests==2.26.0

0 comments on commit eafafe4

Please sign in to comment.