-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #104 from xingetouzi/CustomNotify
Custom notify
- Loading branch information
Showing
2 changed files
with
55 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,34 @@ | ||
from xml.etree import ElementTree | ||
from collections import defaultdict | ||
import json | ||
import requests | ||
import re | ||
|
||
ROOT_TAG = "ding" | ||
|
||
|
||
def dingFormatter(): | ||
e = ElementTree.Element(ROOT_TAG) | ||
e.text = ".*?" | ||
return ElementTree.tostring(e, "unicode") | ||
|
||
|
||
DingCompiler = re.compile(dingFormatter()) | ||
|
||
|
||
def makeNotify(message, titles, channels): | ||
root = ElementTree.Element(ROOT_TAG) | ||
|
||
for title in titles: | ||
etitle = ElementTree.SubElement(root, "title") | ||
etitle.text = title | ||
|
||
for channel in channels: | ||
echannel = ElementTree.SubElement(root, "channel") | ||
echannel.text = channel | ||
|
||
emessage = ElementTree.SubElement(root, "message") | ||
emessage.text = message | ||
|
||
return ElementTree.tostring(root, "unicode") | ||
|
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