mirror of
https://github.com/PaiGramTeam/PaiGram.git
synced 2024-11-16 04:35:49 +00:00
🎨 Update the text of a reply when bot query user does not exist
This commit is contained in:
parent
57edccd925
commit
59be6fc7a4
@ -1,4 +1,4 @@
|
||||
from telegram import Update
|
||||
from telegram import Update, InlineKeyboardMarkup, InlineKeyboardButton
|
||||
from telegram.constants import ChatAction
|
||||
from telegram.ext import CallbackContext, CommandHandler, MessageHandler, filters
|
||||
|
||||
@ -40,10 +40,16 @@ class AbyssTeam(Plugin, BasePlugin):
|
||||
try:
|
||||
client = await get_genshin_client(user.id)
|
||||
except (CookiesNotFoundError, UserNotFoundError):
|
||||
reply_message = await message.reply_text("未查询到账号信息,请先私聊派蒙绑定账号")
|
||||
if filters.ChatType.GROUPS.filter(message):
|
||||
self._add_delete_message_job(context, reply_message.chat_id, reply_message.message_id, 10)
|
||||
self._add_delete_message_job(context, message.chat_id, message.message_id, 10)
|
||||
buttons = [[InlineKeyboardButton("点我私聊", url=f"https://t.me/{context.bot.username}?start=set_cookie")]]
|
||||
reply_message = await message.reply_text(
|
||||
"未查询到您所绑定的账号信息,请先私聊派蒙绑定账号", reply_markup=InlineKeyboardMarkup(buttons)
|
||||
)
|
||||
self._add_delete_message_job(context, reply_message.chat_id, reply_message.message_id, 30)
|
||||
|
||||
self._add_delete_message_job(context, message.chat_id, message.message_id, 30)
|
||||
else:
|
||||
await message.reply_text("未查询到您所绑定的账号信息,请先绑定账号")
|
||||
return
|
||||
|
||||
await message.reply_chat_action(ChatAction.TYPING)
|
||||
|
@ -44,7 +44,7 @@ class SetUserCookies(Plugin.Conversation, BasePlugin.Conversation):
|
||||
self.user_service = user_service
|
||||
|
||||
@conversation.entry_point
|
||||
@handler.command(command="setcookies", filters=filters.ChatType.PRIVATE, block=True)
|
||||
@handler.command(command="setcookie", filters=filters.ChatType.PRIVATE, block=True)
|
||||
@restricts()
|
||||
@error_callable
|
||||
async def command_start(self, update: Update, context: CallbackContext) -> int:
|
||||
|
@ -3,7 +3,7 @@ import os
|
||||
from typing import Optional
|
||||
|
||||
from genshin import DataNotPublic
|
||||
from telegram import Update
|
||||
from telegram import Update, InlineKeyboardButton, InlineKeyboardMarkup
|
||||
from telegram.constants import ChatAction
|
||||
from telegram.ext import CommandHandler, MessageHandler, ConversationHandler, filters, CallbackContext
|
||||
|
||||
@ -102,10 +102,16 @@ class DailyNote(Plugin, BasePlugin):
|
||||
client = await get_genshin_client(user.id)
|
||||
png_data = await self._get_daily_note(client)
|
||||
except (UserNotFoundError, CookiesNotFoundError):
|
||||
reply_message = await message.reply_text("未查询到账号信息,请先私聊派蒙绑定账号")
|
||||
if filters.ChatType.GROUPS.filter(message):
|
||||
buttons = [[InlineKeyboardButton("点我私聊", url=f"https://t.me/{context.bot.username}?start=set_cookie")]]
|
||||
reply_message = await message.reply_text(
|
||||
"未查询到您所绑定的账号信息,请先私聊派蒙绑定账号", reply_markup=InlineKeyboardMarkup(buttons)
|
||||
)
|
||||
self._add_delete_message_job(context, reply_message.chat_id, reply_message.message_id, 30)
|
||||
|
||||
self._add_delete_message_job(context, message.chat_id, message.message_id, 30)
|
||||
else:
|
||||
await message.reply_text("未查询到您所绑定的账号信息,请先绑定账号")
|
||||
return
|
||||
except DataNotPublic:
|
||||
reply_message = await message.reply_text("查询失败惹,可能是便签功能被禁用了?")
|
||||
|
@ -3,7 +3,7 @@ from io import BytesIO
|
||||
|
||||
import genshin
|
||||
from genshin.models import BannerType
|
||||
from telegram import Update, User, Message, Document
|
||||
from telegram import Update, User, Message, Document, InlineKeyboardButton, InlineKeyboardMarkup
|
||||
from telegram.constants import ChatAction
|
||||
from telegram.ext import CallbackContext, CommandHandler, MessageHandler, filters, ConversationHandler
|
||||
|
||||
@ -243,7 +243,7 @@ class GachaLog(Plugin.Conversation, BasePlugin.Conversation):
|
||||
@handler(MessageHandler, filters=filters.Regex("^导出抽卡记录(.*)") & filters.ChatType.PRIVATE, block=False)
|
||||
@restricts()
|
||||
@error_callable
|
||||
async def command_start_export(self, update: Update, _: CallbackContext) -> None:
|
||||
async def command_start_export(self, update: Update, context: CallbackContext) -> None:
|
||||
message = update.effective_message
|
||||
user = update.effective_user
|
||||
logger.info(f"用户 {user.full_name}[{user.id}] 导出抽卡记录命令请求")
|
||||
@ -258,7 +258,11 @@ class GachaLog(Plugin.Conversation, BasePlugin.Conversation):
|
||||
await message.reply_text(text)
|
||||
except UserNotFoundError:
|
||||
logger.info(f"未查询到用户({user.full_name} {user.id}) 所绑定的账号信息")
|
||||
await message.reply_text("未查询到您所绑定的账号信息,请先私聊派蒙绑定账号")
|
||||
if filters.ChatType.GROUPS.filter(message):
|
||||
buttons = [[InlineKeyboardButton("点我私聊", url=f"https://t.me/{context.bot.username}?start=set_uid")]]
|
||||
await message.reply_text("未查询到您所绑定的账号信息,请先私聊派蒙绑定账号", reply_markup=InlineKeyboardMarkup(buttons))
|
||||
else:
|
||||
await message.reply_text("未查询到您所绑定的账号信息,请先绑定账号")
|
||||
|
||||
@handler(CommandHandler, command="gacha_log", block=False)
|
||||
@handler(MessageHandler, filters=filters.Regex("^抽卡记录(.*)"), block=False)
|
||||
@ -291,7 +295,16 @@ class GachaLog(Plugin.Conversation, BasePlugin.Conversation):
|
||||
await message.reply_photo(png_data)
|
||||
except UserNotFoundError:
|
||||
logger.info(f"未查询到用户({user.full_name} {user.id}) 所绑定的账号信息")
|
||||
await message.reply_text("未查询到您所绑定的账号信息,请先私聊派蒙绑定账号")
|
||||
if filters.ChatType.GROUPS.filter(message):
|
||||
buttons = [[InlineKeyboardButton("点我私聊", url=f"https://t.me/{context.bot.username}?start=set_cookie")]]
|
||||
reply_message = await message.reply_text(
|
||||
"未查询到您所绑定的账号信息,请先私聊派蒙绑定账号", reply_markup=InlineKeyboardMarkup(buttons)
|
||||
)
|
||||
self._add_delete_message_job(context, reply_message.chat_id, reply_message.message_id, 30)
|
||||
|
||||
self._add_delete_message_job(context, message.chat_id, message.message_id, 30)
|
||||
else:
|
||||
await message.reply_text("未查询到您所绑定的账号信息,请先绑定账号")
|
||||
|
||||
@handler(CommandHandler, command="gacha_count", block=True)
|
||||
@handler(MessageHandler, filters=filters.Regex("^抽卡统计(.*)"), block=True)
|
||||
@ -333,4 +346,13 @@ class GachaLog(Plugin.Conversation, BasePlugin.Conversation):
|
||||
await message.reply_photo(png_data)
|
||||
except (UserNotFoundError, CookiesNotFoundError):
|
||||
logger.info(f"未查询到用户({user.full_name} {user.id}) 所绑定的账号信息")
|
||||
await message.reply_text("未查询到您所绑定的账号信息,请先私聊派蒙绑定账号")
|
||||
if filters.ChatType.GROUPS.filter(message):
|
||||
buttons = [[InlineKeyboardButton("点我私聊", url=f"https://t.me/{context.bot.username}?start=set_cookie")]]
|
||||
reply_message = await message.reply_text(
|
||||
"未查询到您所绑定的账号信息,请先私聊派蒙绑定账号", reply_markup=InlineKeyboardMarkup(buttons)
|
||||
)
|
||||
self._add_delete_message_job(context, reply_message.chat_id, reply_message.message_id, 30)
|
||||
|
||||
self._add_delete_message_job(context, message.chat_id, message.message_id, 30)
|
||||
else:
|
||||
await message.reply_text("未查询到您所绑定的账号信息,请先绑定账号")
|
||||
|
@ -4,7 +4,7 @@ import re
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
from genshin import GenshinException, DataNotPublic
|
||||
from telegram import Update
|
||||
from telegram import Update, InlineKeyboardMarkup, InlineKeyboardButton
|
||||
from telegram.constants import ChatAction
|
||||
from telegram.ext import CallbackContext, CommandHandler, MessageHandler, filters
|
||||
|
||||
@ -172,10 +172,16 @@ class Ledger(Plugin, BasePlugin):
|
||||
client = await get_genshin_client(user.id)
|
||||
png_data = await self._start_get_ledger(client, month)
|
||||
except (UserNotFoundError, CookiesNotFoundError):
|
||||
reply_message = await message.reply_text("未查询到账号信息,请先私聊派蒙绑定账号")
|
||||
if filters.ChatType.GROUPS.filter(message):
|
||||
buttons = [[InlineKeyboardButton("点我私聊", url=f"https://t.me/{context.bot.username}?start=set_cookie")]]
|
||||
reply_message = await message.reply_text(
|
||||
"未查询到您所绑定的账号信息,请先私聊派蒙绑定账号", reply_markup=InlineKeyboardMarkup(buttons)
|
||||
)
|
||||
self._add_delete_message_job(context, reply_message.chat_id, reply_message.message_id, 30)
|
||||
|
||||
self._add_delete_message_job(context, message.chat_id, message.message_id, 30)
|
||||
else:
|
||||
await message.reply_text("未查询到您所绑定的账号信息,请先绑定账号")
|
||||
return
|
||||
except DataNotPublic:
|
||||
reply_message = await message.reply_text("查询失败惹,可能是旅行札记功能被禁用了?")
|
||||
|
@ -1,7 +1,7 @@
|
||||
from os import sep
|
||||
|
||||
from PIL import Image
|
||||
from telegram import Update
|
||||
from telegram import Update, InlineKeyboardButton, InlineKeyboardMarkup
|
||||
from telegram.constants import ChatAction
|
||||
from telegram.ext import CommandHandler, MessageHandler, filters, CallbackContext
|
||||
|
||||
@ -45,7 +45,8 @@ class Map(Plugin, BasePlugin):
|
||||
return
|
||||
if resource_name in ("list", "列表"):
|
||||
if filters.ChatType.GROUPS.filter(message):
|
||||
reply_message = await message.reply_text("请私聊派蒙使用该命令")
|
||||
buttons = [[InlineKeyboardButton("点我私聊", url=f"https://t.me/{context.bot.username}")]]
|
||||
reply_message = await message.reply_text("请私聊派蒙使用该命令", reply_markup=InlineKeyboardMarkup(buttons))
|
||||
self._add_delete_message_job(context, reply_message.chat_id, reply_message.message_id, 300)
|
||||
self._add_delete_message_job(context, message.chat_id, message.message_id, 300)
|
||||
return
|
||||
|
@ -78,10 +78,16 @@ class PlayerCards(Plugin, BasePlugin):
|
||||
else:
|
||||
uid = user_info.genshin_uid
|
||||
except UserNotFoundError:
|
||||
reply_message = await message.reply_text("未查询到账号信息,请先私聊派蒙绑定账号")
|
||||
if filters.ChatType.GROUPS.filter(message):
|
||||
buttons = [[InlineKeyboardButton("点我私聊", url=f"https://t.me/{context.bot.username}?start=set_uid")]]
|
||||
reply_message = await message.reply_text(
|
||||
"未查询到您所绑定的账号信息,请先私聊派蒙绑定账号", reply_markup=InlineKeyboardMarkup(buttons)
|
||||
)
|
||||
self._add_delete_message_job(context, reply_message.chat_id, reply_message.message_id, 30)
|
||||
|
||||
self._add_delete_message_job(context, message.chat_id, message.message_id, 30)
|
||||
else:
|
||||
await message.reply_text("未查询到您所绑定的账号信息,请先绑定账号")
|
||||
return
|
||||
data = await self._fetch_user(uid)
|
||||
if isinstance(data, str):
|
||||
|
@ -7,7 +7,7 @@ from typing import Optional, Dict
|
||||
|
||||
from genshin import Game, GenshinException, AlreadyClaimed, Client
|
||||
from httpx import AsyncClient, TimeoutException
|
||||
from telegram import Update
|
||||
from telegram import Update, InlineKeyboardButton, InlineKeyboardMarkup
|
||||
from telegram.constants import ChatAction
|
||||
from telegram.ext import CommandHandler, CallbackContext
|
||||
from telegram.ext import MessageHandler, filters
|
||||
@ -283,8 +283,14 @@ class Sign(Plugin, BasePlugin):
|
||||
if filters.ChatType.GROUPS.filter(reply_message):
|
||||
self._add_delete_message_job(context, reply_message.chat_id, reply_message.message_id)
|
||||
except (UserNotFoundError, CookiesNotFoundError):
|
||||
reply_message = await message.reply_text("未查询到账号信息,请先私聊派蒙绑定账号")
|
||||
if filters.ChatType.GROUPS.filter(message):
|
||||
buttons = [[InlineKeyboardButton("点我私聊", url=f"https://t.me/{context.bot.username}?start=set_cookie")]]
|
||||
reply_message = await message.reply_text(
|
||||
"未查询到您所绑定的账号信息,请先私聊派蒙绑定账号", reply_markup=InlineKeyboardMarkup(buttons)
|
||||
)
|
||||
self._add_delete_message_job(context, reply_message.chat_id, reply_message.message_id, 30)
|
||||
|
||||
self._add_delete_message_job(context, message.chat_id, message.message_id, 30)
|
||||
else:
|
||||
await message.reply_text("未查询到您所绑定的账号信息,请先绑定账号")
|
||||
return
|
||||
|
@ -3,7 +3,7 @@ from typing import Optional
|
||||
|
||||
from genshin import Client
|
||||
from genshin.models import GenshinUserStats
|
||||
from telegram import Update
|
||||
from telegram import Update, InlineKeyboardButton, InlineKeyboardMarkup
|
||||
from telegram.constants import ChatAction
|
||||
from telegram.ext import (
|
||||
CallbackContext,
|
||||
@ -53,11 +53,16 @@ class UserStatsPlugins(Plugin, BasePlugin):
|
||||
client, uid = await get_public_genshin_client(user.id)
|
||||
png_data = await self.render(client, uid)
|
||||
except UserNotFoundError:
|
||||
reply_message = await message.reply_text("未查询到账号信息,请先私聊派蒙绑定账号")
|
||||
if filters.ChatType.GROUPS.filter(message):
|
||||
buttons = [[InlineKeyboardButton("点我私聊", url=f"https://t.me/{context.bot.username}?start=set_uid")]]
|
||||
reply_message = await message.reply_text(
|
||||
"未查询到您所绑定的账号信息,请先私聊派蒙绑定账号", reply_markup=InlineKeyboardMarkup(buttons)
|
||||
)
|
||||
self._add_delete_message_job(context, reply_message.chat_id, reply_message.message_id, 30)
|
||||
|
||||
self._add_delete_message_job(context, message.chat_id, message.message_id, 30)
|
||||
else:
|
||||
await message.reply_text("未查询到您所绑定的账号信息,请先绑定账号")
|
||||
return
|
||||
except TooManyRequestPublicCookies:
|
||||
await message.reply_text("用户查询次数过多 请稍后重试")
|
||||
|
@ -13,12 +13,25 @@ class StartPlugin(Plugin):
|
||||
user = update.effective_user
|
||||
message = update.effective_message
|
||||
args = context.args
|
||||
if args is not None and len(args) >= 1 and args[0] == "inline_message":
|
||||
await message.reply_markdown_v2(
|
||||
f"你好 {user.mention_markdown_v2()} {escape_markdown('!我是派蒙 !')}\n"
|
||||
f"{escape_markdown('发送 /help 命令即可查看命令帮助')}"
|
||||
)
|
||||
return
|
||||
if args is not None and len(args) >= 1:
|
||||
if args[0] == "inline_message":
|
||||
await message.reply_markdown_v2(
|
||||
f"你好 {user.mention_markdown_v2()} {escape_markdown('!我是派蒙 !')}\n"
|
||||
f"{escape_markdown('发送 /help 命令即可查看命令帮助')}"
|
||||
)
|
||||
return
|
||||
elif args[0] == "set_cookie":
|
||||
await message.reply_markdown_v2(
|
||||
f"你好 {user.mention_markdown_v2()} {escape_markdown('!我是派蒙 !')}\n"
|
||||
f"{escape_markdown('发送 /setcookie 命令进入绑定账号流程')}"
|
||||
)
|
||||
return
|
||||
elif args[0] == "set_uid":
|
||||
await message.reply_markdown_v2(
|
||||
f"你好 {user.mention_markdown_v2()} {escape_markdown('!我是派蒙 !')}\n"
|
||||
f"{escape_markdown('发送 /setuid 或 /setcookie 命令进入绑定账号流程')}"
|
||||
)
|
||||
return
|
||||
await message.reply_markdown_v2(f"你好 {user.mention_markdown_v2()} {escape_markdown('!我是派蒙 !')}")
|
||||
|
||||
@staticmethod
|
||||
|
@ -162,8 +162,8 @@
|
||||
<div class="command-description">添加UID(请私聊BOT)</div>
|
||||
</div>
|
||||
<div class="command">
|
||||
<div class="command-name">/setcookies</div>
|
||||
<div class="command-description">添加Cookies(请私聊BOT)</div>
|
||||
<div class="command-name">/setcookie</div>
|
||||
<div class="command-description">添加Cookie(请私聊BOT)</div>
|
||||
</div>
|
||||
<!--! 取消操作 -->
|
||||
<div class="command rounded-xl flex-1">
|
||||
|
Loading…
Reference in New Issue
Block a user