Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
# Conflicts:
#	README.md
#	tab/problems.py
  • Loading branch information
mikumifa committed Aug 26, 2024
2 parents 9aeeed3 + ba8da0d commit aa628d9
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 21 deletions.
19 changes: 16 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@

## 快速安装

Windows 下载最新的release文件 [下载链接](https://github.com/mikumifa/cppTickerBuy/releases)


Windows 下载最新的release文件 (cppTickerBuy.zip) [下载链接](https://github.com/mikumifa/cppTickerBuy/releases)
> **NOTE**
>
> 如果你对Github一点也不了解, 不知道在哪下载
Expand Down Expand Up @@ -48,6 +46,14 @@ Running on local URL: http://127.0.0.1:xxx

反馈程序BUG或者提新功能建议: [点此链接向项目提出反馈BUG](https://github.com/mikumifa/cppTickerBuy/issues/new/choose)

## 其他可用脚本

| 链接 | 主要特色 |
| --------------------------------------------------------- | ---------------------- |
| https://github.com/Koileo/ticket_for_allcpp | 能同时开多张票 |



## 项目贡献者

<!-- readme: collaborators,contributors -start -->
Expand All @@ -60,6 +66,13 @@ Running on local URL: http://127.0.0.1:xxx
<br />
<sub><b>mikumifa</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/WittF">
<img src="https://avatars.githubusercontent.com/u/108567138?v=4" width="100;" alt="WittF"/>
<br />
<sub><b>W1ttF</b></sub>
</a>
</td>
</tr>
<tbody>
Expand Down
14 changes: 10 additions & 4 deletions tab/go.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
from requests import HTTPError, RequestException

from config import global_cookieManager, main_request, configDB, time_service
from util import PlusUtil
from util import PushPlusUtil
from util import ServerChanUtil
from util.error import ERRNO_DICT, withTimeString


Expand Down Expand Up @@ -241,9 +242,14 @@ def inner_request():
gr.update(visible=False),
gr.update(value=qr_gen_image.get_image(), visible=True)
]
plusToken = configDB.get("plusToken")
if plusToken is not None and plusToken != "":
PlusUtil.send_message(plusToken, "抢票成功", "付款吧")
pushplusToken = configDB.get("pushplusToken")
if pushplusToken is not None and pushplusToken != "":
PushPlusUtil.send_message(pushplusToken, "抢票成功", "付款吧")
serverchanKey = configDB.get("serverchanKey")
if serverchanKey is not None and serverchanKey != "":
ServerChanUtil.send_message(serverchanKey, "抢票成功", "付款吧")


if audio_path is not None and audio_path != "":
def play_sound_in_loop(file_path):
while True:
Expand Down
38 changes: 25 additions & 13 deletions tab/login.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,21 +69,33 @@ def add():
inputs=None,
outputs=[info_ui, username_ui, gr_file_ui]
)
gr.Markdown("""
> **微信消息推送功能如何添加**
> 参考 https://cloud.tencent.com/developer/article/2139538
> 粘贴token到下面即可
> 关闭的方式是直接删除token即可
""")
gr.Markdown(
"""
🗨️ 抢票成功提醒
> 你需要去对应的网站获取key或token,然后填入下面的输入框
> [Server酱](https://sct.ftqq.com/sendkey) | [pushplus](https://www.pushplus.plus/uc.html)
> 留空以不启用提醒功能
""")
with gr.Row():
plus_ui = gr.Textbox(
value=configDB.get("plusToken") if configDB.get("plusToken") is not None else "",
label="PlusPlus的Token",
serverchan_ui = gr.Textbox(
value=configDB.get("serverchanKey") if configDB.get("serverchanKey") is not None else "",
label="Server酱的SendKey",
interactive=True,
info="留空则表示不使用PlusPlus的提醒功能",
info="https://sct.ftqq.com/",
)

def inner_input(x):
return configDB.insert("plusToken", x)
pushplus_ui = gr.Textbox(
value=configDB.get("pushplusToken") if configDB.get("pushplusToken") is not None else "",
label="PushPlus的Token",
interactive=True,
info="https://www.pushplus.plus/",
)

def inner_input_serverchan(x):
return configDB.insert("serverchanKey", x)
def inner_input_pushplus(x):
return configDB.insert("pushplusToken", x)

serverchan_ui.change(fn=inner_input_serverchan, inputs=serverchan_ui)

plus_ui.change(fn=inner_input, inputs=plus_ui)
pushplus_ui.change(fn=inner_input_pushplus, inputs=pushplus_ui)
2 changes: 1 addition & 1 deletion util/PlusUtil.py → util/PushPlusUtil.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def send_message(token, content, title):
}
requests.post(url, headers=headers, data=json.dumps(data))
except Exception as e:
loguru.logger.info("PlusPlus消息发送失败")
loguru.logger.info("PushPlus消息发送失败")



Expand Down
31 changes: 31 additions & 0 deletions util/ServerChanUtil.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import json

import loguru
import requests
import playsound
import os

from config import get_application_tmp_path


def send_message(token, desp, title):
try:
url = f"https://sctapi.ftqq.com/{token}.send"
headers = {
"Content-Type": "application/json"
}

data = {
"desp": desp,
"title": title
}
requests.post(url, headers=headers, data=json.dumps(data))
except Exception as e:
loguru.logger.info("ServerChan消息发送失败")





if __name__ == '__main__':
playsound.playsound(os.path.join(get_application_tmp_path(), "default.mp3"))

0 comments on commit aa628d9

Please sign in to comment.