Files
ai-tg/handlers/help.py
T

88 lines
3.9 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
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 &lt;query&gt;</code> — Direct web search
<code>/ocr</code> — Reply to an image and extract readable text
<code>/imagine &lt;description&gt;</code> — Generate an image with Imagen 4 Fast
━━━━━━━━━━━━━━━━━━━━
<b>⚙️ Your Settings</b>
<code>/status</code> — View your settings
<code>/setmaxtoken &lt;n&gt;</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 &lt;auto|fa|en&gt;</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 &lt;google|openrouter&gt;</code> — Switch AI provider
<code>/setmodel [google|openrouter] &lt;model&gt;</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 &lt;id&gt;</code> — Authorize a user
<code>/removeauth &lt;id&gt;</code> — Remove authorization
<code>/listauth</code> — List authorized users
<code>/ban &lt;id&gt;</code> — Ban a user
<code>/unban &lt;id&gt;</code> — Unban a user
<code>/listban</code> — List banned users
<code>/userinfo &lt;id&gt;</code> — Show user info
<code>/broadcast &lt;text&gt;</code> — Message all known users
<code>/clearall</code> — Clear all histories
<code>/setpersonality &lt;text&gt;</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)