Skip to content

Commit fb4b70b

Browse files
committed
add "model" command to get the current model
1 parent ab53c0d commit fb4b70b

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

‎telegram-bot/bot.py‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,20 @@ async def start_command(update: Update, _: ContextTypes.DEFAULT_TYPE) -> None:
3939
await update.message.reply_text(_START_MESSAGE)
4040

4141

42+
async def get_model_command(
43+
update: Update,
44+
_: ContextTypes.DEFAULT_TYPE,
45+
db_client: DBClient,
46+
) -> None:
47+
"""Get the current model being used by the user."""
48+
user_id = update.message.from_user.id
49+
username = update.message.from_user.username
50+
account = db_client.get_or_create_account(user_id=user_id, username=username)
51+
await update.message.reply_text(
52+
f"You are currently using {account.model.value} provided by {account.provider.value}."
53+
)
54+
55+
4256
async def rewrite(
4357
update: Update,
4458
context: ContextTypes.DEFAULT_TYPE,
@@ -80,6 +94,9 @@ async def rewrite(
8094
app = ApplicationBuilder().token(os.getenv(_TELEGRAM_BOT_TOKEN_VAR_NAME)).build()
8195

8296
app.add_handler(CommandHandler("start", start_command))
97+
app.add_handler(
98+
CommandHandler("model", partial(get_model_command, db_client=db_client))
99+
)
83100
app.add_handler(
84101
MessageHandler(
85102
filters.TEXT & (~filters.COMMAND),

0 commit comments

Comments
 (0)