fix(pushover): add optional_int function, return None for empty strings and update priority argument type (#5)
Reviewed-on: #5
This commit was merged in pull request #5.
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
name: Conventional Commit
|
name: Validate PR Title
|
||||||
on:
|
on:
|
||||||
pull_request:
|
pull_request:
|
||||||
types:
|
types:
|
||||||
@@ -8,7 +8,9 @@ on:
|
|||||||
- reopened
|
- reopened
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
validate_pr_title:
|
validate:
|
||||||
uses: https://git.tainton.uk/actions/gha-workflows/.gitea/workflows/conventional-commit.yml@main
|
runs-on: ubuntu-latest
|
||||||
with:
|
steps:
|
||||||
commit_message: ${{ gitea.event.pull_request.title }}
|
- uses: https://git.tainton.uk/actions/conventional-commits-check-action@v1.3.0
|
||||||
|
with:
|
||||||
|
commit-message: ${{ gitea.event.pull_request.title }}
|
||||||
|
|||||||
10
pushover.py
10
pushover.py
@@ -4,6 +4,12 @@ import argparse
|
|||||||
import requests
|
import requests
|
||||||
|
|
||||||
|
|
||||||
|
def optional_int(value):
|
||||||
|
"""Convert string to int, treating empty strings as None"""
|
||||||
|
if value == '':
|
||||||
|
return None
|
||||||
|
return int(value)
|
||||||
|
|
||||||
def get_args():
|
def get_args():
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument('--message', type=str, help='Message text')
|
parser.add_argument('--message', type=str, help='Message text')
|
||||||
@@ -11,7 +17,7 @@ def get_args():
|
|||||||
parser.add_argument('--url', type=str, help='Supplementary URL to show with your message')
|
parser.add_argument('--url', type=str, help='Supplementary URL to show with your message')
|
||||||
parser.add_argument('--url_title', type=str, help='title for your supplementary URL, otherwise just the URL is shown')
|
parser.add_argument('--url_title', type=str, help='title for your supplementary URL, otherwise just the URL is shown')
|
||||||
parser.add_argument('--device', type=str, help='Device name to send the message directly to')
|
parser.add_argument('--device', type=str, help='Device name to send the message directly to')
|
||||||
parser.add_argument('--priority', type=int, help='Notification priority (low-to-high: -2 to 1)')
|
parser.add_argument('--priority', type=optional_int, help='Notification priority (low-to-high: -2 to 1)')
|
||||||
parser.add_argument('--sound', type=str, help='The name of a supported sound (https://pushover.net/api#sounds; custom sounds are supported)')
|
parser.add_argument('--sound', type=str, help='The name of a supported sound (https://pushover.net/api#sounds; custom sounds are supported)')
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
return args
|
return args
|
||||||
@@ -48,7 +54,7 @@ def main():
|
|||||||
if device:
|
if device:
|
||||||
payload['device'] = device
|
payload['device'] = device
|
||||||
if priority:
|
if priority:
|
||||||
payload['priority'] = priority
|
payload['priority'] = str(priority)
|
||||||
if sound:
|
if sound:
|
||||||
payload['sound'] = sound
|
payload['sound'] = sound
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user