add announce interval for LXMF bot

This commit is contained in:
Gabby Morgan
2026-05-29 21:45:03 -05:00
parent 4ceac515f0
commit d47d517060
3 changed files with 238 additions and 1 deletions
+18 -1
View File
@@ -31,11 +31,12 @@ class ChannelClient:
STATE_CALLING = 3
STATE_IN_CALL = 4
def __init__(self, configdir=None, rnsconfigdir=None, whitelist_path=None, verbosity=0):
def __init__(self, configdir=None, rnsconfigdir=None, whitelist_path=None, verbosity=0, announce_interval=0):
self.state = self.STATE_IDLE
self.channels = []
self.telephone = None
self.should_run = False
self.announce_interval = announce_interval
self._responses = []
self._response_event = threading.Event()
@@ -93,6 +94,15 @@ class ChannelClient:
display_name="LXST Channel Client",
)
self.lxmf_router.register_delivery_callback(self._delivery_callback)
self.client_destination.announce()
if self.announce_interval > 0:
threading.Thread(target=self._announce_loop, daemon=True).start()
def _announce_loop(self):
while self.should_run:
time.sleep(self.announce_interval)
self.client_destination.announce()
def _delivery_callback(self, message):
content = message.content_as_string().strip()
@@ -378,6 +388,12 @@ def main():
version="lxst-client 0.1.0",
)
parser.add_argument("-v", "--verbose", action="count", default=0)
parser.add_argument(
"--announce_interval",
default=0,
help="seconds between LXMF destination announces (0 = announce once at startup, default)",
type=int,
)
args = parser.parse_args()
@@ -386,6 +402,7 @@ def main():
rnsconfigdir=args.rnsconfig,
whitelist_path=args.whitelist,
verbosity=args.verbose,
announce_interval=args.announce_interval,
)
try: