mirror of
https://github.com/PaiGramTeam/PamGram.git
synced 2024-11-16 03:55:26 +00:00
✨ Add tasks button when query daily note
This commit is contained in:
parent
fd08a6dcf4
commit
9d119c6073
@ -3,9 +3,10 @@ from datetime import datetime
|
||||
from typing import Optional, TYPE_CHECKING
|
||||
|
||||
from simnet.errors import DataNotPublic
|
||||
from telegram import Update
|
||||
from telegram import Update, InlineKeyboardMarkup, InlineKeyboardButton
|
||||
from telegram.constants import ChatAction
|
||||
from telegram.ext import ConversationHandler, filters, CallbackContext
|
||||
from telegram.helpers import create_deep_linked_url
|
||||
|
||||
from core.plugin import Plugin, handler
|
||||
from core.services.template.models import RenderResult
|
||||
@ -80,9 +81,15 @@ class DailyNotePlugin(Plugin):
|
||||
)
|
||||
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.message(filters.Regex("^当前状态(.*)"), block=False)
|
||||
async def command_start(self, update: Update, _: CallbackContext) -> Optional[int]:
|
||||
async def command_start(self, update: Update, context: CallbackContext) -> Optional[int]:
|
||||
message = update.effective_message
|
||||
user = update.effective_user
|
||||
logger.info("用户 %s[%s] 每日便签命令请求", user.full_name, user.id)
|
||||
@ -98,4 +105,9 @@ class DailyNotePlugin(Plugin):
|
||||
return ConversationHandler.END
|
||||
|
||||
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),
|
||||
)
|
||||
|
@ -44,6 +44,7 @@ class DailyNoteTasksPlugin(Plugin.Conversation):
|
||||
|
||||
@conversation.entry_point
|
||||
@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:
|
||||
user = update.effective_user
|
||||
message = update.effective_message
|
||||
|
Loading…
Reference in New Issue
Block a user