Skip to content

Commit

Permalink
Removed ai-imagine due to limitations (again)
Browse files Browse the repository at this point in the history
  • Loading branch information
bishalqx980 committed Feb 11, 2025
1 parent 426f489 commit f1c94ea
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 44 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ This Telegram bot is built using the `python-telegram-bot` library **_version 21
- It has just everything...
- **AI 🤖**
- <s>ChatGPT</s> `Removed due to limitations`
- AI photo imagine
- <s>AI photo imagine</s> `Removed due to limitations`
- **Misc 🎁**
- Get any movie info
- Translate any language
Expand Down
44 changes: 2 additions & 42 deletions bot/functions/imagine.py
Original file line number Diff line number Diff line change
@@ -1,47 +1,7 @@
import os
import requests
from telegram import Update
from telegram.ext import ContextTypes
from bot import logger
from bot.helper.telegram_helper import Message
from bot.modules.database.local_database import LOCAL_DATABASE


async def func_imagine(update: Update, context: ContextTypes.DEFAULT_TYPE):
chat = update.effective_chat
e_msg = update.effective_message
prompt = " ".join(context.args)

if not prompt:
await Message.reply_message(update, "Use <code>!imagine prompt</code>")
return

sent_msg = await Message.reply_message(update, "Generating...")

# temporarily added imagine api
imagine_api = await LOCAL_DATABASE.get_data("bot_docs", "imagine_api")
if not imagine_api:
await Message.edit_message(update, "Imagine API not found.", sent_msg)
return

try:
req = requests.get(f"{imagine_api}{prompt}", timeout=3)
except Exception as e:
logger.error(e)

if req.status_code != 200:
await Message.edit_message(update, f"{req.status_code}: {req.text}", sent_msg)
return

file_name = "downloads/imagine.png"
with open(file_name, "wb") as f:
f.write(req.content)

await Message.send_image(chat.id, file_name, prompt, e_msg.id)
await Message.delete_message(chat.id, sent_msg)

# Removing the image
try:
os.remove(file_name)
except Exception as e:
logger.error(e)
await Message.reply_message(update, "This function has been disabled due to limitations! This maybe reintroduced in future updates.")
return
2 changes: 1 addition & 1 deletion bot/helper/query_handlers/func_help_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ async def _query_help_ai(update: Update, query):
msg = (
"<b>Artificial intelligence</b>\n\n"
"<b>⚠️ Disabled due to limitations. They may be reintroduced in future updates.</b>\n\n"
"/imagine » generate AI image (Available temporarily)\n"
"<s>/imagine » generate AI image</s>\n"
"<s>/gpt » ask any question to ChatGPT</s>\n\n"
"<i><b>Note:</b> Send command to get more details about the command functions!</i>"
)
Expand Down

0 comments on commit f1c94ea

Please sign in to comment.