kopia lustrzana https://github.com/mate-dev/meshtastic-matrix-relay
Bugfixes
rodzic
df02209a8e
commit
32779119a4
|
@ -32,6 +32,21 @@ def load_config():
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
return create_default_config()
|
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):
|
class Hyperlink(tk.Label):
|
||||||
def __init__(self, master=None, **kwargs):
|
def __init__(self, master=None, **kwargs):
|
||||||
self.default_color = kwargs.pop("fg", "blue")
|
self.default_color = kwargs.pop("fg", "blue")
|
||||||
|
@ -174,6 +189,11 @@ def save_config(config):
|
||||||
ordered_yaml_dump(config, f)
|
ordered_yaml_dump(config, f)
|
||||||
|
|
||||||
def apply_changes():
|
def apply_changes():
|
||||||
|
|
||||||
|
#Check if config is valid
|
||||||
|
if not validate_config():
|
||||||
|
return
|
||||||
|
|
||||||
# Update matrix config
|
# Update matrix config
|
||||||
for key, var in matrix_vars.items():
|
for key, var in matrix_vars.items():
|
||||||
config["matrix"][key] = var.get()
|
config["matrix"][key] = var.get()
|
||||||
|
@ -194,8 +214,6 @@ def apply_changes():
|
||||||
new_config["logging"] = config["logging"]
|
new_config["logging"] = config["logging"]
|
||||||
new_config["plugins"] = config["plugins"]
|
new_config["plugins"] = config["plugins"]
|
||||||
|
|
||||||
messagebox.showinfo("Success", "Configuration changes saved.")
|
|
||||||
|
|
||||||
# Update logging config
|
# Update logging config
|
||||||
config["logging"]["level"] = logging_level_var.get()
|
config["logging"]["level"] = logging_level_var.get()
|
||||||
|
|
||||||
|
@ -215,6 +233,8 @@ def apply_changes():
|
||||||
|
|
||||||
save_config(new_config)
|
save_config(new_config)
|
||||||
|
|
||||||
|
messagebox.showinfo("Success", "Configuration changes saved.")
|
||||||
|
|
||||||
|
|
||||||
def add_matrix_room(room=None, meshtastic_channel=None):
|
def add_matrix_room(room=None, meshtastic_channel=None):
|
||||||
if len(matrix_rooms_frames) >= 8:
|
if len(matrix_rooms_frames) >= 8:
|
||||||
|
|
Ładowanie…
Reference in New Issue