2023-12-24 13:26:36 +00:00
|
|
|
|
from telegram import Update, ReplyKeyboardRemove
|
2024-08-02 10:39:07 +00:00
|
|
|
|
from telegram.constants import ParseMode
|
2022-09-08 01:08:37 +00:00
|
|
|
|
from telegram.ext import CallbackContext, CommandHandler
|
2022-07-26 10:07:31 +00:00
|
|
|
|
from telegram.helpers import escape_markdown
|
|
|
|
|
|
2024-06-07 14:58:13 +00:00
|
|
|
|
from core.config import config
|
2022-09-08 01:08:37 +00:00
|
|
|
|
from core.plugin import handler, Plugin
|
2022-10-30 13:35:53 +00:00
|
|
|
|
from utils.log import logger
|
2022-07-26 10:07:31 +00:00
|
|
|
|
|
|
|
|
|
|
2022-09-08 01:08:37 +00:00
|
|
|
|
class StartPlugin(Plugin):
|
2022-11-12 17:56:38 +00:00
|
|
|
|
@handler.command("start", block=False)
|
2022-09-08 01:08:37 +00:00
|
|
|
|
async def start(self, update: Update, context: CallbackContext) -> None:
|
|
|
|
|
user = update.effective_user
|
|
|
|
|
message = update.effective_message
|
|
|
|
|
args = context.args
|
2023-12-24 13:26:36 +00:00
|
|
|
|
args_text = " ".join(args) if args else ""
|
|
|
|
|
logger.info("用户 %s[%s] 发出start命令 args[%s]", user.full_name, user.id, args_text)
|
2022-10-12 09:35:59 +00:00
|
|
|
|
if args is not None and len(args) >= 1:
|
2022-10-22 13:54:04 +00:00
|
|
|
|
return
|
2024-06-07 14:58:13 +00:00
|
|
|
|
await message.reply_markdown_v2(
|
|
|
|
|
f"你好 {user.mention_markdown_v2()} {escape_markdown(f'!我是{config.notice.bot_name}!')}"
|
|
|
|
|
)
|
2022-09-08 01:08:37 +00:00
|
|
|
|
|
|
|
|
|
@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())
|
2024-08-02 10:39:07 +00:00
|
|
|
|
|
|
|
|
|
@handler.command(command="privacy", block=False)
|
|
|
|
|
async def reply_privacy_policy(self, update: "Update", _: "CallbackContext"):
|
|
|
|
|
message = update.effective_message
|
|
|
|
|
await message.reply_text(
|
|
|
|
|
"请查看[PaiGramTeam Bot 用户个人信息及隐私保护政策](https://telegra.ph/paigramteam-bot-privacy-08-02)",
|
|
|
|
|
parse_mode=ParseMode.MARKDOWN_V2,
|
|
|
|
|
)
|