diff options
author | Frederick Yin <fkfd@fkfd.me> | 2022-02-19 22:20:57 +0800 |
---|---|---|
committer | Frederick Yin <fkfd@fkfd.me> | 2022-02-19 22:20:57 +0800 |
commit | c9d9b6914cd3bf3201e8c04be90210da58ae0b5f (patch) | |
tree | 30db8ea7aa788413698fa4972590e370dc395030 /jimbrella | |
parent | f984329bde1784473b9a4e36afc9efd5b46cd06f (diff) |
Routine can send SMS now
Diffstat (limited to 'jimbrella')
-rw-r--r-- | jimbrella/routine.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/jimbrella/routine.py b/jimbrella/routine.py index 659fbfa..3d92482 100644 --- a/jimbrella/routine.py +++ b/jimbrella/routine.py @@ -3,9 +3,10 @@ from dateutil.parser import isoparse import logging from .umbrellas import Umbrellas from .jform import JForm +from .sms import SMS from .exceptions import * from .config import config -from .utils import CST +from .utils import human_datetime, CST """A set of routine methods, run at an interval (somewhere from ten minutes to one hour), to: - sync JImbrella's databse against data pulled from jForm @@ -39,7 +40,7 @@ def chronological_merge(*sheet_lists) -> list: return chronicle -def sync_jform(takeaway: JForm, giveback: JForm, db: Umbrellas): +def sync_jform(takeaway: JForm, giveback: JForm, db: Umbrellas, sms: SMS): takeaway_unread = takeaway.get_unread() giveback_unread = giveback.get_unread() logging.info( @@ -62,6 +63,7 @@ def sync_jform(takeaway: JForm, giveback: JForm, db: Umbrellas): sheet["id"], sheet["phone"], ) + sms.borrow_success(sheet["phone"], sheet["name"], human_datetime(sheet["date"]), sheet["key"]) except (UmbrellaStatusError, UmbrellaNotFoundError): logging.warning( tenant_identity @@ -127,5 +129,6 @@ if __name__ == "__main__": config.get("jform", "bookmark_dir"), ) db = Umbrellas(config.get("general", "db_path")) - sync_jform(takeaway, giveback, db) + sms = SMS() + sync_jform(takeaway, giveback, db, sms) process_overdue(db) |