Skip to content

Commit

Permalink
Merge pull request #10 from jeremiah-k/main
Browse files Browse the repository at this point in the history
Fixed formatting issue when remote messages are sent to local meshnet
  • Loading branch information
jeremiah-k authored Apr 24, 2023
2 parents c49d36c + f4db2d6 commit bd14e42
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
.vscode
config.yaml
meshtastic.sqlite
__pycache__
19 changes: 9 additions & 10 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,12 +332,15 @@ async def on_room_message(
if longname and meshnet_name:
full_display_name = f"{longname}/{meshnet_name}"
if meshnet_name != local_meshnet_name:
logger.info(f"Processing message from remote meshnet: {text}")
short_longname = longname[:3]
short_meshnet_name = meshnet_name[:4]
prefix = f"{short_longname}/{short_meshnet_name}: "
logger.info(f"Processing message from remote meshnet: {text}")
text = re.sub(rf"^\[{full_display_name}\]: ", "", text) # Remove the original prefix from the text
text = truncate_message(text)
full_message = f"{prefix}{text}"
else:
logger.info(f"Processing message from local meshnet: {text}")
# This is a message from a local user, it should be ignored no log is needed
return
else:
display_name_response = await matrix_client.get_displayname(
Expand All @@ -346,12 +349,9 @@ async def on_room_message(
full_display_name = display_name_response.displayname or event.sender
short_display_name = full_display_name[:5]
prefix = f"{short_display_name}[M]: "
logger.info(
f"Processing matrix message from [{full_display_name}]: {text}"
)

text = truncate_message(text)
full_message = f"{prefix}{text}"
logger.info(f"Processing matrix message from [{full_display_name}]: {text}")
text = truncate_message(text)
full_message = f"{prefix}{text}"

room_config = None
for config in matrix_rooms:
Expand All @@ -366,8 +366,7 @@ async def on_room_message(
logger.info(
f"Sending radio message from {full_display_name} to radio broadcast"
)
meshtastic_interface.sendText(
text=full_message, channelIndex=meshtastic_channel
meshtastic_interface.sendText(text=full_message, channelIndex=meshtastic_channel
)
else:
logger.debug(
Expand Down
2 changes: 1 addition & 1 deletion mmrelay.iss
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//WizardSmallImageFile=smallwiz.bmp

AppName=Matrix <> Meshtastic Relay
AppVersion=0.3.2
AppVersion=0.3.4
DefaultDirName={userpf}\MM Relay
DefaultGroupName=MM Relay
UninstallFilesDir={app}
Expand Down

0 comments on commit bd14e42

Please sign in to comment.