PamGram/plugins/app/start.py
2023-12-24 21:48:07 +08:00

32 lines
1.5 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from telegram import Update, ReplyKeyboardRemove
from telegram.ext import CallbackContext, CommandHandler
from telegram.helpers import escape_markdown
from core.plugin import handler, Plugin
from utils.log import logger
class StartPlugin(Plugin):
@handler.command("start", block=False)
async def start(self, update: Update, context: CallbackContext) -> None:
user = update.effective_user
message = update.effective_message
args = context.args
args_text = " ".join(args) if args else ""
logger.info("用户 %s[%s] 发出start命令 args[%s]", user.full_name, user.id, args_text)
if args is not None and len(args) >= 1:
return
await message.reply_markdown_v2(f"你好 {user.mention_markdown_v2()} {escape_markdown('!我是彦卿 ')}")
@staticmethod
async def unknown_command(update: Update, _: CallbackContext) -> None:
await update.effective_message.reply_text("前面的区域,以后再来探索吧!")
@handler(CommandHandler, command="ping", block=False)
async def ping(self, update: Update, _: CallbackContext) -> None:
await update.effective_message.reply_text("online! ヾ(✿゚▽゚)")
@handler(CommandHandler, command="reply_keyboard_remove", block=False)
async def reply_keyboard_remove(self, update: Update, _: CallbackContext) -> None:
await update.message.reply_text("移除远程键盘成功", reply_markup=ReplyKeyboardRemove())