-
Notifications
You must be signed in to change notification settings - Fork 80
/
Copy path__main__.py
31 lines (26 loc) · 926 Bytes
/
__main__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
""" Entry point to trigger webhook(s). """
import argparse
import sys
from discord_webhook import DiscordWebhook
def main() -> bool:
parser = argparse.ArgumentParser(
prog="discord_webhook", description="Trigger discord webhook(s)."
)
parser.add_argument("-u", "--url", required=True, help="Webhook URL")
parser.add_argument("-c", "--content", required=True, help="Message content")
parser.add_argument(
"--username", default=None, help="override the default username of the webhook"
)
parser.add_argument(
"--avatar_url", default=None, help="override the default avatar of the webhook"
)
args = parser.parse_args()
webhook = DiscordWebhook(
url=args.url,
content=args.content,
username=args.username,
avatar_url=args.avatar_url,
)
return webhook.execute() is not None
if __name__ == "__main__":
sys.exit(main())