Minor bug fixes
This commit is contained in:
parent
8bd6ff6ba4
commit
11152ae8de
2 changed files with 11 additions and 5 deletions
|
@ -42,6 +42,7 @@ class ConsumerNTFY(Plugin):
|
||||||
async def report(self, evt: MessageEvent, message: str) -> None:
|
async def report(self, evt: MessageEvent, message: str) -> None:
|
||||||
# Split command (minus !command_name) into tokens
|
# Split command (minus !command_name) into tokens
|
||||||
tokens = message.split()
|
tokens = message.split()
|
||||||
|
st_desig = tokens[0].lower()
|
||||||
|
|
||||||
# Each command must have a state/territory designation and a message
|
# Each command must have a state/territory designation and a message
|
||||||
if len(tokens) < 2: return
|
if len(tokens) < 2: return
|
||||||
|
@ -52,15 +53,20 @@ class ConsumerNTFY(Plugin):
|
||||||
return
|
return
|
||||||
|
|
||||||
# Check allowed senders
|
# Check allowed senders
|
||||||
allowed_senders = self.config["allowed_senders." + tokens[0]]
|
allowed_senders = self.config["allowed_senders"]
|
||||||
if allowed_senders and not evt.sender in allowed_senders:
|
|
||||||
return
|
print(evt.sender)
|
||||||
|
|
||||||
|
if st_desig in self.config["allowed_senders"]:
|
||||||
|
print(f"Allowed senders for {st_desig}: {self.config['allowed_senders'].get(st_desig, [])}")
|
||||||
|
if not evt.sender in self.config['allowed_senders'].get(st_desig, []):
|
||||||
|
return
|
||||||
|
|
||||||
# Sending notification to NTFY
|
# Sending notification to NTFY
|
||||||
|
|
||||||
url = self.config["server_url"] + "/" + self.config["server_topic"]
|
url = self.config["server_url"] + "/" + self.config["server_topic"]
|
||||||
body = ' '.join(tokens[1:])
|
body = ' '.join(tokens[1:])
|
||||||
if len(self.config["allowed_locations"]) > 1:
|
if len(self.config["allowed_locations"]) != 1:
|
||||||
body = tokens[0] + ": " + body
|
body = tokens[0] + ": " + body
|
||||||
|
|
||||||
# Consider authentication
|
# Consider authentication
|
||||||
|
|
|
@ -2,4 +2,4 @@
|
||||||
|
|
||||||
Please see https://git.fiftyfiftyonearizona.org/webmaster/matrix-report-documentation
|
Please see https://git.fiftyfiftyonearizona.org/webmaster/matrix-report-documentation
|
||||||
|
|
||||||
This plugin supports whitelisting state/territory designators, allowed senders, and authenticated NTFY posting.
|
This plugin supports whitelisting state/territory designators, allowed senders, reaction receipt, and authenticated NTFY posting.
|
Loading…
Add table
Add a link
Reference in a new issue