This commit is contained in:
Pavel_Durov 2024-05-10 19:46:37 +03:00
parent a571709afa
commit db842a1ceb
2 changed files with 28 additions and 26 deletions

View File

@ -12,7 +12,8 @@ telegram_admins_ids:
- 317051301 # hogweed1 - 317051301 # hogweed1
- 226765676 # blackjack - 226765676 # blackjack
- 94830892 # viktorRMI - 94830892 # viktorRMI
- 132002803
openai: openai:
token: 5947963644:AAF_GKgMmU5ovqMpc1KXIpcf4aN0JMyKPqc token: 5947963644:AAF_GKgMmU5ovqMpc1KXIpcf4aN0JMyKPqc
api_key: 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 ## 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 api_key: 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 ## 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

View File

@ -3,7 +3,7 @@ from aiogram import types
from create_bot import dp, bot from create_bot import dp, bot
import logging import logging
from global_conf import CONFIG from global_conf import CONFIG
admins = CONFIG['telegram_admins_ids']
token = CONFIG['openai']['token'] token = CONFIG['openai']['token']
@ -16,36 +16,37 @@ ban_comands = ['/dick','/topdick']
@dp.message_handler(commands=['image']) @dp.message_handler(commands=['image'])
async def send_image(message: types.Message): async def send_image(message: types.Message):
try: if message.from_user.id in admins and message.chat.type == 'private':
description = message.text.replace('/image', '').strip() try:
description = message.text.replace('/image', '').strip()
if not description: if not description:
await message.reply('Ты даун, описание запроса напиши после пробела') await message.reply('Ты даун, описание запроса напиши после пробела')
return return
except Exception as e: except Exception as e:
logging.error(f'Error in send_image: {e}') logging.error(f'Error in send_image: {e}')
try: try:
response = openai.Image.create( response = openai.Image.create(
prompt=message.text, prompt=message.text,
n=1, n=1,
size="1024x1024", size="1024x1024",
response_format="url", response_format="url",
) )
image_url = response['data'][0]['url'] image_url = response['data'][0]['url']
await message.answer('Генерирую изображение...') await message.answer('Генерирую изображение...')
await message.reply_photo(image_url) await message.reply_photo(image_url)
except Exception as e: except Exception as e:
await message.reply('у меня не получилось') 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.from_user.id in admins and message.chat.type == 'private':
## TODO уточнить остатки токенов и денег ## TODO уточнить остатки токенов и денег
response = openai.Completion.create( response = openai.Completion.create(
model="text-davinci-003", model="gpt-4-turbo",
prompt=message.text[7:], prompt=message.text[7:],
temperature=0.7, temperature=0.7,
max_tokens=1000, max_tokens=1000,
@ -58,7 +59,7 @@ async def send(message: types.Message):
elif message.reply_to_message.from_user.is_bot: elif message.reply_to_message.from_user.is_bot:
response = openai.Completion.create( response = openai.Completion.create(
model="text-davinci-003", model="gpt-4-turbo",
prompt=message.text, prompt=message.text,
temperature=0.7, temperature=0.7,
max_tokens=1000, max_tokens=1000,