pull/1/head
Jeremiah K 2023-04-27 18:09:01 -05:00
rodzic df02209a8e
commit 32779119a4
1 zmienionych plików z 22 dodań i 2 usunięć

Wyświetl plik

@ -32,6 +32,21 @@ def load_config():
except FileNotFoundError:
return create_default_config()
def validate_config():
room_ids = [frame.room_id_var.get() for frame in matrix_rooms_frames]
meshtastic_channels = [int(frame.meshtastic_channel_var.get()) for frame in matrix_rooms_frames]
if len(room_ids) != len(set(room_ids)):
messagebox.showerror("Error", "Each Matrix room must be unique. Please check the room IDs.")
return False
if len(meshtastic_channels) != len(set(meshtastic_channels)):
messagebox.showerror("Error", "Each Meshtastic channel must be unique. Please check the channel numbers.")
return False
return True
class Hyperlink(tk.Label):
def __init__(self, master=None, **kwargs):
self.default_color = kwargs.pop("fg", "blue")
@ -174,6 +189,11 @@ def save_config(config):
ordered_yaml_dump(config, f)
def apply_changes():
#Check if config is valid
if not validate_config():
return
# Update matrix config
for key, var in matrix_vars.items():
config["matrix"][key] = var.get()
@ -194,8 +214,6 @@ def apply_changes():
new_config["logging"] = config["logging"]
new_config["plugins"] = config["plugins"]
messagebox.showinfo("Success", "Configuration changes saved.")
# Update logging config
config["logging"]["level"] = logging_level_var.get()
@ -215,6 +233,8 @@ def apply_changes():
save_config(new_config)
messagebox.showinfo("Success", "Configuration changes saved.")
def add_matrix_room(room=None, meshtastic_channel=None):
if len(matrix_rooms_frames) >= 8: