diff --git a/README.md b/README.md index 46092ee..1903a03 100644 --- a/README.md +++ b/README.md @@ -20,8 +20,9 @@ from py_agent.jobs import github_notifications from py_agent.listeners import add_issue_to_todoist, add_pr_to_todoist agent = Agent() +task = agent.create_partial(github_notifications) -agent.schedule.every(10).seconds.do(github_notifications, handler=agent.handler) +agent.schedule.every(10).seconds.do(task) agent.add_listener(add_issue_to_todoist, {'event_type': ('==', 'new_issue_assigned')}) agent.add_listener(add_pr_to_todoist, {'event_type': ('==', 'new_pr_review')}) diff --git a/src/py_agent/agent.py b/src/py_agent/agent.py index b6614ef..cd0624e 100644 --- a/src/py_agent/agent.py +++ b/src/py_agent/agent.py @@ -6,6 +6,8 @@ from py_agent.db import init_db from py_agent.event_handler import EventHandler +from functools import partial + logging.basicConfig(level=logging.INFO) @@ -35,3 +37,5 @@ def go(self): except Exception: logging.error("Job failed", exc_info=True) + def create_partial(self, task): + return partial(task, handler=self.handler)