|
10 | 10 | build_reconciliation_record, |
11 | 11 | write_reconciliation_record, |
12 | 12 | ) |
| 13 | +from notifications.events import NotificationPublisher, RenderedNotification |
13 | 14 |
|
14 | 15 |
|
15 | 16 | _ZH_REASON_REPLACEMENTS = ( |
@@ -455,6 +456,10 @@ def run_strategy_core( |
455 | 456 | reconciliation_output_path=None, |
456 | 457 | result_hook=None, |
457 | 458 | ): |
| 459 | + notification_publisher = NotificationPublisher( |
| 460 | + log_message=lambda message: print(message, flush=True), |
| 461 | + send_message=send_tg_message, |
| 462 | + ) |
458 | 463 | ib = None |
459 | 464 | try: |
460 | 465 | ib = connect_ib() |
@@ -524,8 +529,12 @@ def run_strategy_core( |
524 | 529 | body_lines=[no_op_text], |
525 | 530 | dashboard_text=strategy_dashboard, |
526 | 531 | ) |
527 | | - print(detailed_message, flush=True) |
528 | | - send_tg_message(compact_message) |
| 532 | + notification_publisher.publish( |
| 533 | + RenderedNotification( |
| 534 | + detailed_text=detailed_message, |
| 535 | + compact_text=compact_message, |
| 536 | + ) |
| 537 | + ) |
529 | 538 | if callable(result_hook): |
530 | 539 | result_hook( |
531 | 540 | { |
@@ -614,8 +623,12 @@ def run_strategy_core( |
614 | 623 | dashboard_text=strategy_dashboard, |
615 | 624 | ) |
616 | 625 |
|
617 | | - print(detailed_message, flush=True) |
618 | | - send_tg_message(compact_message) |
| 626 | + notification_publisher.publish( |
| 627 | + RenderedNotification( |
| 628 | + detailed_text=detailed_message, |
| 629 | + compact_text=compact_message, |
| 630 | + ) |
| 631 | + ) |
619 | 632 | if callable(result_hook): |
620 | 633 | result_hook( |
621 | 634 | { |
|
0 commit comments