Skip to content

Commit 660cd08

Browse files
committed
Bark push module & fix typo
1 parent 4d5545a commit 660cd08

File tree

4 files changed

+82
-12
lines changed

4 files changed

+82
-12
lines changed

README.md

+10-12
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,28 @@
1-
## FF14 AutoSignRemake
1+
# FF14 AutoSignRemake
22

3-
##### 使用说明
3+
## 使用说明
44

55
**按需下载Releases下的文件,进入项目根目录,使用 ```pip -r requirements.txt```安装依赖库**
66

7-
##### 注意事项
7+
## 注意事项
88

99
**一般情况下无需修改根目录下的设置文件 **
1010

1111
**如果出现报错请开启 ```DebugMode```并将```LogsLevel```调整至 ```High```并心中默念「给我日志给我日志」然后再次执行程序将程序根目录出现的新东西发送到issue**.
1212

1313
**没有logs文件无异于闭眼开车**
1414

15-
##### TodoList
15+
## TodoList
1616

17-
**支持TeleBot/钉钉bot/等推送**
17+
- [ ] 支持TeleBot/钉钉bot/等推送
18+
- [ ] 支持账号密码和一键登录
19+
- [ ] 支持青龙面板
1820

19-
**支持账号密码和一键登录**
20-
21-
**支持青龙面板**
22-
23-
##### 感谢
21+
## 感谢
2422

2523
[@renchangjiu](https://github.com/renchangjiu/FF14AutoSignIn) **提供的核心思路**
2624

27-
##### License
25+
## License
2826

29-
[With AFL - 3.0](https://github.com/AmarokIce/PineappleDelight/blob/master/LICENSE)
27+
[With AFL - 3.0](https://github.com/AmarokIce/PineappleDelight/blob/master/LICENSE)
3028
[Pineapple LICENSE](https://github.com/AmarokIce/PineappleDelight/blob/master/LICENSE.txt)

Utility/Notifications/bark.py

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import configparser
2+
3+
import requests
4+
5+
6+
def send(title: str, content: str):
7+
"""
8+
发送 bark 通知
9+
:param title: 通知标题
10+
:param content: 通知内容
11+
:return: {'status': 'success'} 或 {'status': 'failed'}
12+
"""
13+
config = configparser.ConfigParser()
14+
config.read('config.ini',encoding='UTF-8')
15+
pushkey = config.get('Notification', 'push-key')
16+
url = 'https://api.day.app/' + pushkey
17+
headers = {
18+
"Content-Type": "application/json",
19+
"charset": "UTF-8"
20+
}
21+
# bark通知将被分组到“FF14”,并且会自动保存
22+
load = {
23+
"title": title,
24+
"body": content,
25+
"badge": 1,
26+
"sound": "minuet.caf",
27+
"icon": "https://huiji-thumb.huijistatic.com/ff14/uploads/thumb/3/33/000030.png/30px-000030.png",
28+
"group": "FF14",
29+
"isArchive": 1,
30+
}
31+
response = requests.post(url, headers=headers, json=load)
32+
print(response.text)
33+
if response.status_code == 200:
34+
return {'status': 'success'}
35+
else:
36+
return {'status': 'failed'}

Utility/Notifications/push.py

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import configparser
2+
import importlib
3+
4+
5+
def push(title, content):
6+
"""
7+
PushDeer推送
8+
:param title: 通知标题
9+
:param content: 通知内容
10+
:return: 推送结果,如:{'status': 'success'} 或 {'status': 'failed'}
11+
"""
12+
13+
push_config = configparser.ConfigParser()
14+
push_config.read('config.ini', encoding='UTF-8')
15+
# 根据配置导入对应的包
16+
push_module = importlib.import_module(push_config.get('Notification', 'ush-method'))
17+
result = push_module.push(title, content)
18+
return result

config.ini

+18
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,24 @@ PushKey = 0
99
CookieSaved = False
1010
CookieForceUpdated = 7
1111

12+
13+
[Notification]
14+
;若要启用消息通知,请将noc-enable设置为True,并根据说明正确配置push-key
15+
noc-enable = False
16+
;通知服务商可选:bark、pushdeer serverchan smtp
17+
push-method = bark
18+
;推送密钥或目标地址
19+
push-key = xxxxx
20+
21+
;SMTP 发件服务器配置
22+
;目前仅支持SSL 465端口发送
23+
; TODO: 支持非SSL
24+
smtp-host = ""
25+
smtp-port = 465
26+
smtp-username = ""
27+
smtp-password = ""
28+
smtp-ssl = True
29+
1230
[Develop]
1331
Update = True
1432
DebugMode = False

0 commit comments

Comments
 (0)