88 lines
3.9 KiB
Python
88 lines
3.9 KiB
Python
from telegram import Update
|
||
from telegram.constants import ParseMode
|
||
from telegram.ext import ContextTypes
|
||
from services import auth, ai_client
|
||
from config import BOT_VERSION
|
||
|
||
|
||
HELP_TEXT = """
|
||
<b>🐾 Puppy Bot v{version} — Help</b>
|
||
|
||
Puppy is an AI assistant powered by Google Gemini (or OpenRouter models).
|
||
<b>Groups:</b> mention me by name (<code>Puppy</code> / <code>پاپی</code>), reply to my messages, or @mention me.
|
||
<b>Private:</b> just write directly.
|
||
|
||
━━━━━━━━━━━━━━━━━━━━
|
||
<b>💬 Chat</b>
|
||
Send a message to chat.
|
||
Send a <b>photo</b> or image album → I'll analyze it. Caption with OCR/read/text, describe, objects, or a question for focused image understanding.
|
||
Reply to <b>someone else's message</b> and call my name → I'll respond in context.
|
||
|
||
━━━━━━━━━━━━━━━━━━━━
|
||
<b>🔍 Search & Images</b>
|
||
I auto-search the web for real-time info (news, weather, date, prices…).
|
||
Ask for images → I'll search and send up to 5 results.
|
||
<code>/search <query></code> — Direct web search
|
||
<code>/ocr</code> — Reply to an image and extract readable text
|
||
<code>/imagine <description></code> — Generate an image with Imagen 4 Fast
|
||
|
||
━━━━━━━━━━━━━━━━━━━━
|
||
<b>⚙️ Your Settings</b>
|
||
<code>/status</code> — View your settings
|
||
<code>/setmaxtoken <n></code> — Set max reply tokens (50–4000, default 300)
|
||
<code>/getmaxtoken</code> — Show current max tokens
|
||
<code>/resettoken</code> — Reset to default (300)
|
||
<code>/setlang <auto|fa|en></code> — Override response language
|
||
<code>/togglesearch</code> — Enable / disable auto web search
|
||
<code>/model</code> — Show active AI provider and model
|
||
<code>/clear</code> — Clear your conversation history
|
||
<code>/myhistory</code> — View your recent conversation
|
||
|
||
━━━━━━━━━━━━━━━━━━━━
|
||
<b>🔁 Inline Mode</b>
|
||
Type <code>@{username} your question</code> in any chat.
|
||
|
||
━━━━━━━━━━━━━━━━━━━━
|
||
<b>🛠️ Admin Commands</b> <i>(owner only)</i>
|
||
<code>/unlock</code> — Open bot to everyone (public mode)
|
||
<code>/lock</code> — Restrict back to authorized users only
|
||
<code>/setprovider <google|openrouter></code> — Switch AI provider
|
||
<code>/setmodel [google|openrouter] <model></code> — Change model with validation
|
||
<code>/models [google|openrouter] [free] [keyword]</code> — Browse available models
|
||
<code>/stats</code> / <code>/dashboard</code> — Admin dashboard
|
||
<code>/addauth <id></code> — Authorize a user
|
||
<code>/removeauth <id></code> — Remove authorization
|
||
<code>/listauth</code> — List authorized users
|
||
<code>/ban <id></code> — Ban a user
|
||
<code>/unban <id></code> — Unban a user
|
||
<code>/listban</code> — List banned users
|
||
<code>/userinfo <id></code> — Show user info
|
||
<code>/broadcast <text></code> — Message all known users
|
||
<code>/clearall</code> — Clear all histories
|
||
<code>/setpersonality <text></code> — Set custom system prompt
|
||
<code>/resetpersonality</code> — Restore default personality
|
||
<code>/reload</code> — Reload authorized_users.json from disk
|
||
<code>/uptime</code> — Show bot uptime
|
||
<code>/version</code> — Show bot version
|
||
<code>/ping</code> — Health check
|
||
<code>/myid</code> — Show your Telegram user ID
|
||
|
||
━━━━━━━━━━━━━━━━━━━━
|
||
<i>Provider: {provider} | Model: {model}</i>
|
||
""".strip()
|
||
|
||
|
||
async def cmd_help(update: Update, context: ContextTypes.DEFAULT_TYPE):
|
||
user = update.effective_user
|
||
if not auth.is_authorized(user.id, user.username or ""):
|
||
return
|
||
|
||
bot_username = context.bot.username or "PuppyBot"
|
||
text = HELP_TEXT.format(
|
||
version=BOT_VERSION,
|
||
username=bot_username,
|
||
provider=ai_client.get_provider(),
|
||
model=ai_client.get_model(),
|
||
)
|
||
await update.message.reply_text(text, parse_mode=ParseMode.HTML)
|