Skip to content

Commit

Permalink
临时提交,回家过年
Browse files Browse the repository at this point in the history
  • Loading branch information
黄传 committed Jan 18, 2025
1 parent 6dd7d2d commit d6e270e
Show file tree
Hide file tree
Showing 25 changed files with 1,306 additions and 36 deletions.
1 change: 1 addition & 0 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,4 @@ plugins:
- scheduler_plugin
- weather_query
- workflow_plugin
- web_search
9 changes: 5 additions & 4 deletions plugins/music_player/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ async def _play_music(self, params: Dict[str, Any]) -> Dict[str, Any]:
music_name = re.sub(r'\u2066|\u2067|\u2068|\u2069', '', music_name)

result = await self._get_music(music_name, singer, source, True)
return result
music_url = result["music_url"]
return f"music_url:{music_url} \nlyrics:{result['lyrics']}"

async def _get_music(self, music_name: str, singer: str, source: str, repeat: bool) -> Dict[str, Any]:
download_link = "未找到匹配的音乐"
Expand All @@ -95,7 +96,7 @@ async def _get_music(self, music_name: str, singer: str, source: str, repeat: bo
if result:
music_url = result.get("url")
lyrics = self._clean_lrc(result.get("lrc"))
return f"music_url:{music_url} \nlyrics:{lyrics}"
return {"music_url":music_url,"lyrics":lyrics}

file_id = await self._get_file_id(music_name, singer)
if file_id:
Expand All @@ -105,13 +106,13 @@ async def _get_music(self, music_name: str, singer: str, source: str, repeat: bo
if response.status == 302:
lyrics = await self._get_lyrics(music_name, singer)
lyrics = lyrics if lyrics else "未找到歌词"
return f"music_url:{download_link} \nlyrics:{lyrics}"
return {"music_url":download_link,"lyrics":lyrics}
elif repeat:
return await self._get_music(music_name, "", source, False)

lyrics = await self._get_lyrics(music_name, singer)
lyrics = lyrics if lyrics else "未找到歌词"
return f"music_url:{download_link} \nlyrics:{lyrics}"
return {"music_url":download_link,"lyrics":lyrics}


@staticmethod
Expand Down
21 changes: 21 additions & 0 deletions plugins/onebot_adapter/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from framework.logger import get_logger
from framework.plugin_manager.plugin import Plugin
from .adapter import OneBotAdapter
from .config import OneBotConfig

logger = get_logger("OneBot-Adapter")


class OneBotAdapterPlugin(Plugin):
def __init__(self):
pass

def on_load(self):
self.im_registry.register("onebot", OneBotAdapter, OneBotConfig)
logger.info("OneBotAdapter registered")

def on_start(self):
logger.info("OneBotAdapterPlugin started")

def on_stop(self):
logger.info("OneBotAdapterPlugin stopped")
Loading

0 comments on commit d6e270e

Please sign in to comment.