mirror of
https://github.com/suyiiyii/nonebot-bison.git
synced 2026-05-09 18:27:56 +08:00
Merge branch 'main' into next
This commit is contained in:
@@ -0,0 +1,114 @@
|
||||
{
|
||||
"code": 0,
|
||||
"message": "0",
|
||||
"ttl": 1,
|
||||
"data": {
|
||||
"mid": 13164144,
|
||||
"name": "魔法Zc目录",
|
||||
"sex": "男",
|
||||
"face": "http://i0.hdslb.com/bfs/face/a84fa10f90f7060d0336384954ee1cde7a8e9bc6.jpg",
|
||||
"face_nft": 0,
|
||||
"sign": "每日18:00~22:00欢乐直播!请勿在任何乌有相关内容中刷Zc,尊重角色;商务合作qq271374252",
|
||||
"rank": 10000,
|
||||
"level": 6,
|
||||
"jointime": 0,
|
||||
"moral": 0,
|
||||
"silence": 0,
|
||||
"coins": 0,
|
||||
"fans_badge": true,
|
||||
"fans_medal": {
|
||||
"show": false,
|
||||
"wear": false,
|
||||
"medal": null
|
||||
},
|
||||
"official": {
|
||||
"role": 1,
|
||||
"title": "bilibili 2021百大UP主、知名游戏UP主、直播高能主播",
|
||||
"desc": "",
|
||||
"type": 0
|
||||
},
|
||||
"vip": {
|
||||
"type": 2,
|
||||
"status": 1,
|
||||
"due_date": 1702051200000,
|
||||
"vip_pay_type": 0,
|
||||
"theme_type": 0,
|
||||
"label": {
|
||||
"path": "",
|
||||
"text": "年度大会员",
|
||||
"label_theme": "annual_vip",
|
||||
"text_color": "#FFFFFF",
|
||||
"bg_style": 1,
|
||||
"bg_color": "#FB7299",
|
||||
"border_color": ""
|
||||
},
|
||||
"avatar_subscript": 1,
|
||||
"nickname_color": "#FB7299",
|
||||
"role": 3,
|
||||
"avatar_subscript_url": "http://i0.hdslb.com/bfs/vip/icon_Certification_big_member_22_3x.png"
|
||||
},
|
||||
"pendant": {
|
||||
"pid": 3399,
|
||||
"name": "2233幻星集",
|
||||
"image": "http://i0.hdslb.com/bfs/garb/item/20c07ded13498a5b12db99660c766ddd92ecfe31.png",
|
||||
"expire": 0,
|
||||
"image_enhance": "http://i0.hdslb.com/bfs/garb/item/20c07ded13498a5b12db99660c766ddd92ecfe31.png",
|
||||
"image_enhance_frame": ""
|
||||
},
|
||||
"nameplate": {
|
||||
"nid": 1,
|
||||
"name": "黄金殿堂",
|
||||
"image": "http://i2.hdslb.com/bfs/face/82896ff40fcb4e7c7259cb98056975830cb55695.png",
|
||||
"image_small": "http://i0.hdslb.com/bfs/face/627e342851dfda6fe7380c2fa0cbd7fae2e61533.png",
|
||||
"level": "稀有勋章",
|
||||
"condition": "单个自制视频总播放数\u003e=100万"
|
||||
},
|
||||
"user_honour_info": {
|
||||
"mid": 0,
|
||||
"colour": null,
|
||||
"tags": []
|
||||
},
|
||||
"is_followed": true,
|
||||
"top_photo": "http://i2.hdslb.com/bfs/space/853fea2728651588a2cdef0a1e586bcefff8e3d8.png",
|
||||
"theme": {},
|
||||
"sys_notice": {},
|
||||
"live_room": {
|
||||
"roomStatus": 1,
|
||||
"liveStatus": 0,
|
||||
"url": "https://live.bilibili.com/3044248?broadcast_type=0\u0026is_room_feed=1",
|
||||
"title": "【Zc】早朝危机合约!",
|
||||
"cover": "http://i0.hdslb.com/bfs/live/new_room_cover/cf7d4d3b2f336c6dba299644c3af952c5db82612.jpg",
|
||||
"roomid": 3044248,
|
||||
"roundStatus": 1,
|
||||
"broadcast_type": 0,
|
||||
"watched_show": {
|
||||
"switch": true,
|
||||
"num": 13753,
|
||||
"text_small": "1.3万",
|
||||
"text_large": "1.3万人看过",
|
||||
"icon": "https://i0.hdslb.com/bfs/live/a725a9e61242ef44d764ac911691a7ce07f36c1d.png",
|
||||
"icon_location": "",
|
||||
"icon_web": "https://i0.hdslb.com/bfs/live/8d9d0f33ef8bf6f308742752d13dd0df731df19c.png"
|
||||
}
|
||||
},
|
||||
"birthday": "07-21",
|
||||
"school": {
|
||||
"name": ""
|
||||
},
|
||||
"profession": {
|
||||
"name": "",
|
||||
"department": "",
|
||||
"title": "",
|
||||
"is_show": 0
|
||||
},
|
||||
"tags": [
|
||||
"评论区UP主",
|
||||
"目标是星辰大海"
|
||||
],
|
||||
"series": {
|
||||
"user_upgrade_status": 3,
|
||||
"show_upgrade_window": false
|
||||
},
|
||||
"is_senior_member": 1
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{"code":0,"message":"0","ttl":1,"data":{"mid":161775300,"name":"明日方舟","sex":"保密","face":"http://i0.hdslb.com/bfs/face/89154378c06a5ed332c40c2ca56f50cd641c0c90.jpg","face_nft":0,"sign":"重铸未来 方舟启航","rank":10000,"level":6,"jointime":0,"moral":0,"silence":0,"coins":0,"fans_badge":true,"fans_medal":{"show":false,"wear":false,"medal":null},"official":{"role":3,"title":"明日方舟官方账号","desc":"","type":1},"vip":{"type":2,"status":1,"due_date":1648828800000,"vip_pay_type":0,"theme_type":0,"label":{"path":"","text":"年度大会员","label_theme":"annual_vip","text_color":"#FFFFFF","bg_style":1,"bg_color":"#FB7299","border_color":""},"avatar_subscript":1,"nickname_color":"#FB7299","role":3,"avatar_subscript_url":"http://i0.hdslb.com/bfs/vip/icon_Certification_big_member_22_3x.png"},"pendant":{"pid":5305,"name":"明日方舟音律系列","image":"http://i0.hdslb.com/bfs/garb/item/615a1653281141ddf64cbb98c792ddaee78f7f40.png","expire":0,"image_enhance":"http://i0.hdslb.com/bfs/garb/item/516ecdf2d495a62f1bac31497c831b711823140c.webp","image_enhance_frame":"http://i0.hdslb.com/bfs/garb/item/c0751afbf950373c260254d02768eabf30ff3906.png"},"nameplate":{"nid":0,"name":"","image":"","image_small":"","level":"","condition":""},"user_honour_info":{"mid":0,"colour":null,"tags":[]},"is_followed":true,"top_photo":"http://i1.hdslb.com/bfs/space/6c6084808ec5bdff1985acc05ce0e126c49ad76e.png","theme":{},"sys_notice":{},"live_room":{"roomStatus":1,"liveStatus":0,"url":"https://live.bilibili.com/5555734?broadcast_type=0\u0026is_room_feed=1","title":"《明日方舟》2022新春前瞻特辑","cover":"http://i0.hdslb.com/bfs/live/new_room_cover/79af83a27f6001c1acfb47d1c0b879290f7c3308.jpg","roomid":5555734,"roundStatus":1,"broadcast_type":0,"watched_show":{"switch":true,"num":13033,"text_small":"1.3万","text_large":"1.3万人看过","icon":"https://i0.hdslb.com/bfs/live/a725a9e61242ef44d764ac911691a7ce07f36c1d.png","icon_location":"","icon_web":"https://i0.hdslb.com/bfs/live/8d9d0f33ef8bf6f308742752d13dd0df731df19c.png"}},"birthday":"","school":null,"profession":{"name":"","department":"","title":"","is_show":0},"tags":null,"series":{"user_upgrade_status":3,"show_upgrade_window":false},"is_senior_member":0}}
|
||||
@@ -1,3 +1,4 @@
|
||||
import typing
|
||||
from datetime import datetime
|
||||
|
||||
import pytest
|
||||
@@ -14,6 +15,10 @@ def bing_dy_list():
|
||||
return get_json("bilibili_bing_list.json")["data"]["cards"]
|
||||
|
||||
|
||||
if typing.TYPE_CHECKING:
|
||||
from nonebot_bison.platform.bilibili import Bilibili
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def bilibili(app: App):
|
||||
from nonebot_bison.platform import platform_manager
|
||||
@@ -76,3 +81,20 @@ async def test_fetch_new(bilibili, dummy_user_subinfo):
|
||||
post.text
|
||||
== "#罗德厨房——回甘##明日方舟#\r\n明日方舟官方美食漫画,正式开餐。\r\n往事如烟,安然即好。\r\nMenu 01:高脚羽兽烤串与罗德岛的领袖\r\n\r\n哔哩哔哩漫画阅读:https://manga.bilibili.com/detail/mc31998?from=manga_search\r\n\r\n关注并转发本动态,我们将会在5月27日抽取10位博士赠送【兔兔奇境】周边礼盒一份。 互动抽奖"
|
||||
)
|
||||
|
||||
|
||||
async def test_parse_target(bilibili: "Bilibili"):
|
||||
from nonebot_bison.platform.platform import Platform
|
||||
|
||||
res = await bilibili.parse_target(
|
||||
"https://space.bilibili.com/161775300?from=search&seid=130517740606234234234&spm_id_from=333.337.0.0"
|
||||
)
|
||||
assert res == "161775300"
|
||||
res2 = await bilibili.parse_target(
|
||||
"space.bilibili.com/161775300?from=search&seid=130517740606234234234&spm_id_from=333.337.0.0"
|
||||
)
|
||||
assert res2 == "161775300"
|
||||
with pytest.raises(Platform.ParseTargetException):
|
||||
await bilibili.parse_target(
|
||||
"https://www.bilibili.com/video/BV1qP4y1g738?spm_id_from=333.999.0.0"
|
||||
)
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
from datetime import datetime
|
||||
|
||||
import feedparser
|
||||
import pytest
|
||||
import respx
|
||||
from httpx import Response
|
||||
from nonebug.app import App
|
||||
from pytz import timezone
|
||||
|
||||
from .utils import get_file, get_json
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def bili_live(app: App):
|
||||
from nonebot_bison.platform import platform_manager
|
||||
|
||||
return platform_manager["bilibili-live"]
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@respx.mock
|
||||
async def test_fetch_bilibili_live_status(bili_live, dummy_user_subinfo):
|
||||
mock_bili_live_status = get_json("bili_live_status.json")
|
||||
|
||||
bili_live_router = respx.get(
|
||||
"https://api.bilibili.com/x/space/acc/info?mid=13164144"
|
||||
)
|
||||
bili_live_router.mock(return_value=Response(200, json=mock_bili_live_status))
|
||||
target = "13164144"
|
||||
res = await bili_live.fetch_new_post(target, [dummy_user_subinfo])
|
||||
assert bili_live_router.called
|
||||
assert len(res) == 0
|
||||
mock_bili_live_status["data"]["live_room"]["liveStatus"] = 1
|
||||
bili_live_router.mock(return_value=Response(200, json=mock_bili_live_status))
|
||||
res2 = await bili_live.fetch_new_post(target, [dummy_user_subinfo])
|
||||
post = res2[0][1][0]
|
||||
assert post.target_type == "Bilibili直播"
|
||||
assert post.text == "【Zc】早朝危机合约!"
|
||||
assert post.url == "https://live.bilibili.com/3044248"
|
||||
assert post.target_name == "魔法Zc目录"
|
||||
assert post.pics == [
|
||||
"http://i0.hdslb.com/bfs/live/new_room_cover/cf7d4d3b2f336c6dba299644c3af952c5db82612.jpg"
|
||||
]
|
||||
assert post.compress == True
|
||||
@@ -1,4 +1,5 @@
|
||||
import time
|
||||
import typing
|
||||
|
||||
import pytest
|
||||
import respx
|
||||
@@ -7,6 +8,9 @@ from nonebug.app import App
|
||||
|
||||
from .utils import get_json
|
||||
|
||||
if typing.TYPE_CHECKING:
|
||||
from nonebot_bison.platform.ncm_artist import NcmArtist
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def ncm_artist(app: App):
|
||||
@@ -48,3 +52,16 @@ async def test_fetch_new(ncm_artist, ncm_artist_0, ncm_artist_1, dummy_user_subi
|
||||
assert post.target_type == "ncm-artist"
|
||||
assert post.text == "新专辑发布:Y1K"
|
||||
assert post.url == "https://music.163.com/#/album?id=131074504"
|
||||
|
||||
|
||||
async def test_parse_target(ncm_artist: "NcmArtist"):
|
||||
from nonebot_bison.platform.platform import Platform
|
||||
|
||||
res = await ncm_artist.parse_target("32540734")
|
||||
assert res == "32540734"
|
||||
res = await ncm_artist.parse_target("https://music.163.com/#/artist?id=32540734")
|
||||
assert res == "32540734"
|
||||
res = await ncm_artist.parse_target("music.163.com/#/artist?id=32540734")
|
||||
assert res == "32540734"
|
||||
with pytest.raises(Platform.ParseTargetException):
|
||||
await ncm_artist.parse_target("music.163.com/#/rad?id=32540734")
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import time
|
||||
import typing
|
||||
|
||||
import pytest
|
||||
import respx
|
||||
@@ -7,6 +8,9 @@ from nonebug.app import App
|
||||
|
||||
from .utils import get_json
|
||||
|
||||
if typing.TYPE_CHECKING:
|
||||
from nonebot_bison.platform.ncm_radio import NcmRadio
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def ncm_radio(app: App):
|
||||
@@ -53,3 +57,14 @@ async def test_fetch_new(ncm_radio, ncm_radio_0, ncm_radio_1, dummy_user_subinfo
|
||||
"http://p1.music.126.net/H5em5xUNIYXcjJhOmeaSqQ==/109951166647436789.jpg"
|
||||
]
|
||||
assert post.target_name == "《明日方舟》游戏原声OST"
|
||||
|
||||
|
||||
async def test_parse_target(ncm_radio: "NcmRadio"):
|
||||
res = await ncm_radio.parse_target("https://music.163.com/#/djradio?id=793745436")
|
||||
assert res == "793745436"
|
||||
res = await ncm_radio.parse_target("music.163.com/#/djradio?id=793745436")
|
||||
assert res == "793745436"
|
||||
res = await ncm_radio.parse_target("793745436")
|
||||
assert res == "793745436"
|
||||
with pytest.raises(ncm_radio.ParseTargetException):
|
||||
await ncm_radio.parse_target("music.163.com/#/alm?id=793745436")
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import typing
|
||||
from datetime import datetime
|
||||
|
||||
import feedparser
|
||||
@@ -9,6 +10,9 @@ from pytz import timezone
|
||||
|
||||
from .utils import get_file, get_json
|
||||
|
||||
if typing.TYPE_CHECKING:
|
||||
from nonebot_bison.platform.weibo import Weibo
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def weibo(app: App):
|
||||
@@ -132,3 +136,16 @@ def test_chaohua_tag(weibo):
|
||||
tags = weibo.get_tags(test_post)
|
||||
assert "刚出生的小羊驼长啥样" in tags
|
||||
assert "小羊驼三三超话" in tags
|
||||
|
||||
|
||||
async def test_parse_target(weibo: "Weibo"):
|
||||
from nonebot_bison.platform.platform import Platform
|
||||
|
||||
res = await weibo.parse_target("https://weibo.com/u/6441489862")
|
||||
assert res == "6441489862"
|
||||
res = await weibo.parse_target("weibo.com/u/6441489862")
|
||||
assert res == "6441489862"
|
||||
res = await weibo.parse_target("6441489862")
|
||||
assert res == "6441489862"
|
||||
with pytest.raises(Platform.ParseTargetException):
|
||||
await weibo.parse_target("https://weibo.com/arknights")
|
||||
|
||||
Reference in New Issue
Block a user