randydev commited on
Commit
63e8267
·
verified ·
1 Parent(s): 43be786

Update chatbot/plugins/chat.py

Browse files
Files changed (1) hide show
  1. chatbot/plugins/chat.py +16 -11
chatbot/plugins/chat.py CHANGED
@@ -61,6 +61,15 @@ trans = SyncTranslator()
61
  js = AkenoXJs(DifferentAPIDefault()).connect()
62
 
63
  message_memory_state = {}
 
 
 
 
 
 
 
 
 
64
 
65
  def obfuscate(word):
66
  return word.lower()\
@@ -931,9 +940,9 @@ async def chatbot_talk(client: Client, message: Message):
931
  if regex_all_blacklist(caption):
932
  return await message.reply_text("You been blocked blacklisted")
933
 
934
- if caption == "--stream-image":
935
  return await message.reply_text(
936
- "You can't --stream-image, it has to be long OR short first\n"
937
  )
938
 
939
  stream_image_now = re.sub(r"--stream-image", "", caption).strip()
@@ -947,7 +956,7 @@ async def chatbot_talk(client: Client, message: Message):
947
  async for chunk in await gen.aio.models.generate_content_stream(
948
  model='gemini-2.0-flash-001',
949
  contents=[
950
- str(caption),
951
  ty.Part.from_bytes(data=image_bytes, mime_type="image/jpeg")
952
  ]
953
  ):
@@ -981,19 +990,15 @@ async def chatbot_talk(client: Client, message: Message):
981
  except:
982
  pass
983
 
984
- if re.findall(r"\b(This is a picture of me)\b", caption, re.IGNORECASE):
985
- if caption == "picture" or len(caption) > 300:
986
- return await message.reply_text(
987
- "You can't **picture** small, it has to be long OR short first\n"
988
- "OR Caption Too many `MAX_CAPTION: 300`"
989
- )
990
  try:
991
  backup_chat = await db._get_chatbot_chat_from_db(message.from_user.id)
992
  backup_chat.append({"role": "user", "parts": [{"text": caption}]})
993
  images = Image.open(await message.download())
994
  response = await gen.aio.models.generate_content(
995
  model="gemini-2.0-flash-exp-image-generation",
996
- contents=[str(caption), images],
997
  config=ty.GenerateContentConfig(
998
  response_modalities=['TEXT', 'IMAGE']
999
  )
@@ -1212,7 +1217,7 @@ async def chatbot_talk(client: Client, message: Message):
1212
  if regex_all_blacklist(query_base):
1213
  return await message.reply_text("You been blocked blacklisted")
1214
 
1215
- if query_base in ["/", "/help", "about:", "enabled:", "disabled:"]:
1216
  await client.send_chat_action(message.chat.id, enums.ChatAction.CANCEL)
1217
  return
1218
 
 
61
  js = AkenoXJs(DifferentAPIDefault()).connect()
62
 
63
  message_memory_state = {}
64
+ DISABLED_COMMANDS = [
65
+ "/",
66
+ "/help",
67
+ "about:",
68
+ "enabled:",
69
+ "disabled:",
70
+ "--stream-image",
71
+ "--edit-image"
72
+ ]
73
 
74
  def obfuscate(word):
75
  return word.lower()\
 
940
  if regex_all_blacklist(caption):
941
  return await message.reply_text("You been blocked blacklisted")
942
 
943
+ if caption == "--stream-image" or caption == "--edit-image" or len(caption) > 350:
944
  return await message.reply_text(
945
+ "You can't type, it has to be long or short"
946
  )
947
 
948
  stream_image_now = re.sub(r"--stream-image", "", caption).strip()
 
956
  async for chunk in await gen.aio.models.generate_content_stream(
957
  model='gemini-2.0-flash-001',
958
  contents=[
959
+ str(stream_image_now),
960
  ty.Part.from_bytes(data=image_bytes, mime_type="image/jpeg")
961
  ]
962
  ):
 
990
  except:
991
  pass
992
 
993
+ edit_image_now = re.sub(r"--edit-image", "", caption).strip()
994
+ if edit_image_now:
 
 
 
 
995
  try:
996
  backup_chat = await db._get_chatbot_chat_from_db(message.from_user.id)
997
  backup_chat.append({"role": "user", "parts": [{"text": caption}]})
998
  images = Image.open(await message.download())
999
  response = await gen.aio.models.generate_content(
1000
  model="gemini-2.0-flash-exp-image-generation",
1001
+ contents=[str(edit_image_now), images],
1002
  config=ty.GenerateContentConfig(
1003
  response_modalities=['TEXT', 'IMAGE']
1004
  )
 
1217
  if regex_all_blacklist(query_base):
1218
  return await message.reply_text("You been blocked blacklisted")
1219
 
1220
+ if query_base in DISABLED_COMMANDS:
1221
  await client.send_chat_action(message.chat.id, enums.ChatAction.CANCEL)
1222
  return
1223