-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
72072db
commit aca4c5f
Showing
3 changed files
with
37 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import requests | ||
from enum import Enum | ||
|
||
class MessageType(Enum): | ||
plaintext = 'text/plain' # 默认模板,纯文本展 | ||
markdown = 'text/markdown' # 内容基于markdown格式展示 | ||
|
||
class NtfyNotify: | ||
def __init__(self, topic, server_url = "https://ntfy.sh"): | ||
self.server_url = server_url | ||
self.topic = topic | ||
|
||
def send_msg(self, title, msg): | ||
url = self.server_url.rstrip('/') + "/" + self.topic | ||
response = requests.post(url, | ||
data=msg.encode("utf-8"), | ||
headers={ "Title": title }) | ||
|
||
return response.json() | ||
|
||
|
||
if __name__ == "__main__": | ||
TOPIC = "" | ||
URL = "" | ||
ntfy = NtfyNotify(TOPIC, URL) | ||
print(ntfy.send_msg("title","msg")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters