Update bot/onboarding.py
Browse files- bot/onboarding.py +13 -14
bot/onboarding.py
CHANGED
|
@@ -11,50 +11,49 @@ async def handle_start(chat_id, user_id, username=None):
|
|
| 11 |
if user and dbm.user_has_valid_token(user_id):
|
| 12 |
await send_message(
|
| 13 |
chat_id,
|
| 14 |
-
"
|
|
|
|
| 15 |
"Use /help for commands.",
|
| 16 |
)
|
| 17 |
return
|
| 18 |
await send_message(
|
| 19 |
chat_id,
|
| 20 |
-
"
|
| 21 |
"This bot requires an access token.\n\n"
|
| 22 |
-
"Send
|
| 23 |
"If you don't have one, ask the admin.",
|
| 24 |
)
|
| 25 |
|
| 26 |
|
| 27 |
async def handle_token_command(chat_id, user_id, token: str):
|
| 28 |
if not token:
|
| 29 |
-
await send_message(
|
| 30 |
-
chat_id, "Usage: <code>/token YOUR_TOKEN_HERE</code>"
|
| 31 |
-
)
|
| 32 |
return
|
| 33 |
|
| 34 |
ok = dbm.bind_token(user_id, token)
|
| 35 |
if ok:
|
| 36 |
await send_message(
|
| 37 |
chat_id,
|
| 38 |
-
"
|
| 39 |
)
|
| 40 |
else:
|
| 41 |
await send_message(
|
| 42 |
chat_id,
|
| 43 |
-
"
|
| 44 |
)
|
| 45 |
|
| 46 |
|
| 47 |
async def handle_reset(chat_id, user_id):
|
| 48 |
dbm.clear_history(user_id)
|
| 49 |
-
await send_message(chat_id, "
|
| 50 |
|
| 51 |
|
| 52 |
async def handle_help(chat_id):
|
| 53 |
await send_message(
|
| 54 |
chat_id,
|
| 55 |
-
"
|
| 56 |
"/start — welcome / onboarding\n"
|
| 57 |
-
"/token
|
| 58 |
"/reset — clear this chat's memory\n"
|
| 59 |
"/stats — your usage stats\n"
|
| 60 |
"/help — this message",
|
|
@@ -65,7 +64,7 @@ async def handle_stats(chat_id, user_id):
|
|
| 65 |
user = dbm.get_user(user_id) or {}
|
| 66 |
await send_message(
|
| 67 |
chat_id,
|
| 68 |
-
f"
|
| 69 |
-
f"Total turns:
|
| 70 |
-
f"Last seen:
|
| 71 |
)
|
|
|
|
| 11 |
if user and dbm.user_has_valid_token(user_id):
|
| 12 |
await send_message(
|
| 13 |
chat_id,
|
| 14 |
+
"**Welcome back!**\n\n"
|
| 15 |
+
"Send any message to chat with the model.\n"
|
| 16 |
"Use /help for commands.",
|
| 17 |
)
|
| 18 |
return
|
| 19 |
await send_message(
|
| 20 |
chat_id,
|
| 21 |
+
"**Welcome.**\n\n"
|
| 22 |
"This bot requires an access token.\n\n"
|
| 23 |
+
"Send `/token YOUR_TOKEN_HERE` to activate.\n"
|
| 24 |
"If you don't have one, ask the admin.",
|
| 25 |
)
|
| 26 |
|
| 27 |
|
| 28 |
async def handle_token_command(chat_id, user_id, token: str):
|
| 29 |
if not token:
|
| 30 |
+
await send_message(chat_id, "Usage: `/token YOUR_TOKEN_HERE`")
|
|
|
|
|
|
|
| 31 |
return
|
| 32 |
|
| 33 |
ok = dbm.bind_token(user_id, token)
|
| 34 |
if ok:
|
| 35 |
await send_message(
|
| 36 |
chat_id,
|
| 37 |
+
"**Token accepted.**\n\nYou can now send messages.",
|
| 38 |
)
|
| 39 |
else:
|
| 40 |
await send_message(
|
| 41 |
chat_id,
|
| 42 |
+
"**Invalid, revoked, or already-used token.**",
|
| 43 |
)
|
| 44 |
|
| 45 |
|
| 46 |
async def handle_reset(chat_id, user_id):
|
| 47 |
dbm.clear_history(user_id)
|
| 48 |
+
await send_message(chat_id, "Conversation memory cleared.")
|
| 49 |
|
| 50 |
|
| 51 |
async def handle_help(chat_id):
|
| 52 |
await send_message(
|
| 53 |
chat_id,
|
| 54 |
+
"**Commands**\n\n"
|
| 55 |
"/start — welcome / onboarding\n"
|
| 56 |
+
"/token VALUE — activate or replace token\n"
|
| 57 |
"/reset — clear this chat's memory\n"
|
| 58 |
"/stats — your usage stats\n"
|
| 59 |
"/help — this message",
|
|
|
|
| 64 |
user = dbm.get_user(user_id) or {}
|
| 65 |
await send_message(
|
| 66 |
chat_id,
|
| 67 |
+
f"**Your stats**\n\n"
|
| 68 |
+
f"Total turns: {user.get('total_turns', 0)}\n"
|
| 69 |
+
f"Last seen: {user.get('last_seen', 'n/a')}",
|
| 70 |
)
|