1.新增一些配方2.新增红包系统3.WPSConfigSystem中新增用户名替换空白字符机制

This commit is contained in:
2025-11-17 21:19:14 +08:00
parent 0342d83916
commit 803fb9d49f
9 changed files with 855 additions and 17 deletions

View File

@@ -0,0 +1,56 @@
from __future__ import annotations
from typing import Optional, Sequence
from Plugins.WPSAPI import GuideEntry
from .WPSRedPacketBase import WPSRedPacketBase
class WPSRedPacketClaim(WPSRedPacketBase):
"""抢红包入口"""
def get_guide_subtitle(self) -> str:
return "通过红包ID领取积分奖励"
def collect_command_entries(self):
return (
GuideEntry(
title="抢红包",
identifier="抢红包 <红包ID> [口令]",
description="输入红包ID后领取剩余份额口令红包需附带口令。",
),
)
def wake_up(self) -> None:
super().wake_up()
self.register_plugin("抢红包")
async def callback(self, message: str, chat_id: int, user_id: int) -> Optional[str]:
payload = self.parse_message_after_at(message).strip()
tokens = [token.strip() for token in payload.split() if token.strip()]
if not tokens:
return await self.send_markdown_message(
self.format_error("指令格式:`抢红包 <红包ID> [口令]`"),
chat_id,
user_id,
)
packet_id = tokens[0]
extra_tokens: Sequence[str] = tokens[1:]
username = self.config_api().get_user_name(user_id)
service = self.red_packet_service()
success, message_text, _ = service.claim_packet(
chat_id,
packet_id,
user_id,
username,
extra_tokens,
)
if success:
return await self.send_markdown_message(message_text, chat_id, user_id)
return await self.send_markdown_message(message_text, chat_id, user_id)
__all__ = ["WPSRedPacketClaim"]