Skip to content

Commit

Permalink
add configuration option for filtering own messages
Browse files Browse the repository at this point in the history
Add the filter-own configuration file option and command line argument
for enabling filtering of own messages (disabled by default).

Signed-off-by: hwipl <33433250+hwipl@users.noreply.github.com>
  • Loading branch information
hwipl committed Dec 27, 2020
1 parent 5d5044c commit 3826ec1
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions nuqql_based/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def __init__(self, backend_name: str, backend_version: str):
self._loglevel = self._LOGLEVEL_MAP[self._DEFAULT_LOGLEVEL]
self._history = True
self._push_accounts = False
self._filter_own = False

def get_from_args(self) -> None:
"""
Expand Down Expand Up @@ -71,6 +72,8 @@ def get_from_args(self) -> None:
help="disable message history")
parser.add_argument("--push-accounts", action="store_true",
help="push accounts to client")
parser.add_argument("--filter-own", action="store_true",
help="enable filtering of own messages")

# parse command line arguments
args = parser.parse_args()
Expand All @@ -94,6 +97,8 @@ def get_from_args(self) -> None:
self._history = False
if args.push_accounts:
self._push_accounts = True
if args.filter_own:
self._filter_own = True

def read_from_file(self) -> None:
"""
Expand Down Expand Up @@ -141,6 +146,8 @@ def read_from_file(self) -> None:
"history", fallback=self._history)
self._push_accounts = config[section].getboolean(
"push-accounts", fallback=self._push_accounts)
self._filter_own = config[section].getboolean(
"filter-own", fallback=self._filter_own)
except ValueError as error:
error_msg = "Error parsing config file: {}".format(error)
print(error_msg)
Expand Down Expand Up @@ -224,6 +231,14 @@ def get_push_accounts(self) -> bool:

return self._push_accounts

def get_filter_own(self) -> bool:
"""
Get filter own entry from config: filtering of own messages
enabled or disabled
"""

return self._filter_own

def get_name(self) -> str:
"""
Get the name of the backend
Expand Down

0 comments on commit 3826ec1

Please sign in to comment.