Merge remote-tracking branch 'origin/master'

This commit is contained in:
liulong 2024-09-23 15:33:23 +08:00
commit 98cfe3586c
4 changed files with 311 additions and 18 deletions

View File

@ -4,7 +4,9 @@
# @author Echo # @author Echo
# @EditTime 2024/9/14 # @EditTime 2024/9/14
import datetime import datetime
import os
import random import random
import re
import time import time
import httpx import httpx
from typing import Text, Optional, List, Dict from typing import Text, Optional, List, Dict
@ -33,25 +35,29 @@ from typing import Text, Optional, List, Dict
""" """
设置配置常量 设置配置常量
""" """
API_KEY = "" # 天聚数行密钥 CONFIG = {
APP_ID = "" # 微信公众号appid "API_KEY": "", # 天聚数行密钥
APP_SECRET = "" # 微信公众号appsecret "APP_ID": "", # 微信公众号appid
WECHAT_USER_IDS = [] # 要推送的微信用户ID "APP_SECRET": "", # 微信公众号appsecret
TEMPLATE_ID = "" # 模板ID "TEMPLATE_ID": "", # 模板ID
CITY_NAME = "" # 城市 "CITY_NAME": "", # 城市
AREA = "" # 区县 "AREA": "", # 区县
EXAMINATION_DATE = "" # 考研日期 "EXAMINATION_DATE": "", # 考研日期
USER = "" # 对象称呼 "USER": "", # 对象称呼
BIRTHDAY = "" # 对象生日 "BIRTHDAY": "", # 对象生日
STAR_SIGN = "" # 对象星座 "STAR_SIGN": "", # 对象星座
LOVE_DATE = "" # 恋爱开始日期 "LOVE_DATE": "" # 恋爱开始日期
}
# 从环境变量中获取配置,如果环境变量不存在则使用默认值
for key in CONFIG:
CONFIG[key] = os.environ.get(key, CONFIG[key])
# if 'tian_api_key' in os.environ: # 特殊处理 WECHAT_USER_IDS因为它需要被分割
# api_key = re.split("@|&", os.environ.get("tian_api_key")) WECHAT_USER_IDS = re.split("@|&", os.environ.get("WECHAT_USER_IDS", "")) if "WECHAT_USER_IDS" in os.environ else []
# else:
# api_key = [] # 使用全局变量
# print("未查找到tian_api_key变量.") globals().update(CONFIG)
def time_diff(time1: Text, time2: Text, format) -> int: def time_diff(time1: Text, time2: Text, format) -> int:
@ -259,7 +265,7 @@ class WeChatPushMessage:
"touser": user, "touser": user,
"template_id": TEMPLATE_ID, "template_id": TEMPLATE_ID,
"url": "http://www.baidu.com", "url": "heartSpin.html",
"topcolor": "#FF0000", "topcolor": "#FF0000",
"data": { "data": {
"today": {"value": time_, "color": self.get_color()}, # 当前时间 "today": {"value": time_, "color": self.get_color()}, # 当前时间

84
heartSpin.html Normal file
View File

@ -0,0 +1,84 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<style>
html, body {
height: 100%;
padding: 0;
margin: 0;
background: #000;
}
img{
display: block;
margin: 0 auto;
}
label{
display: block;
margin: 0 auto;
color: pink;
font-size: 20px;
padding-right: 5px;/*往左偏移10px*/
animation:mymove 2.5s infinite;/* //关联动画名称、动画时长、循环 */
/*Safari 和 Chrome:*/
-webkit-animation:mymove 2.5s infinite;/* //同上(兼容) */
}
@keyframes mymove
{
50% {font-size: 40px;}/* //名字放大大小 */
}
/*Safari 和 Chrome:*/
@-webkit-keyframes mymove
{
50% {font-size: 40px;}/* //名字放大大小 */
}
.middle{
width: 100%;
height: 100vh;
display: flex;
align-items: center;
}
.middle2{
position: absolute;
z-index: 2;
width: 100%;
height: 100%;
margin: auto;
display: flex;align-items: center;
}
</style>
<link rel="stylesheet" href="./style.css">
<body>
<div class="container">
<span></span>
<span></span>
<span></span>
<span></span>
<span></span>
</div>
<div class="middle">
<div class="middle2">
</div>
<img src="https://pic.imgdb.cn/item/642547f5a682492fcc15cd5d.gif"width="1000" height="650"/>
</div>
</body>
<audio
autoplay="autoplay"
loop="loop"
preload="auto"
src="http://ws.stream.qqmusic.qq.com/C4000009nowb1Lxsk5.m4a?guid=291747946&vkey=927E1CB036619BB457EC5C1E98E58C4646FD00050805BB0984A5BFCA3496DCEB4584A8A036F397667725E74D8AC498ED6108144422F6FC6F&uin=&fromtag=120032">
</audio>
<script type="text/javascript" src="//js.users.51.la/21504121.js"></script>
</body>
</html>

196
hykb.py Normal file
View File

@ -0,0 +1,196 @@
# -*- coding=UTF-8 -*-
# @Project QL_TimingScript
# @fileName hykb.py
# @author Echo
# @EditTime 2024/9/20
import os
import re
from datetime import datetime
import requests
import random
from sendNotify import send_notification_message
if 'Hykb_cookie' in os.environ:
Hykb_cookie = re.split("@|&", os.environ.get("Hykb_cookie"))
else:
Hykb_cookie = []
print("未查找到Hykb_cookie变量.")
class HaoYouKuaiBao():
"""好游快爆签到
"""
def __init__(self, cookie, user_agent):
self.cookie = cookie
self.url = "https://huodong3.3839.com/n/hykb/{}/ajax{}.php"
self.data = "ac={}&r=0.{}&scookie={}"
self.headers = {
"Origin": "https://huodong3.i3839.com",
"Referer": "https://huodong3.3839.com/n/hykb/cornfarm/index.php?imm=0",
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
"User-Agent": user_agent
}
def plant(self) -> int:
"""播种
"""
url = self.url.format("cornfarm", "_plant")
data = self.data.format("Plant", random.randint(1000000000000000, 8999999999999999), self.cookie)
try:
response = requests.post(url, headers=self.headers, data=data).json()
if response['key'] == 'ok':
print("好游快爆-播种成功")
send_notification_message("好游快爆签到通知 - " + datetime.now().strftime("%Y/%m/%d"), "好游快爆-播种成功")
return 1
else:
if response['seed'] == 0:
print("好游快爆-种子已用完")
send_notification_message("好游快爆签到通知 - " + datetime.now().strftime("%Y/%m/%d"), "好游快爆-种子已用完")
return -1
else:
print("好游快爆-播种失败")
send_notification_message("好游快爆签到通知 - " + datetime.now().strftime("%Y/%m/%d"), "好游快爆-播种失败")
return 0
except Exception as e:
print(f"好游快爆-播种出现错误:{e}")
return False
def harvest(self) -> bool:
"""收获
"""
url = self.url.format("cornfarm", "_plant")
data = self.data.format("Harvest", random.randint(1000000000000000, 8999999999999999), self.cookie)
try:
response = requests.post(url, headers=self.headers, data=data).json()
if response['key'] == 'ok':
print("好游快爆-收获成功")
send_notification_message("好游快爆签到通知 - " + datetime.now().strftime("%Y/%m/%d"), "好游快爆-收获成功")
return True
else:
print("好游快爆-收获失败")
send_notification_message("好游快爆签到通知 - " + datetime.now().strftime("%Y/%m/%d"), "好游快爆-收获失败")
return False
except Exception as e:
print(f"好游快爆-收获出现错误:{e}")
return False
def login(self):
"""登录
"""
url = self.url.format("cornfarm", "")
data = self.data.format("login", random.randint(100000000000000, 8999999999999999), self.cookie)
response = requests.post(url, headers=self.headers, data=data)
try:
response = response.json()
return response
except Exception as e:
print("好游快爆-登录出现错误:{}".format(e))
# response = response.text
# return response
def watering(self):
"""浇水
"""
url = self.url.format("cornfarm", "_sign")
data = self.data.format("Sign&verison=1.5.7.005&OpenAutoSign=",
random.randint(100000000000000, 8999999999999999), self.cookie)
try:
response = requests.post(url, headers=self.headers, data=data).json()
if response['key'] == 'ok':
print("好游快爆-浇水成功")
send_notification_message(title="好游快爆签到通知 - " + datetime.now().strftime("%Y/%m/%d"), content="好游快爆-浇水成功")
return 1, response['add_baomihua']
elif response['key'] == '1001':
print("好游快爆-今日已浇水")
send_notification_message(title="好游快爆签到通知 - " + datetime.now().strftime("%Y/%m/%d"), content="好游快爆-今日已浇水")
return 0, 0
else:
print("好游快爆-浇水出现错误:{}".format(response))
return -1, 0
except Exception as e:
print("好游快爆-浇水出现错误:{}".format(e))
return -1, 0
# def buyseeds(self):
# """购买种子
# """
# url = self.url.format("bmhstore2/inc/virtual", "Virtual")
# print(url)
# ac = "exchange&t=" + datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") + "&goodsid=14565"
# data = self.data.format(ac, random.randint(100000000000000, 8999999999999999), self.cookie)
# print(data)
# response = requests.post(url, headers=self.headers, data=data)
# print(response.json())
def sgin(self):
info = ""
# 登录
data = self.login()
if data['key'] == 'ok':
if data['config']['csd_jdt'] == "100%":
# 收获
if self.harvest():
info = info + "收获成功\n"
# 播种
b = self.plant()
if b == -1:
info = info + "播种失败,没有种子\n"
elif b == 1:
info = info + "播种成功\n"
# 浇水
data = self.watering()
if data[0] == 1:
info = info + f"浇水成功,获得{data[1]}爆米花\n"
elif data[0] == 0:
info = info + f"今日已浇水\n"
else:
info = info + f"浇水失败\n"
else:
info = info + "播种失败\n"
else:
info = info + "收获失败\n"
elif data['config']['grew'] == '-1':
# 播种
b = self.plant()
if b == -1:
info = info + "播种失败,没有种子\n"
elif b == 1:
info = info + "播种成功\n"
# 浇水
data = self.watering()
if data[0] == 1:
info = info + f"浇水成功,获得{data[1]}爆米花\n"
elif data[0] == 0:
info = info + f"今日已浇水\n"
else:
info = info + f"浇水失败\n"
else:
info = info + "播种失败\n"
else:
# 浇水
data = self.watering()
if data[0] == 1:
info = info + f"浇水成功,获得{data[1]}爆米花\n"
elif data[0] == 0:
info = info + f"今日已浇水\n"
else:
info = info + f"浇水失败\n"
else:
info = info + "登录失败\n"
return info
if __name__ == '__main__':
user_agents = [
"Mozilla/5.0 (Linux; Android 13; M2012K11AC Build/TKQ1.220829.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/115.0.5790.166 Mobile Safari/537.36Androidkb/1.5.7.005(android;M2012K11AC;13;1080x2320;WiFi);@4399_sykb_android_activity@",
"Mozilla/5.0 (Linux; Android 12; Redmi K30 Pro Build/SKQ1.211006.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/96.0.4664.104 Mobile Safari/537.36Androidkb/1.5.7.507(android;Redmi K30 Pro;12;1080x2356;WiFi);@4399_sykb_android_activity@"
]
for cookie_, user_agent in zip(Hykb_cookie, user_agents):
hykb = HaoYouKuaiBao(cookie_, user_agent)
hykb.sgin()
del hykb

View File

@ -472,5 +472,12 @@ def main():
send('title', 'content') send('title', 'content')
def send_notification_message(title, content):
try:
dingding_bot(title, content)
except Exception as e:
print("发送通知消息失败")
if __name__ == '__main__': if __name__ == '__main__':
main() main()