run.py
def callback_clock(context: CallbackContext, out: bool = False) -> None:
    """Handle callback: a clock in/out callback using job queue."""
    u = context.job.context
    clock_string = "clockin_"
    if out:
        clock_string = "clockout_"
    logging.info(f"{clock_string}: {str(u.userid)}")
    br = apollo.ApolloSession()
    retry_count = 3
    for i in range(retry_count):
        login_status = br.login(u.apollo_user, u.apollo_password)
        if str(login_status) == "True":
            msg = br.work_day_query()
            if msg == "work":
                logging.info(f"{clock_string}{str(u.userid)}: Detected Work Day")
                work_detected_text = "Good morning, you have work today!"
                if out:
                    work_detected_text = "Good evening, nice work today!"
                context.bot.send_message(
                    chat_id=u.userid, text=work_detected_text,
                )
                if u.autolog:
                    logging.info(f"{clock_string}{str(u.userid)}: Auto Login")
                    context.bot.send_message(
                        chat_id=u.userid,
                        text=f"You have autolog enabled, I will now try to clock you {'out' if out else 'in'}.",
                    )
                    if out:
                        clock_msg = br.clock_out()
                    else:
                        clock_msg = br.clock_in()
                    logging.info(f"{clock_string}{str(u.userid)} Login:" + clock_msg)
                    context.bot.send_message(chat_id=u.userid, text=clock_msg)
            elif msg == "leave":
                logging.info(f"{clock_string}{str(u.userid)}: Detected Leave Day")
                context.bot.send_message(
                    chat_id=u.userid,
                    text=f"Good evening, I detected a leave notice today, but I'm still sending you a reminder to clock {'out' if out else 'in'}!",
                )
                if u.autolog:
                    context.bot.send_message(
                        chat_id=u.userid,
                        text=f"Since I can't tell your leave hours, you'll have to clock {'out' if out else 'in'} manually!",
                    )
            elif msg == "off":
                logging.info(f"{clock_string}{str(u.userid)}: Detected Off Day")
                pass
            else:
                logging.info(f"{clock_string}{str(u.userid)}: Detected " + msg)
                pass
            break
        else:
            logging.info(f"{clock_string}{str(u.userid)}: " + login_status)
            if i == retry_count - 1:
                context.bot.send_message(
                    chat_id=u.userid,
                    text=f"Login failed {retry_count} times.\n"
                    + login_status
                    + "\nPlease clock in/out manually.",
                )
    del br
Handle callback: a clock in/out callback using job queue.
Handle callback: a clock in/out callback using job queue.
Handle callback : a clock in / out callback using job queue .
def callback_clock(context: CallbackContext, out: bool = False) -> None:
    u = context.job.context
    clock_string = "clockin_"
    if out:
        clock_string = "clockout_"
    logging.info(f"{clock_string}: {str(u.userid)}")
    br = apollo.ApolloSession()
    retry_count = 3
    for i in range(retry_count):
        login_status = br.login(u.apollo_user, u.apollo_password)
        if str(login_status) == "True":
            msg = br.work_day_query()
            if msg == "work":
                logging.info(f"{clock_string}{str(u.userid)}: Detected Work Day")
                work_detected_text = "Good morning, you have work today!"
                if out:
                    work_detected_text = "Good evening, nice work today!"
                context.bot.send_message(
                    chat_id=u.userid, text=work_detected_text,
                )
                if u.autolog:
                    logging.info(f"{clock_string}{str(u.userid)}: Auto Login")
                    context.bot.send_message(
                        chat_id=u.userid,
                        text=f"You have autolog enabled, I will now try to clock you {'out' if out else 'in'}.",
                    )
                    if out:
                        clock_msg = br.clock_out()
                    else:
                        clock_msg = br.clock_in()
                    logging.info(f"{clock_string}{str(u.userid)} Login:" + clock_msg)
                    context.bot.send_message(chat_id=u.userid, text=clock_msg)
            elif msg == "leave":
                logging.info(f"{clock_string}{str(u.userid)}: Detected Leave Day")
                context.bot.send_message(
                    chat_id=u.userid,
                    text=f"Good evening, I detected a leave notice today, but I'm still sending you a reminder to clock {'out' if out else 'in'}!",
                )
                if u.autolog:
                    context.bot.send_message(
                        chat_id=u.userid,
                        text=f"Since I can't tell your leave hours, you'll have to clock {'out' if out else 'in'} manually!",
                    )
            elif msg == "off":
                logging.info(f"{clock_string}{str(u.userid)}: Detected Off Day")
                pass
            else:
                logging.info(f"{clock_string}{str(u.userid)}: Detected " + msg)
                pass
            break
        else:
            logging.info(f"{clock_string}{str(u.userid)}: " + login_status)
            if i == retry_count - 1:
                context.bot.send_message(
                    chat_id=u.userid,
                    text=f"Login failed {retry_count} times.\n"
                    + login_status
                    + "\nPlease clock in/out manually.",
                )
    del br
def callback_clock ( context : CallbackContext , out : bool = False ) -> None : u = context . job . context clock_string = "clockin_" if out : clock_string = "clockout_" logging . info ( f"{clock_string}: {str(u.userid)}" ) br = apollo . ApolloSession ( ) retry_count = 3 for i in range ( retry_count ) : login_status = br . login ( u . apollo_user , u . apollo_password ) if str ( login_status ) == "True" : msg = br . work_day_query ( ) if msg == "work" : logging . info ( f"{clock_string}{str(u.userid)}: Detected Work Day" ) work_detected_text = "Good morning, you have work today!" if out : work_detected_text = "Good evening, nice work today!" context . bot . send_message ( chat_id = u . userid , text = work_detected_text , ) if u . autolog : logging . info ( f"{clock_string}{str(u.userid)}: Auto Login" ) context . bot . send_message ( chat_id = u . userid , text = f"You have autolog enabled, I will now try to clock you {'out' if out else 'in'}." , ) if out : clock_msg = br . clock_out ( ) else : clock_msg = br . clock_in ( ) logging . info ( f"{clock_string}{str(u.userid)} Login:" + clock_msg ) context . bot . send_message ( chat_id = u . userid , text = clock_msg ) elif msg == "leave" : logging . info ( f"{clock_string}{str(u.userid)}: Detected Leave Day" ) context . bot . send_message ( chat_id = u . userid , text = f"Good evening, I detected a leave notice today, but I'm still sending you a reminder to clock {'out' if out else 'in'}!" , ) if u . autolog : context . bot . send_message ( chat_id = u . userid , text = f"Since I can't tell your leave hours, you'll have to clock {'out' if out else 'in'} manually!" , ) elif msg == "off" : logging . info ( f"{clock_string}{str(u.userid)}: Detected Off Day" ) pass else : logging . info ( f"{clock_string}{str(u.userid)}: Detected " + msg ) pass break else : logging . info ( f"{clock_string}{str(u.userid)}: " + login_status ) if i == retry_count - 1 : context . bot . send_message ( chat_id = u . userid , text = f"Login failed {retry_count} times.\n" + login_status + "\nPlease clock in/out manually." , ) del br
Handle callback: a clock in/out callback using job queue.
Handle callback : a clock in / out callback using job queue .
"""Handle callback: a clock in/out callback using job queue."""
context
CallbackContext
out
bool