@ -82,21 +82,33 @@ class Callbacks(object):
print ( event )
print ( event )
await self . bot . send_message ( self . client , room . room_id , " Hello World! " )
await self . bot . send_message ( self . client , room . room_id , " Hello World! " )
return
return
elif event . body . startswith ( ' !image ' ) or event . body . startswith ( ' !image1 ' ) :
elif event . body == " !image " or event . body . startswith ( ' !image ' ) or event . body . startswith ( ' !image1 ' ) :
prompt = event . body . removeprefix ( ' !image ' ) . removeprefix ( ' !image1 ' ) . strip ( )
prompt = event . body . removeprefix ( ' !image ' ) . removeprefix ( ' !image1 ' ) . strip ( )
negative_prompt = " out of frame, (ugly:1.3), (fused fingers), (too many fingers), (bad anatomy:1.5), (watermark:1.5), (words), letters, untracked eyes, asymmetric eyes, floating head, (logo:1.5), (bad hands:1.3), (mangled hands:1.2), (missing hands), (missing arms), backward hands, floating jewelry, unattached jewelry, floating head, doubled head, unattached head, doubled head, head in body, (misshapen body:1.1), (badly fitted headwear:1.2), floating arms, (too many arms:1.5), limbs fused with body, (facial blemish:1.5), badly fitted clothes, imperfect eyes, untracked eyes, crossed eyes, hair growing from clothes, partial faces, hair not attached to head "
negative_prompt = " out of frame, (ugly:1.3), (fused fingers), (too many fingers), (bad anatomy:1.5), (watermark:1.5), (words), letters, untracked eyes, asymmetric eyes, floating head, (logo:1.5), (bad hands:1.3), (mangled hands:1.2), (missing hands), (missing arms), backward hands, floating jewelry, unattached jewelry, floating head, doubled head, unattached head, doubled head, head in body, (misshapen body:1.1), (badly fitted headwear:1.2), floating arms, (too many arms:1.5), limbs fused with body, (facial blemish:1.5), badly fitted clothes, imperfect eyes, untracked eyes, crossed eyes, hair growing from clothes, partial faces, hair not attached to head "
if len ( prompt ) == 0 :
if len ( prompt ) > 0 :
prompt = " a beautiful woman "
if self . bot . image_prompt :
output = await ai . generate_image ( prompt , negative_prompt , " https://api.runpod.ai/v1/sd-anything-v4/ " , self . bot . runpod_api_key )
prompt . replace ( self . bot . name , self . bot . image_prompt )
else :
if self . bot . image_prompt :
prompt = self . bot . image_prompt
else :
prompt = " a beautiful woman "
output = await ai . generate_image1 ( prompt , negative_prompt , self . bot . runpod_api_key )
for imagefile in output :
for imagefile in output :
await self . bot . send_image ( self . client , room . room_id , imagefile )
await self . bot . send_image ( self . client , room . room_id , imagefile )
return
return
elif event . body . startswith ( ' !image2 ' ) :
elif event . body . startswith ( ' !image2 ' ) :
prompt = event . body . removeprefix ( ' !image2 ' ) . strip ( )
prompt = event . body . removeprefix ( ' !image2 ' ) . strip ( )
negative_prompt = " ugly, tiling, poorly drawn hands, poorly drawn feet, poorly drawn face, out of frame, extra limbs, disfigured, deformed, body out of frame, bad anatomy, watermark, signature, cut off, low contrast, underexposed, overexposed, bad art, beginner, amateur, distorted face "
negative_prompt = " ugly, tiling, poorly drawn hands, poorly drawn feet, poorly drawn face, out of frame, extra limbs, disfigured, deformed, body out of frame, bad anatomy, watermark, signature, cut off, low contrast, underexposed, overexposed, bad art, beginner, amateur, distorted face "
if len ( prompt ) == 0 :
if len ( prompt ) > 0 :
prompt = " a beautiful woman "
if self . bot . image_prompt :
output = await ai . generate_image ( prompt , negative_prompt , " https://api.runpod.ai/v1/sd-openjourney/ " , self . bot . runpod_api_key )
prompt . replace ( self . bot . name , self . bot . image_prompt )
else :
if self . bot . image_prompt :
prompt = self . bot . image_prompt
else :
prompt = " a beautiful woman "
output = await ai . generate_image2 ( prompt , negative_prompt , self . bot . runpod_api_key )
for imagefile in output :
for imagefile in output :
await self . bot . send_image ( self . client , room . room_id , imagefile )
await self . bot . send_image ( self . client , room . room_id , imagefile )
return
return
@ -175,9 +187,9 @@ class Callbacks(object):
await self . bot . send_message ( self . client , room . room_id , translated_answer , reply_to = chat_message . event_id , original_message = answer )
await self . bot . send_message ( self . client , room . room_id , translated_answer , reply_to = chat_message . event_id , original_message = answer )
else :
else :
await self . bot . send_message ( self . client , room . room_id , answer , reply_to = chat_message . event_id )
await self . bot . send_message ( self . client , room . room_id , answer , reply_to = chat_message . event_id )
if not " message_count " in self . room_config [ room_id ] :
if not " message_count " in self . bot . room_config [ room . room_id ] :
self . room_config [ room_id ] [ " message_count " ] = 0
self . bot . room_config [ room . room_id ] [ " message_count " ] = 0
self . room_config [ room_id ] [ " message_count " ] + = 1
self . bot . room_config [ room . room_id ] [ " message_count " ] + = 1
async def invite_cb ( self , room : MatrixRoom , event : InviteEvent ) - > None :
async def invite_cb ( self , room : MatrixRoom , event : InviteEvent ) - > None :