mirror of
https://github.com/PaiGramTeam/PaiGram.git
synced 2024-11-16 04:35:49 +00:00
✨ Add tasks button when query daily note
This commit is contained in:
parent
763075cb4c
commit
0e496743a3
@ -2,8 +2,10 @@ from datetime import datetime
|
|||||||
from typing import Optional, TYPE_CHECKING
|
from typing import Optional, TYPE_CHECKING
|
||||||
|
|
||||||
from simnet.errors import DataNotPublic
|
from simnet.errors import DataNotPublic
|
||||||
|
from telegram import InlineKeyboardMarkup, InlineKeyboardButton
|
||||||
from telegram.constants import ChatAction
|
from telegram.constants import ChatAction
|
||||||
from telegram.ext import ConversationHandler, filters
|
from telegram.ext import ConversationHandler, filters
|
||||||
|
from telegram.helpers import create_deep_linked_url
|
||||||
|
|
||||||
from core.plugin import Plugin, handler
|
from core.plugin import Plugin, handler
|
||||||
from core.services.template.models import RenderResult
|
from core.services.template.models import RenderResult
|
||||||
@ -92,9 +94,15 @@ class DailyNotePlugin(Plugin):
|
|||||||
)
|
)
|
||||||
return render_result
|
return render_result
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_task_button(bot_username: str) -> InlineKeyboardMarkup:
|
||||||
|
return InlineKeyboardMarkup(
|
||||||
|
[[InlineKeyboardButton(">> 设置状态提醒 <<", url=create_deep_linked_url(bot_username, "daily_note_tasks"))]]
|
||||||
|
)
|
||||||
|
|
||||||
@handler.command("dailynote", block=False)
|
@handler.command("dailynote", block=False)
|
||||||
@handler.message(filters.Regex("^当前状态(.*)"), block=False)
|
@handler.message(filters.Regex("^当前状态(.*)"), block=False)
|
||||||
async def command_start(self, update: "Update", _: "ContextTypes.DEFAULT_TYPE") -> Optional[int]:
|
async def command_start(self, update: "Update", context: "ContextTypes.DEFAULT_TYPE") -> Optional[int]:
|
||||||
message = update.effective_message
|
message = update.effective_message
|
||||||
user = update.effective_user
|
user = update.effective_user
|
||||||
logger.info("用户 %s[%s] 每日便签命令请求", user.full_name, user.id)
|
logger.info("用户 %s[%s] 每日便签命令请求", user.full_name, user.id)
|
||||||
@ -111,4 +119,9 @@ class DailyNotePlugin(Plugin):
|
|||||||
return ConversationHandler.END
|
return ConversationHandler.END
|
||||||
|
|
||||||
await message.reply_chat_action(ChatAction.UPLOAD_PHOTO)
|
await message.reply_chat_action(ChatAction.UPLOAD_PHOTO)
|
||||||
await render_result.reply_photo(message, filename=f"{client.player_id}.png", allow_sending_without_reply=True)
|
await render_result.reply_photo(
|
||||||
|
message,
|
||||||
|
filename=f"{client.player_id}.png",
|
||||||
|
allow_sending_without_reply=True,
|
||||||
|
reply_markup=self.get_task_button(context.bot.username),
|
||||||
|
)
|
||||||
|
@ -40,6 +40,7 @@ class DailyNoteTasksPlugin(Plugin.Conversation):
|
|||||||
@conversation.entry_point
|
@conversation.entry_point
|
||||||
@handler.command(command="dailynote_tasks", filters=filters.ChatType.PRIVATE, block=False)
|
@handler.command(command="dailynote_tasks", filters=filters.ChatType.PRIVATE, block=False)
|
||||||
@handler.command(command="daily_note_tasks", filters=filters.ChatType.PRIVATE, block=False)
|
@handler.command(command="daily_note_tasks", filters=filters.ChatType.PRIVATE, block=False)
|
||||||
|
@handler.command(command="start", filters=filters.Regex(r"daily_note_tasks$"), block=False)
|
||||||
async def command_start(self, update: Update, _: CallbackContext) -> int:
|
async def command_start(self, update: Update, _: CallbackContext) -> int:
|
||||||
user = update.effective_user
|
user = update.effective_user
|
||||||
message = update.effective_message
|
message = update.effective_message
|
||||||
|
Loading…
Reference in New Issue
Block a user