-
Notifications
You must be signed in to change notification settings - Fork 610
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
542 changed files
with
173 additions
and
152 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
__version__: v0.1.4.1 | ||
__version__: v0.1.4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
from .music_163 import get_song_id, get_song_info | ||
from nonebot.adapters.onebot.v11 import Bot, MessageEvent, GroupMessageEvent, Message | ||
from nonebot.params import CommandArg | ||
from nonebot.typing import T_State | ||
from services.log import logger | ||
from nonebot import on_command | ||
from utils.message_builder import music | ||
|
||
|
||
__zx_plugin_name__ = "点歌" | ||
__plugin_usage__ = """ | ||
usage: | ||
在线点歌 | ||
指令: | ||
点歌 [歌名] | ||
""".strip() | ||
__plugin_des__ = "为你点播了一首曾经的歌" | ||
__plugin_cmd__ = ["点歌 [歌名]"] | ||
__plugin_type__ = ("一些工具",) | ||
__plugin_version__ = 0.1 | ||
__plugin_author__ = "HibiKier" | ||
__plugin_settings__ = { | ||
"level": 5, | ||
"default_status": True, | ||
"limit_superuser": False, | ||
"cmd": ["点歌"], | ||
} | ||
|
||
|
||
music_handler = on_command("点歌", priority=5, block=True) | ||
|
||
|
||
@music_handler.handle() | ||
async def handle_first_receive(state: T_State, arg: Message = CommandArg()): | ||
if args := arg.extract_plain_text().strip(): | ||
state["song_name"] = args | ||
|
||
|
||
@music_handler.got("song_name", prompt="歌名是?") | ||
async def _(bot: Bot, event: MessageEvent, state: T_State): | ||
song = state["song_name"] | ||
song_id = await get_song_id(song) | ||
if not song_id: | ||
await music_handler.finish("没有找到这首歌!", at_sender=True) | ||
await music_handler.send(music("163", song_id)) | ||
logger.info( | ||
f"(USER {event.user_id}, GROUP " | ||
f"{event.group_id if isinstance(event, GroupMessageEvent) else 'private'})" | ||
f" 点歌 :{song}" | ||
) | ||
|
||
|
||
|
||
|
82 changes: 41 additions & 41 deletions
82
plugins/c_song/music_163.py → plugins/music/music_163.py
100755 → 100644
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,41 @@ | ||
from utils.http_utils import AsyncHttpx | ||
import json | ||
|
||
|
||
headers = {"referer": "http://music.163.com"} | ||
cookies = {"appver": "2.0.2"} | ||
|
||
|
||
async def search_song(song_name: str): | ||
""" | ||
搜索歌曲 | ||
:param song_name: 歌名 | ||
""" | ||
r = await AsyncHttpx.post( | ||
f"http://music.163.com/api/search/get/", | ||
data={"s": song_name, "limit": 1, "type": 1, "offset": 0}, | ||
) | ||
if r.status_code != 200: | ||
return None | ||
return json.loads(r.text) | ||
|
||
|
||
async def get_song_id(song_name: str) -> int: | ||
""" """ | ||
r = await search_song(song_name) | ||
try: | ||
return r["result"]["songs"][0]["id"] | ||
except KeyError: | ||
return 0 | ||
|
||
|
||
async def get_song_info(songId: int): | ||
""" | ||
获取歌曲信息 | ||
""" | ||
r = await AsyncHttpx.post( | ||
f"http://music.163.com/api/song/detail/?id={songId}&ids=%5B{songId}%5D", | ||
) | ||
if r.status_code != 200: | ||
return None | ||
return json.loads(r.text) | ||
from utils.http_utils import AsyncHttpx | ||
import json | ||
|
||
|
||
headers = {"referer": "http://music.163.com"} | ||
cookies = {"appver": "2.0.2"} | ||
|
||
|
||
async def search_song(song_name: str): | ||
""" | ||
搜索歌曲 | ||
:param song_name: 歌名 | ||
""" | ||
r = await AsyncHttpx.post( | ||
f"http://music.163.com/api/search/get/", | ||
data={"s": song_name, "limit": 1, "type": 1, "offset": 0}, | ||
) | ||
if r.status_code != 200: | ||
return None | ||
return json.loads(r.text) | ||
|
||
|
||
async def get_song_id(song_name: str) -> int: | ||
""" """ | ||
r = await search_song(song_name) | ||
try: | ||
return r["result"]["songs"][0]["id"] | ||
except KeyError: | ||
return 0 | ||
|
||
|
||
async def get_song_info(songId: int): | ||
""" | ||
获取歌曲信息 | ||
""" | ||
r = await AsyncHttpx.post( | ||
f"http://music.163.com/api/song/detail/?id={songId}&ids=%5B{songId}%5D", | ||
) | ||
if r.status_code != 200: | ||
return None | ||
return json.loads(r.text) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.