|
|
@@ -12,12 +12,11 @@ from pyrogram.types import (
|
|
|
ChatMemberUpdated,
|
|
|
InlineKeyboardButton,
|
|
|
InlineKeyboardMarkup,
|
|
|
- KeyboardButton,
|
|
|
Message,
|
|
|
- ReplyKeyboardMarkup,
|
|
|
)
|
|
|
|
|
|
from wbb import BOT_PROFILE_ID, BOT_USERNAME, app, log
|
|
|
+from wbb.core.reply_keyboard import remove_reply_keyboard
|
|
|
from wbb.services.directory import (
|
|
|
DirectoryServiceError,
|
|
|
admin_change_teacher_state,
|
|
|
@@ -96,45 +95,63 @@ def _directory_keyboard(
|
|
|
profile: dict[str, Any] | None,
|
|
|
*,
|
|
|
is_admin: bool,
|
|
|
-) -> ReplyKeyboardMarkup:
|
|
|
+) -> InlineKeyboardMarkup:
|
|
|
status = str((profile or {}).get("application_status") or "none")
|
|
|
- rows: list[list[KeyboardButton]] = [
|
|
|
- [KeyboardButton(BUTTON_BROWSE)],
|
|
|
+ rows: list[list[InlineKeyboardButton]] = [
|
|
|
+ [InlineKeyboardButton(BUTTON_BROWSE, callback_data="dir:browse")],
|
|
|
]
|
|
|
if status == APPLICATION_APPROVED:
|
|
|
rows.extend(
|
|
|
[
|
|
|
[
|
|
|
- KeyboardButton(
|
|
|
- BUTTON_UNLIST if profile and profile.get("listed") else BUTTON_LIST
|
|
|
+ InlineKeyboardButton(
|
|
|
+ BUTTON_UNLIST if profile and profile.get("listed") else BUTTON_LIST,
|
|
|
+ callback_data=(
|
|
|
+ "dir:self:unlist"
|
|
|
+ if profile and profile.get("listed")
|
|
|
+ else "dir:self:list"
|
|
|
+ ),
|
|
|
),
|
|
|
- KeyboardButton(
|
|
|
+ InlineKeyboardButton(
|
|
|
BUTTON_OFFLINE
|
|
|
if profile and profile.get("online")
|
|
|
- else BUTTON_ONLINE
|
|
|
+ else BUTTON_ONLINE,
|
|
|
+ callback_data=(
|
|
|
+ "dir:self:offline"
|
|
|
+ if profile and profile.get("online")
|
|
|
+ else "dir:self:online"
|
|
|
+ ),
|
|
|
),
|
|
|
],
|
|
|
- [KeyboardButton(BUTTON_STATUS)],
|
|
|
+ [InlineKeyboardButton(BUTTON_STATUS, callback_data="dir:status")],
|
|
|
]
|
|
|
)
|
|
|
else:
|
|
|
rows.append(
|
|
|
[
|
|
|
- KeyboardButton(
|
|
|
+ InlineKeyboardButton(
|
|
|
"技师申请审核中"
|
|
|
if status == APPLICATION_PENDING
|
|
|
- else BUTTON_APPLY
|
|
|
+ else BUTTON_APPLY,
|
|
|
+ callback_data=(
|
|
|
+ "dir:status"
|
|
|
+ if status == APPLICATION_PENDING
|
|
|
+ else "dir:apply"
|
|
|
+ ),
|
|
|
)
|
|
|
]
|
|
|
)
|
|
|
if is_admin:
|
|
|
- rows.append([KeyboardButton(BUTTON_APPROVAL)])
|
|
|
- return ReplyKeyboardMarkup(
|
|
|
+ rows.append(
|
|
|
+ [
|
|
|
+ InlineKeyboardButton(
|
|
|
+ BUTTON_APPROVAL,
|
|
|
+ callback_data="dir:admin:pending:1",
|
|
|
+ )
|
|
|
+ ]
|
|
|
+ )
|
|
|
+ return InlineKeyboardMarkup(
|
|
|
rows,
|
|
|
- resize_keyboard=True,
|
|
|
- is_persistent=True,
|
|
|
- selective=True,
|
|
|
- placeholder="浏览技师、咨询或评价",
|
|
|
)
|
|
|
|
|
|
|
|
|
@@ -225,6 +242,7 @@ async def send_directory_menu(
|
|
|
) -> None:
|
|
|
if not message.from_user:
|
|
|
return
|
|
|
+ await remove_reply_keyboard(message)
|
|
|
if source_chat_id is not None:
|
|
|
try:
|
|
|
member = await app.get_chat_member(source_chat_id, message.from_user.id)
|
|
|
@@ -445,6 +463,7 @@ async def _refresh_keyboard(
|
|
|
) -> None:
|
|
|
if not message.from_user:
|
|
|
return
|
|
|
+ await remove_reply_keyboard(message)
|
|
|
admin_result = await verify_platform_membership(
|
|
|
user_id=int(message.from_user.id),
|
|
|
require_admin=True,
|
|
|
@@ -1078,6 +1097,8 @@ async def _confirm_admin_action(target: CallbackQuery, token: str) -> None:
|
|
|
async def directory_callback(_, query: CallbackQuery):
|
|
|
parts = str(query.data).split(":")
|
|
|
try:
|
|
|
+ if parts[1] == "browse":
|
|
|
+ return await _open_service_directory(query)
|
|
|
if parts[1] == "apply":
|
|
|
return await _apply_teacher(query)
|
|
|
if parts[1] == "status":
|
|
|
@@ -1176,6 +1197,7 @@ async def cancel_directory_flow(_, message: Message):
|
|
|
admin_flow = _admin_flows.pop(message.from_user.id, None)
|
|
|
if not admin_flow:
|
|
|
return
|
|
|
+ await remove_reply_keyboard(message)
|
|
|
await message.reply_text("已取消当前操作。")
|
|
|
raise StopPropagation
|
|
|
|