randydev commited on
Commit
5b99e56
Β·
verified Β·
1 Parent(s): 57bfdd8

Upload chat.py

Browse files
Files changed (1) hide show
  1. chatbot/plugins/chat.py +9 -9
chatbot/plugins/chat.py CHANGED
@@ -282,9 +282,9 @@ async def deletemydata(client, callback):
282
  else:
283
  await callback.answer(delm, True)
284
 
285
- @Client.on_callback_query(filters.regex("^genprompt$"))
286
  async def geminigen_prompt(client, callback):
287
- user_id = callback.from_user.id
288
  user_bl = await db.user_blacklists.find_one({"user_id": user_id})
289
  if user_bl and user_bl.get("is_frozen", False) and user_id not in [6477856957]:
290
  await callback.answer("Sorry your account is frozen", True)
@@ -314,7 +314,6 @@ async def geminigen_prompt(client, callback):
314
  response_modalities=['TEXT', 'IMAGE']
315
  )
316
  )
317
- uuid_code = str(uuid.uuid4())[:8]
318
  for part in response.candidates[0].content.parts:
319
  if part.text is not None:
320
  captions += part.text
@@ -322,6 +321,7 @@ async def geminigen_prompt(client, callback):
322
  image = Image.open(BytesIO((part.inline_data.data)))
323
  image.save(file_path)
324
 
 
325
  keyboard = create_keyboard(
326
  user_id=user_id,
327
  uuid_str=uuid_code
@@ -364,9 +364,9 @@ async def geminigen_prompt(client, callback):
364
  except:
365
  pass
366
 
367
- @Client.on_callback_query(filters.regex("^fluxprompt$"))
368
  async def flux_prompt(client, callback):
369
- user_id = callback.from_user.id
370
  user_bl = await db.user_blacklists.find_one({"user_id": user_id})
371
  if user_bl and user_bl.get("is_frozen", False) and user_id not in [6477856957]:
372
  await callback.answer("Sorry your account is frozen", True)
@@ -405,7 +405,6 @@ async def flux_prompt(client, callback):
405
  file_photo = await gen.aio.files.get(name=file_photo.name)
406
  if file_photo.state.name == "FAILED":
407
  return await callback.message.reply_text(f"Error: {file_photo.state.name}")
408
- uuid_code = str(uuid.uuid4())[:8]
409
  response = await gen.aio.models.generate_content(
410
  model="gemini-2.0-flash",
411
  contents=[
@@ -413,6 +412,7 @@ async def flux_prompt(client, callback):
413
  file_photo
414
  ]
415
  )
 
416
  keyboard = create_keyboard(
417
  user_id=user_id,
418
  uuid_str=uuid_code
@@ -639,7 +639,7 @@ async def multiple_langagues(client, callback):
639
  InlineKeyboardButton("πŸ‡·πŸ‡Ί", callback_data=f"tr_ru_{uuidstr}"),
640
  ])
641
  keyboard.append([
642
- InlineKeyboardButton("πŸ’Ύ", callback_data=f"memory_{uuidstr}")
643
  ])
644
  try:
645
  await callback.edit_message_reply_markup(
@@ -1258,13 +1258,13 @@ async def chatbot_talk(client: Client, message: Message):
1258
  [
1259
  InlineKeyboardButton(
1260
  text="🎨 Gemini AI Generate Image",
1261
- callback_data="genprompt"
1262
  )
1263
  ],
1264
  [
1265
  InlineKeyboardButton(
1266
  text="πŸ–ŒοΈ FLUX AI Generate Image",
1267
- callback_data="fluxprompt"
1268
  )
1269
  ],
1270
  [
 
282
  else:
283
  await callback.answer(delm, True)
284
 
285
+ @Client.on_callback_query(filters.regex("^genprompt_(\d+)$"))
286
  async def geminigen_prompt(client, callback):
287
+ user_id = int(callback.matches[0].group(1))
288
  user_bl = await db.user_blacklists.find_one({"user_id": user_id})
289
  if user_bl and user_bl.get("is_frozen", False) and user_id not in [6477856957]:
290
  await callback.answer("Sorry your account is frozen", True)
 
314
  response_modalities=['TEXT', 'IMAGE']
315
  )
316
  )
 
317
  for part in response.candidates[0].content.parts:
318
  if part.text is not None:
319
  captions += part.text
 
321
  image = Image.open(BytesIO((part.inline_data.data)))
322
  image.save(file_path)
323
 
324
+ uuid_code = str(uuid.uuid4())[:8]
325
  keyboard = create_keyboard(
326
  user_id=user_id,
327
  uuid_str=uuid_code
 
364
  except:
365
  pass
366
 
367
+ @Client.on_callback_query(filters.regex("^fluxprompt_(\d+)$"))
368
  async def flux_prompt(client, callback):
369
+ user_id = int(callback.matches[0].group(1))
370
  user_bl = await db.user_blacklists.find_one({"user_id": user_id})
371
  if user_bl and user_bl.get("is_frozen", False) and user_id not in [6477856957]:
372
  await callback.answer("Sorry your account is frozen", True)
 
405
  file_photo = await gen.aio.files.get(name=file_photo.name)
406
  if file_photo.state.name == "FAILED":
407
  return await callback.message.reply_text(f"Error: {file_photo.state.name}")
 
408
  response = await gen.aio.models.generate_content(
409
  model="gemini-2.0-flash",
410
  contents=[
 
412
  file_photo
413
  ]
414
  )
415
+ uuid_code = str(uuid.uuid4())[:8]
416
  keyboard = create_keyboard(
417
  user_id=user_id,
418
  uuid_str=uuid_code
 
639
  InlineKeyboardButton("πŸ‡·πŸ‡Ί", callback_data=f"tr_ru_{uuidstr}"),
640
  ])
641
  keyboard.append([
642
+ InlineKeyboardButton("Back To Menu", callback_data=f"menu_back:{uuidstr}")
643
  ])
644
  try:
645
  await callback.edit_message_reply_markup(
 
1258
  [
1259
  InlineKeyboardButton(
1260
  text="🎨 Gemini AI Generate Image",
1261
+ callback_data=f"genprompt_{message.from_user.id}"
1262
  )
1263
  ],
1264
  [
1265
  InlineKeyboardButton(
1266
  text="πŸ–ŒοΈ FLUX AI Generate Image",
1267
+ callback_data=f"fluxprompt_{message.from_user.id}"
1268
  )
1269
  ],
1270
  [