🔥:remove: 删除好游快爆相关脚本

删除了 hykb.py 和 hykb_tasks.py 两个文件,移除了与好游快爆相关的所有功能代码
This commit is contained in:
liulong 2024-11-04 10:17:45 +08:00
parent 9cd05c406b
commit bb273c20d3
2 changed files with 0 additions and 591 deletions

257
hykb.py
View File

@ -1,257 +0,0 @@
# -*- coding=UTF-8 -*-
# @Project QL_TimingScript
# @fileName hykb.py
# @author Echo
# @EditTime 2024/9/20
import os
import random
import re
import threading
import urllib.parse
from datetime import datetime
import httpx
import requests
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):
self.client = httpx.Client(
verify=False,
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"
}
)
self.cookie = cookie
self.url = "https://huodong3.3839.com/n/hykb/{}/ajax{}.php"
self.user_name = self.user_info()["user"]
def get_index_html(self):
"""
获取首页
:return:
"""
url = "https://huodong3.3839.com/n/hykb/cornfarm/index.php?imm=0"
try:
response = self.client.get(url)
return response.text
except Exception as e:
print("好游快爆-获取首页出现错误:{}".format(e))
def user_info(self):
"""
获取用户信息
:return:
"""
url = self.url.format("qdjh", "")
payload = f"ac=login&r=0.{random.randint(100000000000000000, 899999999999999999)}&scookie={urllib.parse.quote(self.cookie)}&device=kbA25014349F11473F467DC6FF5C89E9D6"
try:
response = self.client.post(url, content=payload).json()
if response['key'] == 'ok':
return {
"user": response["config"]["name"],
"uuid": response["config"]["uid"]
}
except Exception as e:
print("好游快爆-获取用户信息出现错误:{}".format(e))
def plant(self) -> int:
"""播种
"""
url = self.url.format("cornfarm", "_plant")
payload = f"ac=Plant&r=0.{random.randint(100000000000000000, 899999999999999999)}&scookie={urllib.parse.quote(self.cookie)}&device=kbA25014349F11473F467DC6FF5C89E9D6"
try:
response = self.client.post(url, content=payload).json()
if response['key'] == 'ok':
print(f"好游快爆-用户【{self.user_name}】播种成功")
send_notification_message("好游快爆签到通知 - " + datetime.now().strftime("%Y/%m/%d"),
f"好游快爆-用户【{self.user_name}】播种成功")
return 1
else:
if response['seed'] == 0:
print(f"好游快爆-用户【{self.user_name}】种子已用完")
send_notification_message("好游快爆签到通知 - " + datetime.now().strftime("%Y/%m/%d"),
f"好游快爆-用户【{self.user_name}】种子已用完")
return -1
else:
print(f"好游快爆-用户【{self.user_name}】播种失败")
send_notification_message("好游快爆签到通知 - " + datetime.now().strftime("%Y/%m/%d"),
f"好游快爆-用户【{self.user_name}】播种失败")
return 0
except Exception as e:
print(f"好游快爆-播种出现错误:{e}")
return False
def harvest(self) -> bool:
"""收获
"""
url = self.url.format("cornfarm", "_plant")
payload = f"ac=Harvest&r=0.{random.randint(100000000000000000, 899999999999999999)}&scookie={urllib.parse.quote(self.cookie)}&device=kbA25014349F11473F467DC6FF5C89E9D6"
try:
response = self.client.post(url, content=payload).json()
if response['key'] == 'ok':
print(f"好游快爆-用户【{self.user_name}】收获成功")
send_notification_message("好游快爆签到通知 - " + datetime.now().strftime("%Y/%m/%d"),
f"好游快爆-用户【{self.user_name}】收获成功")
elif response['key'] == '503':
print(f"好游快爆-用户【{self.user_name}{response['info']}")
send_notification_message("好游快爆签到通知 - " + datetime.now().strftime("%Y/%m/%d"),
f"好游快爆-用户【{self.user_name}{response['info']}")
else:
print(f"好游快爆-用户【{self.user_name}】收获失败")
send_notification_message("好游快爆签到通知 - " + datetime.now().strftime("%Y/%m/%d"),
f"好游快爆-用户【{self.user_name}】收获失败")
return False
except Exception as e:
print(f"好游快爆-收获出现错误:{e}")
return False
def login(self):
"""登录
"""
url = self.url.format("cornfarm", "")
payload = f"ac=login&r=0.{random.randint(100000000000000000, 899999999999999999)}&scookie={urllib.parse.quote(self.cookie)}&device=kbA25014349F11473F467DC6FF5C89E9D6"
response = self.client.post(url, content=payload)
try:
response = response.json()
return response
except Exception as e:
print("好游快爆-登录出现错误:{}".format(e))
def watering(self):
"""浇水
"""
url = self.url.format("cornfarm", "_sign")
payload = f"ac=Sign&verison=1.5.7.005&OpenAutoSign=&r=0.{random.randint(100000000000000000, 899999999999999999)}&scookie={urllib.parse.quote(self.cookie)}&device=kbA25014349F11473F467DC6FF5C89E9D6"
try:
response = self.client.post(url, content=payload).json()
if response['key'] == 'ok':
print(f"好游快爆-用户【{self.user_name}】浇水成功")
send_notification_message(title="好游快爆签到通知 - " + datetime.now().strftime("%Y/%m/%d"),
content=f"好游快爆-用户【{self.user_name}】浇水成功")
return 1, response['add_baomihua']
elif response['key'] == '1001':
print(f"好游快爆-用户【{self.user_name}】今日已浇水")
send_notification_message(title="好游快爆签到通知 - " + datetime.now().strftime("%Y/%m/%d"),
content=f"好游快爆-用户【{self.user_name}】今日已浇水")
return 0, 0
else:
print("好游快爆-浇水出现错误:{}".format(response))
return -1, 0
except Exception as e:
print("好游快爆-浇水出现错误:{}".format(e))
return -1, 0
def get_goods(self):
"""
获取商品id
:return:
"""
response = self.client.post(
url="https://shop.3839.com/index.php?c=Index&a=initCard",
content=f"pid=1660&r=0.{random.randint(100000000000000000, 899999999999999999)}&scookie={urllib.parse.quote(self.cookie)}&device=kbA25014349F11473F467DC6FF5C89E9D6"
)
try:
j_response = response.json()
if j_response['code'] == 200:
return j_response['data']['store_id'], j_response['data']['product_name']
except Exception as e:
print("好游快爆-获取商品id出现错误{}".format(e))
def buy_seeds(self):
"""购买种子
"""
# 获取种子商品id
goods_id, goods_name = self.get_goods()
l_response = self.client.post(
url="https://huodong3.3839.com/n/hykb/bmhstore2/inc/virtual/ajaxVirtual.php",
content=f"ac=checkExchange&gid={goods_id}&t={datetime.now().strftime('%Y-%m-%d %H:%M:%S')}&r=0.{random.randint(100000000000000000, 899999999999999999)}&scookie={urllib.parse.quote(self.cookie)}&device=kbA25014349F11473F467DC6FF5C89E9D6"
).json()
if l_response['key'] != "200" and l_response['msg'] != "验证通过":
print("好游快爆-购买种子出现错误:{}".format(l_response))
return False
else:
# 购买种子
response = self.client.post(
url="https://huodong3.3839.com/n/hykb/bmhstore2/inc/virtual/ajaxVirtual.php",
content=f"ac=exchange&t={datetime.now().strftime('%Y-%m-%d %H:%M:%S')}&r=0.{random.randint(100000000000000000, 899999999999999999)}&goodsid={goods_id}&scookie={urllib.parse.quote(self.cookie)}&device=kbA25014349F11473F467DC6FF5C89E9D6"
)
try:
j_response = response.json()
if j_response['key'] == 200:
print(f"好游快爆-用户【{self.user_name}】购买了【{goods_name}】,还剩下🍿爆米花{j_response['bmh']}")
send_notification_message(title="好游快爆签到通知 - " + datetime.now().strftime("%Y/%m/%d"),
content=f"好游快爆-用户【{self.user_name}】购买了【{goods_name}】,还剩下🍿爆米花{j_response['bmh']}")
return True
else:
print("好游快爆-购买种子失败:{}".format(j_response))
return False
except Exception as e:
print("好游快爆-购买种子出现错误:{}".format(e))
return False
def sgin(self):
info = ""
# 登录
data = self.login()
if data['key'] == 'ok':
print(f"用户: 【{self.user_name}】登录成功!✅")
# 优先判断是否已收获
if data['config']['csd_jdt'] == "100%":
# 收获
if self.harvest():
info = info + "收获成功\n"
else:
info = info + "收获失败\n"
# 判断是否已播种
if data['config']['grew'] == '-1':
# 播种
b = self.plant()
if b == -1:
info = info + "播种失败,没有种子\n"
# 购买种子
if self.buy_seeds():
info = info + "购买种子成功\n"
elif b == 1:
info = info + "播种成功\n"
else:
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"
return info
# if __name__ == '__main__':
# threads = []
# for cookie_ in Hykb_cookie:
# hykb = HaoYouKuaiBao(cookie_)
# thread = threading.Thread(target=hykb.sgin)
# threads.append(thread)
# thread.start()
# for thread in threads:
# thread.join()

View File

@ -1,334 +0,0 @@
# -*- coding=UTF-8 -*-
# @Project QL_TimingScript
# @fileName hykb_tasks.py
# @author Echo
# @EditTime 2024/9/24
import asyncio
import os
import random
import re
import urllib.parse
from datetime import datetime
import httpx
from bs4 import BeautifulSoup
from fn_print import fn_print
from sendNotify import send_notification_message_collection
if 'Hykb_cookie' in os.environ:
hykb_cookie = re.split("@", os.environ.get("Hykb_cookie"))
print(f"查找到{len(hykb_cookie)}个账号")
else:
hykb_cookie = []
print("未查找到Hykb_cookie变量.")
exit()
class AsyncHykbTasks:
def __init__(self, cookie):
self.client = httpx.AsyncClient(base_url="https://huodong3.3839.com",
headers={
'User-Agent': "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@",
'Content-Type': "application/x-www-form-urlencoded; charset=UTF-8",
'Origin': "https://huodong3.3839.com",
'Referer': "https://huodong3.3839.com/n/hykb/newsign/index.php?imm=0",
},
verify=False)
self.cookie = cookie
self.temp_id = []
self.bmh_tasks = []
self.items = []
self.moreManorToDo_tasks = []
async def get_task_ids(self):
response = await self.client.get("/n/hykb/qdjh/index.php")
html = response.text
soup = BeautifulSoup(html, 'html.parser')
list_items = soup.select(".game-list-item")
for item in list_items:
btn = item.select_one(".item-time")
if btn and "已结束" not in btn.get("onclick", "") and "hd_id" in btn["onclick"]:
onclick = btn["onclick"].replace("每日签到领", "")
parts = onclick.split("'")
self.items.append({
"title": parts[3],
"id": re.search(r"hd_id=(.+)", parts[1]).group(1)
})
async def get_recommendToDoToday_task_ids(self):
"""
获取今日必做推荐任务的id
:return:
"""
response = await self.client.get("/n/hykb/cornfarm/index.php?imm=0")
html = response.text
soup = BeautifulSoup(html, 'html.parser')
task_list = soup.select(".taskDailyUl > li")
for task_item in task_list:
tasks_infos = task_item.select_one("dl")
id_param = tasks_infos.select_one("dd")["class"][0]
title_param = tasks_infos.select_one("dt").get_text()
reward_param = tasks_infos.select_one("dd").get_text()
if "分享福利" in title_param or "分享资讯" in title_param:
self.bmh_tasks.append(
{
"bmh_task_id": re.search(r"daily_dd_(.+)", id_param).group(1),
"bmh_task_title": re.search(r"分享福利:(.*)", title_param).group(
1) if "分享福利" in title_param else re.search(r"分享资讯:(.*)", title_param).group(1),
"reward_num": re.search(r"可得+(.+)", reward_param).group(1)
}
)
async def get_moreManorToDo_task_ids(self):
"""
获取更多庄园必做任务id
:return:
"""
response = await self.client.get("https://huodong3.3839.com/n/hykb/cornfarm/index.php?imm=0")
html = response.text
soup = BeautifulSoup(html, 'html.parser')
task_list = soup.select(".taskYcxUl > li")
for task_item in task_list:
task_info = task_item.select_one("dl")
id_param = task_info["onclick"]
title_param = task_info.select_one("dt").get_text()
reward_param = task_info.select_one("dd").get_text()
self.moreManorToDo_tasks.append(
{
"bmh_task_id": re.search(r"ShowLue\((.+),'ycx'\); return false;", id_param).group(1),
"bmh_task_title": title_param,
"reward_num": re.search(r"可得+(.+)", reward_param).group(1)
}
)
async def get_task(self, a, hd_id_):
try:
payload = f"ac={a}&hd_id={hd_id_}&hd_id2={hd_id_}&t={datetime.now().strftime('%Y-%m-%d %H:%M:%S')}&r=0.{random.randint(1000000000000000, 8999999999999999)}&scookie={self.cookie}"
url = "https://huodong3.3839.com/n/hykb/newsign/ajax.php"
self.client.headers["Referer"] = f"https://huodong3.3839.com/n/hykb/newsign/index.php?imm=0&hd_id={hd_id_}"
response = await self.client.post(
url=url,
content=payload,
)
response_json = response.json()
return response_json
except Exception as e:
print(e)
return None
"""async def process_item(self, item, bmh_itme):
id = item["id"]
await self.get_task("login", id)
data = await self.get_task("signToday", id)
await self.do_tasks_every_day(bmh_itme)
await self.get_task_reward(bmh_itme)
key = str(data["key"])
if key == "-1005":
fn_print("体验游戏中,请一分钟后再刷新领取☑️")
await self.get_task("tiyan", id)
elif key == "-1007":
await self.get_task("sharelimit", id)
fn_print(f"活动【{item['title']}】分享成功!✅")
await self.get_task("login", id)
await self.get_task("signToday", id)
elif key == "-1002":
fn_print(f"活动【{item['title']}】奖励已领取过了!")
elif key == "200":
fn_print(f"活动【{item['title']}】签到成功!✅已签到{data['signnum']}")
elif key == "no_login":
fn_print("scookie失效,请重新配置⚠️⚠️")
return False
return True"""
async def process_moreManorToDo_task(self, mmtodo_item):
if "预约" in mmtodo_item["bmh_task_title"]:
await self.appointment_moreManorToDo_task(mmtodo_item)
await self.get_moreManorToDo_task_reward(mmtodo_item, "YcxYuyueLing")
else:
if "微博" in mmtodo_item["bmh_task_title"]:
await self.get_moreManorToDo_task_reward(mmtodo_item, "YcxToWeiboRemindLing")
elif "微信" in mmtodo_item["bmh_task_title"]:
await self.get_moreManorToDo_task_reward(mmtodo_item, "YcxToWechatRemindLing")
elif "视频" in mmtodo_item["bmh_task_title"]:
await self.get_moreManorToDo_task_reward(mmtodo_item, "YcxToH5Url")
async def process_doItDaily_task(self, bmh_itme):
await self.do_tasks_every_day(bmh_itme)
await self.get_task_reward(bmh_itme)
async def do_tasks_every_day(self, task_items: dict):
"""
调度每日必做任务
:return:
"""
url = "https://huodong3.3839.com/n/hykb/cornfarm/ajax_daily.php"
daily_share_response = await self.client.post(
url=url,
content=f"ac=DailyShare&id={task_items['bmh_task_id']}&onlyc=0&r=0.{random.randint(100000000000000, 8999999999999999)}&scookie={urllib.parse.quote(self.cookie)}&device=kbA25014349F11473F467DC6FF5C89E9D6"
)
if daily_share_response.json()["key"] != "2002":
return False
# 回调任务
payload = (
f"ac=DailyShareCallback&id={task_items['bmh_task_id']}&mode=qq&source=ds&r=0.{random.randint(100000000000000, 8999999999999999)}"
f"&scookie={urllib.parse.quote(self.cookie)}&device=kbA25014349F11473F467DC6FF5C89E9D6")
daily_share_callback_response = await self.client.post(url=url, content=payload)
try:
share_response_json = daily_share_callback_response.json()
if share_response_json["key"] == "ok" and share_response_json["info"] == "可以领奖":
fn_print("任务: {}, 可以领奖了.".format(task_items["bmh_task_title"]))
return True
elif share_response_json["key"] == "2002":
fn_print("任务: {}, 已经领过奖励了.")
return False
else:
fn_print("任务: {}, 不可以领奖".format(task_items["bmh_task_title"]))
return False
except Exception as e:
fn_print("调度任务异常:", e)
fn_print(daily_share_callback_response.json())
async def appointment_moreManorToDo_task(self, task_items):
"""
预约更多庄园必做任务
:param task_items:
:return:
"""
url = "https://huodong3.3839.com/n/hykb/cornfarm/ajax_ycx.php"
payload = (
f"ac=YcxGameDetail&id={task_items['bmh_task_id']}&r=0.{random.randint(100000000000000, 8999999999999999)}"
f"&scookie={urllib.parse.quote(self.cookie)}"
"&device=kbA25014349F11473F467DC6FF5C89E9D6")
am_response = await self.client.post(url, content=payload)
try:
am_response_json = am_response.json()
if am_response_json["key"] == "ok":
fn_print(f"任务: 【{task_items['bmh_task_title']}】预约成功!")
return True
else:
fn_print(f"任务: 【{task_items['bmh_task_title']}】预约失败!")
except Exception as e:
print(f"任务{task_items['bmh_task_title']}预约操作错误:{e}")
async def get_task_reward(self, task_items: dict):
"""
领取任务奖励
:param task_items: 任务组
:return:
"""
url = "https://huodong3.3839.com/n/hykb/cornfarm/ajax_daily.php"
payload = (
f"ac=DailyShareLing&smdeviceid=BTeK4FWZx3plsETCF1uY6S1h2uEajvI1AicKa4Lqz3U7Tt5wKKDZZqVmVr7WpkcEuSQKyiDA3d64bErE%2FsaJp3Q%3D%3D&verison=1.5.7.507&id={task_items['bmh_task_id']}&r=0.{random.randint(100000000000000, 8999999999999999)}&scookie={self.cookie}"
f"&device=kbA25014349F11473F467DC6FF5C89E9D6")
response = await self.client.post(url=url, content=payload)
try:
response_json = response.json()
if response_json["key"] == "ok":
fn_print(
f"任务: {task_items['bmh_task_title']}- ✅奖励领取成功!\n成熟度+{response_json['reward_csd_num']}\n已完成任务数量:{response_json['daily_renwu_success_total']}\n今日获得成熟度{response_json['daily_day_all_chengshoudu']}")
elif response_json["key"] == "2001":
fn_print(f"任务:【{task_items['bmh_task_title']}】今天已经领取过了!")
else:
fn_print(f"奖励领取失败!{response.json()}")
except Exception as e:
print("领取任务奖励异常: ", e)
async def get_moreManorToDo_task_reward(self, task_items, reward_type):
"""
领取更多庄园必做任务的奖励
:param task_items:
:param reward_type:
:return:
"""
url = "https://huodong3.3839.com/n/hykb/cornfarm/ajax_ycx.php"
if reward_type == "YcxToWechatRemindLing":
payload = {
"ac": reward_type,
"id": f"{task_items['bmh_task_id']}",
"smdeviceid": "BTeK4FWZx3plsETCF1uY6S1h2uEajvI1AicKa4Lqz3U7Tt5wKKDZZqVmVr7WpkcEuSQKyiDA3d64bErE/saJp3Q==",
"verison": "1.5.7.507",
"VersionCode": "342",
"r": f"0.{random.randint(100000000000000, 8999999999999999)}",
"scookie": self.cookie,
"device": "kbA25014349F11473F467DC6FF5C89E9D6"
}
elif reward_type == "YcxYuyueLing":
payload = {
"ac": reward_type,
"id": f"{task_items['bmh_task_id']}",
"smdeviceid": "BTeK4FWZx3plsETCF1uY6S1h2uEajvI1AicKa4Lqz3U7Tt5wKKDZZqVmVr7WpkcEuSQKyiDA3d64bErE/saJp3Q==",
"verison": "1.5.7.507",
"r": f"0.{random.randint(100000000000000, 8999999999999999)}",
"scookie": self.cookie,
"device": "kbA25014349F11473F467DC6FF5C89E9D6"
}
elif reward_type == "YcxToWeiboRemindLing":
payload = {
"ac": reward_type,
"id": f"{task_items['bmh_task_id']}",
"smdeviceid": "BTeK4FWZx3plsETCF1uY6S1h2uEajvI1AicKa4Lqz3U7Tt5wKKDZZqVmVr7WpkcEuSQKyiDA3d64bErE/saJp3Q==",
"verison": "1.5.7.507",
"VersionCode": "342",
"r": f"0.{random.randint(100000000000000, 8999999999999999)}",
"scookie": self.cookie,
"device": "kbA25014349F11473F467DC6FF5C89E9D6"
}
elif reward_type == "YcxToH5Url":
payload = {
"ac": reward_type,
"id": f"{task_items['bmh_task_id']}",
"r": f"0.{random.randint(100000000000000, 8999999999999999)}",
"scookie": self.cookie,
"device": "kbA25014349F11473F467DC6FF5C89E9D6"
}
response = await self.client.post(
url=url,
content=urllib.parse.urlencode(payload)
)
try:
m_response = response.json()
if m_response["key"] == "ok":
fn_print(f"任务: 【{task_items['bmh_task_title']}】领取奖励成功!")
elif m_response["key"] == "2001":
fn_print(f"任务: 【{task_items['bmh_task_title']}】已经领取过奖励啦")
else:
fn_print(f"奖励领取失败,{response.json()}")
except Exception as e:
print("领取任务奖励异常: ", e)
async def task(self):
await self.get_task_ids()
await self.get_recommendToDoToday_task_ids()
await self.get_moreManorToDo_task_ids()
for bmh_item in self.bmh_tasks:
if not await self.process_doItDaily_task(bmh_item):
continue
for mmtodo_item in self.moreManorToDo_tasks:
if not await self.process_moreManorToDo_task(mmtodo_item):
continue
await self.client.aclose()
async def run_single_task(cookie):
ht = AsyncHykbTasks(cookie)
await ht.task()
async def run_all_tasks(cookies):
tasks = [run_single_task(cookie) for cookie in cookies]
await asyncio.gather(*tasks)
async def main():
await run_all_tasks(hykb_cookie)
# if __name__ == '__main__':
# asyncio.run(main())
# send_notification_message_collection("好游快爆活动奖励领取通知 - {}".format(datetime.now().strftime("%Y/%m/%d")))