added regex for topic filter
This commit is contained in:
parent
745e8e9524
commit
011ee98477
@ -1,8 +1,9 @@
|
||||
import argparse
|
||||
import getpass
|
||||
import logging
|
||||
import json
|
||||
import logging
|
||||
import mqtt
|
||||
import re
|
||||
import time
|
||||
|
||||
from textual.app import App, ComposeResult
|
||||
@ -10,7 +11,6 @@ from textual.containers import Vertical
|
||||
from textual.widgets import Footer, Header, Input, RichLog
|
||||
|
||||
|
||||
# TODO: Usage of multiple regex for topic filter
|
||||
# TODO: Integrate sending of message (topic + payload)
|
||||
|
||||
class MqttReceiver(object):
|
||||
@ -68,7 +68,10 @@ class MqttSniffer(App):
|
||||
"""filter the mqtt messages."""
|
||||
topic_match = False
|
||||
for topic_filter in self.topic_filter.split(","):
|
||||
topic_match |= topic_filter.lower() in record.topic.lower()
|
||||
try:
|
||||
topic_match |= len(re.findall(topic_filter, record.topic)) > 0
|
||||
except re.error:
|
||||
pass # No valid regular expression
|
||||
|
||||
if topic_match:
|
||||
try:
|
||||
|
Loading…
x
Reference in New Issue
Block a user