Skip to content
This repository has been archived by the owner on Apr 24, 2024. It is now read-only.

Commit

Permalink
feat: Bringing images to Bard
Browse files Browse the repository at this point in the history
  • Loading branch information
ciuzaak committed May 25, 2023
1 parent e0f37a7 commit a978563
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions bot.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
from re import sub
from urllib.parse import quote

from telegram import BotCommand, InlineKeyboardButton, InlineKeyboardMarkup, Update
from telegram import (
BotCommand,
InlineKeyboardButton,
InlineKeyboardMarkup,
InputMediaPhoto,
Update,
)
from telegram.constants import ParseMode
from telegram.ext import (
Application,
Expand Down Expand Up @@ -203,6 +209,11 @@ async def recv_msg(update: Update, context: ContextTypes.DEFAULT_TYPE):
}
# get response
await bard_response(update, context)
# get images
images = response["images"]
if len(images) != 0:
media = [InputMediaPhoto(image[: image.rfind("=")]) for image in images]
await update.message.reply_media_group(media)


async def show_settings(update: Update, context: ContextTypes.DEFAULT_TYPE):
Expand Down Expand Up @@ -240,9 +251,7 @@ async def change_mode(update: Update, context: ContextTypes.DEFAULT_TYPE):
return await update.message.reply_text(f"❌ You cannot access the other mode.")
mode, _ = get_session(update, context)

final_mode, emoji = (
("Bard", "🟠") if mode == "Claude" else ("Claude", "🟣")
)
final_mode, emoji = ("Bard", "🟠") if mode == "Claude" else ("Claude", "🟣")
context.chat_data["mode"] = final_mode
if final_mode not in context.chat_data:
context.chat_data[final_mode] = {"session": Session(final_mode)}
Expand Down

0 comments on commit a978563

Please sign in to comment.