mirror of
https://github.com/liberatedsystems/openCom-Companion.git
synced 2025-02-23 01:39:52 +01:00
Strip markup from notifications
This commit is contained in:
parent
dd1399d7ce
commit
56add0bc50
@ -7,6 +7,7 @@ import struct
|
||||
import sqlite3
|
||||
import random
|
||||
import shlex
|
||||
import re
|
||||
|
||||
import RNS.vendor.umsgpack as msgpack
|
||||
import RNS.Interfaces.Interface as Interface
|
||||
@ -127,6 +128,7 @@ class SidebandCore():
|
||||
# Add the announce to the directory announce
|
||||
# stream logger
|
||||
|
||||
if self.reticulum != None:
|
||||
link_stats = {"rssi": self.reticulum.get_packet_rssi(announce_packet_hash),
|
||||
"snr": self.reticulum.get_packet_snr(announce_packet_hash),
|
||||
"q": self.reticulum.get_packet_q(announce_packet_hash)}
|
||||
@ -4532,6 +4534,11 @@ class SidebandCore():
|
||||
|
||||
self.setstate("lxm_uri_ingest.result", response)
|
||||
|
||||
def strip_markup(self, text):
|
||||
if not hasattr(self, "smr") or self.smr == None:
|
||||
self.smr = re.compile(r'\[\/?(?:b|i|u|url|quote|code|img|color|size)*?.*?\]',re.IGNORECASE | re.MULTILINE )
|
||||
return self.smr.sub("", text)
|
||||
|
||||
def lxm_ingest(self, message, originator = False):
|
||||
should_notify = False
|
||||
is_trusted = False
|
||||
@ -4614,7 +4621,7 @@ class SidebandCore():
|
||||
if should_notify:
|
||||
nlen = 128
|
||||
text = message.content.decode("utf-8")
|
||||
notification_content = text[:nlen]
|
||||
notification_content = self.strip_markup(text[:nlen])
|
||||
if len(text) > nlen:
|
||||
notification_content += " [...]"
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user