Skip to content

Commit

Permalink
Merge pull request #3 from WittF/main
Browse files Browse the repository at this point in the history
添加Server酱推送,重命名PushPlusUtil
  • Loading branch information
mikumifa authored Aug 22, 2024
2 parents 4c0c934 + 6ea5808 commit f2ff0e2
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 30 deletions.
10 changes: 1 addition & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,9 @@

开源免费,简单易用,图形界面, 速度极快的CPP抢票辅助工具


## 快速安装

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


> **NOTE**
>
> 如果你对Github一点也不了解, 不知道在哪下载
>
> 这里有一份小白指南 [点我前往小白指南](https://github.com/mikumifa/biliTickerBuy/wiki/%E5%B0%8F%E7%99%BD%E4%B8%8B%E8%BD%BD%E6%8C%87%E5%8D%97)
Windows 下载最新的release文件 (cppTickerBuy.zip) [下载链接](https://github.com/mikumifa/cppTickerBuy/releases)

## 使用说明书
重构了UI,启动终端第一行会显示
Expand Down
2 changes: 1 addition & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
header = """
# CPP 抢票🌈
⚠️此项目完全开源免费 ([项目地址](https://github.com/mikumifa/biliTickerBuy)),切勿进行盈利,所造成的后果与本人无关。
⚠️此项目完全开源免费 ([项目地址](https://github.com/mikumifa/cppTickerBuy)),切勿进行盈利,所造成的后果与本人无关。
"""

short_js = """
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)
4 changes: 2 additions & 2 deletions tab/problems.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# def problems_tab():
# gr.Markdown("""
#
# 本项目使用说明书 [使用说明书](https://github.com/mikumifa/biliTickerBuy/wiki/%E6%8A%A2%E7%A5%A8%E8%AF%B4%E6%98%8E)
# 以前项目使用说明书 [使用说明书](https://github.com/mikumifa/biliTickerBuy/wiki/%E6%8A%A2%E7%A5%A8%E8%AF%B4%E6%98%8E)
#
# 本项目的提问专区 [提问专区](https://github.com/mikumifa/biliTickerBuy/discussions)
# 本项目的提问专区 [提问专区](https://github.com/mikumifa/cppTickerBuy/discussions)
# """)
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 f2ff0e2

Please sign in to comment.