Giter Site home page Giter Site logo

ttp-notifier's Introduction

ttp-notifier

Simple library that notifies of appointments for the Trusted Traveler Program

Getting Started

Prerequisites

This library was tested against Python 3.7+.

Installation

Clone the repo:

git clone https://github.com/thesilvad/ttp-notifier

Install the dependencies:

cd ttp-notifier
pip install -r requirements.txt

If you'd like to use it as a python module, you can install it with the following:

pip install .

Find your location_id from one of the following:

Usage

There is an example main.py script that contains three example notifications. Two of which only work on macOS. The main.py script can be modified to not include the macOS notifications.

You can run the script with the following:

python main.py --location_id 5002 \
               --current_appointment "May 20, 2024" \
               --poll_interval 10 \
               --phone_number 1-555-555-1234

ConsoleObserver

The ConsoleObserver class will simply log the appointments to the console log.

NotificationsObserver

The NotificationsObserver class will only work on macOS. It depends osascript to create display notifications.

MessagesObserver

The MessagesObserver class will only work on macOS. It depends on osascript to send an iMessage to a phone number.

Writing a Custom Observer

If instead you'd like to write your own custom observers, simply subclass the Observer and implement its update method. Here is a very simple example of how to log the available appointments to the console:

import logging
import time

from ttpnotifier.ttpnotifier import Observer, TTPNotifier


class ConsoleObserver(Observer):
    def update(self, available_appointments):
        logging.info(f'Found {len(available_appointments)} appointment(s): {", ".join(available_appointments)}')


console_observer = ConsoleObserver()
notifier = TTPNotifier(
    location_id=5002,
    current_appointment='January 19, 2038',
    num_appointments=10,
    poll_interval=60)
notifier.subscribe(console_observer)

while True:
    time.sleep(1)

ttp-notifier's People

Contributors

thesilvad avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.