async def handle_group_message(cls, msg, user_id, group_id): msg = msg.replace("#", "#") p = BotUtils(user_id=user_id, group_id=group_id) if msg in ("一言", "#一言"): return await p.proc_one_sentence() elif msg.startswith("#点歌"): return await p.proc_song(msg) elif msg.startswith("#翻译"): return p.proc_translation(msg) elif msg.startswith("#动态"): return await p.proc_dynamic(msg) elif msg.startswith("#勋章查询"): try: return await p.proc_query_medal(msg) except Exception as e: logging.error( f"Error in proc_query_medal: {e}\n{traceback.format_exc()}" ) elif msg.lower() in ("#h", "#help", "#帮助", "#指令"): return await p.proc_help()
async def proc_song(self, msg): song_name = msg.split("点歌")[-1].strip() if not song_name: return {} strip_name = song_name.replace("管珩心", "").replace("泡泡", "").lower().replace( "hansy", "").strip() song_name = strip_name if strip_name else song_name try: song_id = await BotUtils.get_song_id(song_name) except Exception as e: tb = traceback.format_exc() error_msg = f"Error happened in BotUtils.get_song_id: {e}\n{tb}" logging.error(error_msg) return error_msg return f"[CQ:music,type=163,id={song_id}]" if song_id else f"未找到歌曲「{song_name}」"