diff --git a/.github/workflows/publish_teenstudy.yml b/.github/workflows/publish_teenstudy.yml
index e6436e7..8831415 100644
--- a/.github/workflows/publish_teenstudy.yml
+++ b/.github/workflows/publish_teenstudy.yml
@@ -23,7 +23,7 @@ jobs:
- name: Build package
run: |
python -m build
- twine check --strict dist/*
+ twine upload dist/*
- name: Publish package
uses: pypa/gh-action-pypi-publish@master
with:
diff --git a/README.md b/README.md
index 05e0535..53ae977 100644
--- a/README.md
+++ b/README.md
@@ -44,9 +44,9 @@
|青春山东|支持|需要自行抓包|
|重庆共青团|支持|需要自行抓包|
|吉青飞扬|支持|需要自行抓包|
+|黑龙江共青团|支持|需要自行抓包,该地区上线测试中|
|天府新青年|支持|不进入公众号token时效大于1周|
|河南共青团|不支持|cookie时效小于1周|
-|黑龙江共青团|待开发||
|广西青年圈|待开发||
|青春湖南|待开发||
|甘肃青年|待开发||
@@ -80,8 +80,8 @@
第二种方式(二选一)
-1、使用`pip install TeenStudy`来进行安装,使用`pip install TeenStudy -U`进行更新
-2、使用`nb plugin install TeenStudy`来进行安装,使用`nb plugin install TeenStudy -U`进行更新
+- 使用`pip install TeenStudy`来进行安装,使用`pip install TeenStudy -U`进行更新
+- 使用`nb plugin install TeenStudy`来进行安装,使用`nb plugin install TeenStudy -U`进行更新
@@ -160,10 +160,17 @@
## 更新日志
-### 2023/05/11
+### 2023/05/21
+
+- 增加黑龙江地区,需要自行抓包,该地区上线测试中,请积极提issue反馈
+- 下版本为大版本更新,将添加新功能,优化功能,请积极提issue反馈或加交流群反馈
+
+
+2023/05/11
- 增加广东地区,无需抓包[#13](https://github.com/ZM25XC/TeenStudy/issues/13),感谢[@neal240](https://github.com/neal240)提供账号测试
+
2023/05/06
diff --git a/TeenStudy/utils/dxx.py b/TeenStudy/utils/dxx.py
index f139165..a869629 100644
--- a/TeenStudy/utils/dxx.py
+++ b/TeenStudy/utils/dxx.py
@@ -1075,3 +1075,71 @@ async def guangdong(user_id: int) -> dict:
"status": 500,
"msg": "提交失败!"
}
+
+async def heilongjiang(user_id: int) -> dict:
+ """
+ 黑龙江共青团
+ :param user_id:用户ID
+ :return:
+ """
+ result = await User.filter(user_id=user_id).values()
+ if not result:
+ return {
+ "status": 500,
+ "msg": "用户数据不存在!"
+ }
+ else:
+ cookie = result[0]["cookie"]
+ answer = await Answer.all().order_by("time").values()
+ headers = {
+ "Host": "tsw.ithyxy.com",
+ "Connection": "keep-alive",
+ "Accept": "application/json, text/plain, */*",
+ "User-Agent": "Mozilla/5.0 (Linux; Android 12; M2007J3SC Build/SKQ1.220303.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/86.0.4240.99 XWEB/3262 MMWEBSDK/20220204 Mobile Safari/537.36 MMWEBID/6170 MicroMessenger/8.0.20.2100(0x28001438) Process/toolsmp WeChat/arm32 Weixin NetType/WIFI Language/zh_CN ABI/arm64",
+ "X-Requested-With": "com.tencent.mm",
+ "Referer": "http://tsw.ithyxy.com/login",
+ "Accept-Encoding": "gzip, deflate",
+ "Accept-Language": "zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7",
+ "Cookie": cookie
+ }
+ try:
+ learn_url = "http://tsw.ithyxy.com/h5/learn/home"
+ async with AsyncClient(headers=headers, timeout=5, max_redirects=5) as client:
+ response = await client.get(url=learn_url)
+ response.encoding = response.charset_encoding
+ if response.status_code == 200 and response.json()["code"] == 200:
+ learn_id = response.json()["data"]["id"]
+ commit_url = f"http://tsw.ithyxy.com/h5/learn/enter?id={learn_id}"
+ async with AsyncClient(headers=headers, timeout=5, max_redirects=5) as client:
+ response = await client.get(url=commit_url)
+ response.encoding = response.charset_encoding
+ if response.status_code == 200 and response.json()["code"] == 200:
+ await User.filter(user_id=user_id).update(
+ commit_time=time.time(),
+ catalogue=answer[-1]["catalogue"]
+ )
+ await commit(user_id=user_id, catalogue=answer[-1]["catalogue"], status=True)
+ return {
+ "status": 0,
+ "catalogue": answer[-1]["catalogue"],
+ "msg": "提交成功!"
+ }
+ else:
+ await commit(user_id=user_id, catalogue=answer[-1]["catalogue"], status=False)
+ return {
+ "status": 500,
+ "msg": "提交失败,cookie失效!"
+ }
+ else:
+ await commit(user_id=user_id, catalogue=answer[-1]["catalogue"], status=False)
+ return {
+ "status": 500,
+ "msg": "提交失败,cookie失效!"
+ }
+ except Exception as e:
+ logger.error(e)
+ await commit(user_id=user_id, catalogue=answer[-1]["catalogue"], status=False)
+ return {
+ "status": 500,
+ "msg": "提交失败!"
+ }
\ No newline at end of file
diff --git a/TeenStudy/utils/utils.py b/TeenStudy/utils/utils.py
index 72d7009..42c1872 100644
--- a/TeenStudy/utils/utils.py
+++ b/TeenStudy/utils/utils.py
@@ -179,6 +179,15 @@ class UserModel(BaseModel):
"status": True,
"catalogue": None
},
+ {
+ "area": "黑龙江",
+ "host": "tsw.ithyxy.com",
+ "referer": None,
+ "origin": "http://tsw.ithyxy.com/login",
+ "url": "http://tsw.ithyxy.com/h5/learn/home",
+ "status": True,
+ "catalogue": None
+ },
]
RESOURCE = [
{
@@ -517,6 +526,8 @@ async def distribute_area(user_id: int, area: str) -> dict:
return await dxx.jilin(user_id=user_id)
elif area == "广东":
return await dxx.guangdong(user_id=user_id)
+ elif area == "黑龙江":
+ return await dxx.heilongjiang(user_id=user_id)
else:
return {
"status": 404,
@@ -544,6 +555,8 @@ async def distribute_area_url(province: str, user_id: int, group_id: int) -> dic
province = "jilin"
elif province == "广东":
province="guangdong"
+ elif province == "黑龙江":
+ province = "heilongjiang"
data = f"http://{config['DXX_IP']}:{config['DXX_PORT']}/TeenStudy/api/{province}?user_id={user_id}&group_id={group_id}"
img = qrcode.make(data=data)
buf = BytesIO()
diff --git a/TeenStudy/web/api/add.py b/TeenStudy/web/api/add.py
index 2e96d23..c465b68 100644
--- a/TeenStudy/web/api/add.py
+++ b/TeenStudy/web/api/add.py
@@ -9,7 +9,7 @@
from httpx import AsyncClient
from ..pages.add import hubei_page, jiangxi_page, jiangsu_page, anhui_page, sichuan_page, shandong_page, \
- chongqing_page, jilin_page, guangdong_page
+ chongqing_page, jilin_page, guangdong_page,heilongjiang_page
from ..utils.add import write_to_database
from ...models.accuont import User, AddUser
from ...models.dxx import JiangXi
@@ -814,3 +814,142 @@ async def guangdong(user_id: int, group_id: int):
return RedirectResponse(
url="/TeenStudy/login"
)
+
+
+@route.post("/heilongjiang/add", response_class=HTMLResponse)
+async def heilongjiang_add(data: dict) -> JSONResponse:
+ user_id = data["user_id"]
+ if await User.filter(user_id=user_id).count():
+ return JSONResponse({
+ "status": 500,
+ "msg": "添加失败!,用户信息存在!"
+ })
+ else:
+ try:
+ cookie = data["cookie"]
+ url = "http://tsw.ithyxy.com/h5/auth/info"
+ headers = {
+ "Host": "tsw.ithyxy.com",
+ "Connection": "keep-alive",
+ "Accept": "application/json, text/plain, */*",
+ "User-Agent": "Mozilla/5.0 (Linux; Android 12; M2007J3SC Build/SKQ1.220303.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/86.0.4240.99 XWEB/3262 MMWEBSDK/20220204 Mobile Safari/537.36 MMWEBID/6170 MicroMessenger/8.0.20.2100(0x28001438) Process/toolsmp WeChat/arm32 Weixin NetType/WIFI Language/zh_CN ABI/arm64",
+ "X-Requested-With": "com.tencent.mm",
+ "Referer": "http://tsw.ithyxy.com/login",
+ "Accept-Encoding": "gzip, deflate",
+ "Accept-Language": "zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7",
+ "Cookie": cookie
+ }
+ async with AsyncClient(headers=headers) as client:
+ response = await client.get(url, headers=headers)
+ response.encoding = response.charset_encoding
+ if response.status_code == 200 and response.json()["code"] == 200:
+ result = response.json()
+ data["name"] = result["data"]["name"]
+ data["gender"] = result["data"]["sex"]
+ data["mobile"] = result["data"]["phone"]
+ class_url = "http://tsw.ithyxy.com/h5/auth/class?id=0"
+ async with AsyncClient(headers=headers) as client:
+ response = await client.get(url=class_url)
+ response.encoding = response.charset_encoding
+ if response.status_code == 200 and response.json()["code"] == 200:
+ university_list = response.json()["data"]
+ for x, item in enumerate(result["data"]["path"]):
+ if x == 0:
+ for item2 in university_list:
+ if item == item2["id"]:
+ data["university_type"] = item2["name"]
+ break
+ elif x == 1:
+ async with AsyncClient(headers=headers) as client:
+ response = await client.get(
+ url=f"http://tsw.ithyxy.com/h5/auth/class?id={result['data']['path'][0]}")
+ response.encoding = response.charset_encoding
+ if response.status_code == 200 and response.json()["code"] == 200:
+ university_list = response.json()["data"]
+ for item2 in university_list:
+ if item == item2["id"]:
+ data["university"] = item2["name"]
+ data["university_id"] = item
+ break
+ else:
+ data["university"] = item
+ continue
+ elif x == 2:
+ async with AsyncClient(headers=headers) as client:
+ response = await client.get(
+ url=f"http://tsw.ithyxy.com/h5/auth/class?id={result['data']['path'][1]}")
+ response.encoding = response.charset_encoding
+ if response.status_code == 200 and response.json()["code"] == 200:
+ university_list = response.json()["data"]
+ for item2 in university_list:
+ if item == item2["id"]:
+ data["college"] = item2["name"]
+ data["college_id"] = item
+ break
+ else:
+ data["college"] = item
+ continue
+ elif x == 3:
+ async with AsyncClient(headers=headers) as client:
+ response = await client.get(
+ url=f"http://tsw.ithyxy.com/h5/auth/class?id={result['data']['path'][2]}")
+ response.encoding = response.charset_encoding
+ if response.status_code == 200 and response.json()["code"] == 200:
+ university_list = response.json()["data"]
+ for item2 in university_list:
+ if item == item2["id"]:
+ data["organization"] = item2["name"]
+ data["organization_id"] = item
+ break
+ else:
+ data["organization"] = item
+ continue
+ status = await write_to_database(data=data)
+ if status:
+ return JSONResponse(
+ {
+ "status": 0,
+ "msg": "添加成功!"
+ }
+ )
+ else:
+ return JSONResponse({
+ "status": 500,
+ "msg": "添加失败!"
+ })
+ else:
+ data["university"] = result["data"]["path"][0]
+ data["college"] = result["data"]["path"][1]
+ status = await write_to_database(data=data)
+ if status:
+ return JSONResponse(
+ {
+ "status": 0,
+ "msg": "添加成功!"
+ }
+ )
+ else:
+ return JSONResponse({
+ "status": 500,
+ "msg": "添加失败!"
+ })
+ else:
+ return JSONResponse({"status": 500, "msg": "添加失败!"})
+ except Exception as e:
+ return JSONResponse({
+ "status": 500,
+ "msg": f"添加失败,{e}"
+ })
+
+
+@route.get("/heilongjiang", response_class=HTMLResponse)
+async def heilongjiang(user_id: int, group_id: int):
+ result = await AddUser.filter(user_id=user_id, group_id=group_id, status="未通过").count()
+ if result:
+ return heilongjiang_page.render(
+ site_title='黑龙江共青团 | TeenStudy',
+ site_icon="https://i.328888.xyz/2023/02/23/xIh5k.png"
+ )
+ return RedirectResponse(
+ url="/TeenStudy/login"
+ )
\ No newline at end of file
diff --git a/TeenStudy/web/pages/add.py b/TeenStudy/web/pages/add.py
index 968e258..b9efcb8 100644
--- a/TeenStudy/web/pages/add.py
+++ b/TeenStudy/web/pages/add.py
@@ -938,3 +938,66 @@
)
guangdong_page = Page(title='添加大学习', body=[logo, Divider(), guangdong_table, footer])
+
+heilongjiang_table = Form(
+ title="黑龙江共青团",
+ mode=DisplayModeEnum.horizontal,
+ api="post:/TeenStudy/api/heilongjiang/add",
+ redirect="/TeenStudy/login",
+ body=[
+ InputText(
+ label="用户ID",
+ description="用户ID,为用户QQ号,无需填写",
+ name="user_id",
+ value="${user_id}",
+ disabled=True
+ ),
+ InputText(
+ label="通知群ID",
+ description="通知群号,无需填写",
+ name="group_id",
+ value="${group_id}",
+ disabled=True
+ ),
+ InputText(
+ label="地区",
+ description="所处省份",
+ name="area",
+ value="黑龙江",
+ disabled=True
+ ),
+ InputText(
+ label="登录密码",
+ type='input-password',
+ description="可不填,默认为用户ID",
+ name="password",
+ inline=False,
+ required=False,
+ value="",
+ clearable=True,
+ maxLength=16
+ ),
+ InputText(
+ label="姓名",
+ description="对应黑龙江共青团个人信息页 您的姓名",
+ name="name",
+ inline=False,
+ required=True,
+ value="",
+ clearable=True,
+ maxLength=8
+ ),
+ InputText(
+ label="cookie",
+ description="自行抓包获取,结构为:SESSION=Y2RhZThmZTUtM2QzXXXXXXXXWIxMDktZjI5ZDk2NzNmOTY5",
+ name="cookie",
+ inline=False,
+ required=True,
+ value="",
+ clearable=True,
+ )
+
+ ]
+)
+
+heilongjiang_page = Page(title='添加大学习', body=[logo, Divider(), heilongjiang_table, footer])
\ No newline at end of file
diff --git a/TeenStudy/web/pages/admin.py b/TeenStudy/web/pages/admin.py
index 1b68d1d..3c537c9 100644
--- a/TeenStudy/web/pages/admin.py
+++ b/TeenStudy/web/pages/admin.py
@@ -1503,6 +1503,82 @@
maxLength=32
)]
)
+"""黑龙江地区添加成员面板"""
+heilongjiang_table = Form(
+ title="黑龙江共青团",
+ mode=DisplayModeEnum.horizontal,
+ api="post:/TeenStudy/api/heilongjiang/add",
+ redirect="/TeenStudy/login",
+ body=[
+ Select(
+ label="群聊",
+ name="group_id",
+ description="需要添加的群组",
+ checkAll=False,
+ source="get:/TeenStudy/api/get_group_list",
+ value='',
+ multiple=False,
+ required=True,
+ searchable=True,
+ joinValues=False,
+ extractValue=True,
+ statistics=True,
+ ),
+ Select(
+ label="用户ID",
+ name="user_id",
+ description="需要添加的用户ID",
+ checkAll=False,
+ source="get:/TeenStudy/api/get_member_list?group_id=${group_id}",
+ value='',
+ multiple=False,
+ required=True,
+ searchable=True,
+ joinValues=False,
+ extractValue=True,
+ statistics=True,
+ hiddenOn="${group_id==''?true:false}"
+ ),
+ InputText(
+ label="地区",
+ description="所处省份",
+ name="area",
+ value="黑龙江",
+ disabled=True
+ ),
+ InputText(
+ label="登录密码",
+ type='input-password',
+ description="可不填,默认为用户ID",
+ name="password",
+ inline=False,
+ required=False,
+ value="",
+ clearable=True,
+ maxLength=16
+ ),
+ InputText(
+ label="姓名",
+ description="对应黑龙江共青团个人信息页 您的姓名",
+ name="name",
+ inline=False,
+ required=True,
+ value="",
+ clearable=True,
+ maxLength=8
+ ),
+ InputText(
+ label="cookie",
+ description="自行抓包获取,结构为:SESSION=Y2RhZThmZTUtM2QzXXXXXXXXWIxMDktZjI5ZDk2NzNmOTY5",
+ name="cookie",
+ inline=False,
+ required=True,
+ value="",
+ clearable=True,
+ )
+
+ ]
+)
"""推送群聊模板"""
push_table = CRUD(mode='table',
title='',
@@ -1586,6 +1662,8 @@
schema=Page(title='吉青飞扬', body=[jilin_table]))
guangdong_page = PageSchema(url='/add/guangdong', icon='fa fa-pen-to-square', label='广东共青团',
schema=Page(title='广东共青团', body=[guangdong_table]))
+heilongjiang_page = PageSchema(url='/add/heilongjiang', icon='fa fa-pen-to-square', label='黑龙江共青团',
+ schema=Page(title='黑龙江共青团', body=[heilongjiang_table]))
admin_app = App(brandName='TeenStudy',
logo='https://i.328888.xyz/2023/02/23/xIh5k.png',
header=header,
@@ -1594,7 +1672,7 @@
admin_page,
PageSchema(icon='fa fa-circle-user', label='成员管理',
children=[list_page, hubei_page, jiangxi_page, jiangsu_page, anhui_page,
- sichuan_page, shandong_page, chongqing_page, jilin_page,guangdong_page]),
+ sichuan_page, shandong_page, chongqing_page, jilin_page,guangdong_page,heilongjiang_page]),
PageSchema(url="/notice", label='推送列表', icon='fa fa-bell',
schema=Page(title='', body=[push_table])),
PageSchema(url="/request", label='申请记录', icon='fa fa-circle-info',
diff --git a/pyproject.toml b/pyproject.toml
index 5617b8b..560d068 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,6 +1,6 @@
[tool.poetry]
name = "TeenStudy"
-version = "0.1.8"
+version = "0.1.9"
description = "基于nonebot2异步框架的青年大学自动提交插件基于nonebot2的青年大学习自动提交插件,用于自动完成大学习,在后台留下记录,返回完成截图"
authors = ["ZM25XC "]
license="MIT"