-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Removed ai-imagine due to limitations (again)
- Loading branch information
1 parent
426f489
commit f1c94ea
Showing
3 changed files
with
4 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters