Skip to content

Commit

Permalink
add "model" command to get the current model
Browse files Browse the repository at this point in the history
  • Loading branch information
CuriousDima committed May 29, 2024
1 parent ab53c0d commit fb4b70b
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions telegram-bot/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,20 @@ async def start_command(update: Update, _: ContextTypes.DEFAULT_TYPE) -> None:
await update.message.reply_text(_START_MESSAGE)


async def get_model_command(
update: Update,
_: ContextTypes.DEFAULT_TYPE,
db_client: DBClient,
) -> None:
"""Get the current model being used by the user."""
user_id = update.message.from_user.id
username = update.message.from_user.username
account = db_client.get_or_create_account(user_id=user_id, username=username)
await update.message.reply_text(
f"You are currently using {account.model.value} provided by {account.provider.value}."
)


async def rewrite(
update: Update,
context: ContextTypes.DEFAULT_TYPE,
Expand Down Expand Up @@ -80,6 +94,9 @@ async def rewrite(
app = ApplicationBuilder().token(os.getenv(_TELEGRAM_BOT_TOKEN_VAR_NAME)).build()

app.add_handler(CommandHandler("start", start_command))
app.add_handler(
CommandHandler("model", partial(get_model_command, db_client=db_client))
)
app.add_handler(
MessageHandler(
filters.TEXT & (~filters.COMMAND),
Expand Down

0 comments on commit fb4b70b

Please sign in to comment.