add generate images
This commit is contained in:
parent
28d0e6fdbf
commit
3965b11643
@ -1,6 +1,7 @@
|
|||||||
import openai
|
import openai
|
||||||
from aiogram import types, Dispatcher
|
from aiogram import types, Dispatcher
|
||||||
from create_bot import dp, bot
|
from create_bot import dp, bot
|
||||||
|
import logging
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -9,6 +10,35 @@ token = '5947963644:AAF_GKgMmU5ovqMpc1KXIpcf4aN0JMyKPqc'
|
|||||||
openai.api_key = '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'
|
openai.api_key = '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'
|
||||||
ban_comands = ['/dick','/topdick']
|
ban_comands = ['/dick','/topdick']
|
||||||
|
|
||||||
|
# Image_promt =['тупица сгенерируй','тупица сгенерируй картинку',\
|
||||||
|
# 'тупица отправь картинку', 'тупица отправь картинку']
|
||||||
|
|
||||||
|
|
||||||
|
@dp.message_handler(commands=['image'])
|
||||||
|
async def send_image(message: types.Message):
|
||||||
|
try:
|
||||||
|
description = message.text.replace('/image', '').strip()
|
||||||
|
|
||||||
|
if not description:
|
||||||
|
await message.reply('Ты даун, описание запроса напиши после пробела')
|
||||||
|
return
|
||||||
|
except Exception as e:
|
||||||
|
logging.error(f'Error in send_image: {e}')
|
||||||
|
try:
|
||||||
|
|
||||||
|
response = openai.Image.create(
|
||||||
|
prompt=message.text,
|
||||||
|
n=1,
|
||||||
|
size="1024x1024",
|
||||||
|
response_format="url",
|
||||||
|
|
||||||
|
)
|
||||||
|
image_url = response['data'][0]['url']
|
||||||
|
await message.answer('Генерирую изображение...')
|
||||||
|
await message.reply_photo(image_url)
|
||||||
|
except Exception as e:
|
||||||
|
await message.reply('у меня не получилось')
|
||||||
|
|
||||||
@dp.message_handler()
|
@dp.message_handler()
|
||||||
async def send(message: types.Message):
|
async def send(message: types.Message):
|
||||||
if message.text.lower().startswith('тупица'):
|
if message.text.lower().startswith('тупица'):
|
||||||
@ -43,3 +73,7 @@ async def send(message: types.Message):
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user