kopia lustrzana https://github.com/mate-dev/meshtastic-matrix-relay
Shortname work
rodzic
4b827bd9f2
commit
81841c1fe4
|
@ -110,7 +110,7 @@ def save_shortname(meshtastic_id, shortname):
|
||||||
)
|
)
|
||||||
conn.commit()
|
conn.commit()
|
||||||
|
|
||||||
def update_shortnames(nodes):
|
def update_shortname(nodes):
|
||||||
if meshtastic_interface.nodes:
|
if meshtastic_interface.nodes:
|
||||||
for node in meshtastic_interface.nodes.values():
|
for node in meshtastic_interface.nodes.values():
|
||||||
user = node.get("user")
|
user = node.get("user")
|
||||||
|
|
5
main.py
5
main.py
|
@ -9,7 +9,7 @@ from nio import (
|
||||||
)
|
)
|
||||||
from pubsub import pub
|
from pubsub import pub
|
||||||
from typing import List
|
from typing import List
|
||||||
from db_utils import initialize_database, update_longnames, update_shortnames
|
from db_utils import initialize_database, update_longnames, update_shortname
|
||||||
from matrix_utils import (
|
from matrix_utils import (
|
||||||
connect_matrix,
|
connect_matrix,
|
||||||
join_matrix_room,
|
join_matrix_room,
|
||||||
|
@ -28,6 +28,7 @@ from meshtastic_utils import (
|
||||||
|
|
||||||
logger = get_logger(name="M<>M Relay")
|
logger = get_logger(name="M<>M Relay")
|
||||||
meshtastic_interface = connect_meshtastic()
|
meshtastic_interface = connect_meshtastic()
|
||||||
|
logger.debug(f"meshtastic_interface: {meshtastic_interface}")
|
||||||
matrix_rooms: List[dict] = relay_config["matrix_rooms"]
|
matrix_rooms: List[dict] = relay_config["matrix_rooms"]
|
||||||
matrix_access_token = relay_config["matrix"]["access_token"]
|
matrix_access_token = relay_config["matrix"]["access_token"]
|
||||||
|
|
||||||
|
@ -72,7 +73,7 @@ async def main():
|
||||||
try:
|
try:
|
||||||
# Update longnames & shortnames
|
# Update longnames & shortnames
|
||||||
update_longnames(meshtastic_interface.nodes)
|
update_longnames(meshtastic_interface.nodes)
|
||||||
update_shortnames(meshtastic_interface.nodes)
|
update_shortname(meshtastic_interface.nodes)
|
||||||
|
|
||||||
matrix_logger.info("Syncing with server...")
|
matrix_logger.info("Syncing with server...")
|
||||||
await matrix_client.sync_forever(timeout=30000)
|
await matrix_client.sync_forever(timeout=30000)
|
||||||
|
|
Ładowanie…
Reference in New Issue