More telegram reply text changes

pull/4/head
Guillermo Rodriguez 2023-01-17 07:16:29 -03:00
parent 5d6b3c2edb
commit 5a365180ff
No known key found for this signature in database
GPG Key ID: EC3AB66D5D83B392
1 changed files with 16 additions and 10 deletions

View File

@ -28,7 +28,7 @@ def prepare_metainfo_caption(tguser, meta: dict) -> str:
prompt = prompt[:256] prompt = prompt[:256]
if tguser.username: if tguser.username:
user = tguser.username user = f'@{tguser.username}'
else: else:
user = f'{tguser.first_name} id: {tguser.id}' user = f'{tguser.first_name} id: {tguser.id}'
@ -93,8 +93,9 @@ async def run_skynet_telegram(
@bot.message_handler(commands=['txt2img']) @bot.message_handler(commands=['txt2img'])
async def send_txt2img(message): async def send_txt2img(message):
chat = message.chat chat = message.chat
# if chat.type != 'group' and chat.id != GROUP_ID: reply_id = None
# return if chat.type == 'group' and chat.id == GROUP_ID:
reply_id = message.message_id
prompt = ' '.join(message.text.split(' ')[1:]) prompt = ' '.join(message.text.split(' ')[1:])
@ -124,7 +125,8 @@ async def run_skynet_telegram(
await bot.send_photo( await bot.send_photo(
GROUP_ID, GROUP_ID,
caption=prepare_metainfo_caption(message.from_user, result['meta']['meta']), caption=prepare_metainfo_caption(message.from_user, result['meta']['meta']),
photo=img photo=img,
reply_to_message_id=reply_id
) )
return return
@ -133,8 +135,9 @@ async def run_skynet_telegram(
@bot.message_handler(func=lambda message: True, content_types=['photo']) @bot.message_handler(func=lambda message: True, content_types=['photo'])
async def send_img2img(message): async def send_img2img(message):
chat = message.chat chat = message.chat
# if chat.type != 'group' and chat.id != GROUP_ID: reply_id = None
# return if chat.type == 'group' and chat.id == GROUP_ID:
reply_id = message.message_id
if not message.caption.startswith('/img2img'): if not message.caption.startswith('/img2img'):
return return
@ -172,7 +175,8 @@ async def run_skynet_telegram(
await bot.send_photo( await bot.send_photo(
GROUP_ID, GROUP_ID,
caption=prepare_metainfo_caption(message.from_user, result['meta']['meta']), caption=prepare_metainfo_caption(message.from_user, result['meta']['meta']),
photo=img photo=img,
reply_to_message_id=reply_id
) )
return return
@ -188,8 +192,9 @@ async def run_skynet_telegram(
@bot.message_handler(commands=['redo']) @bot.message_handler(commands=['redo'])
async def redo_txt2img(message): async def redo_txt2img(message):
chat = message.chat chat = message.chat
# if chat.type != 'group' and chat.id != GROUP_ID: reply_id = None
# return if chat.type == 'group' and chat.id == GROUP_ID:
reply_id = message.message_id
resp = await _rpc_call(message.from_user.id, 'redo') resp = await _rpc_call(message.from_user.id, 'redo')
@ -207,7 +212,8 @@ async def run_skynet_telegram(
await bot.send_photo( await bot.send_photo(
GROUP_ID, GROUP_ID,
caption=prepare_metainfo_caption(message.from_user, result['meta']['meta']), caption=prepare_metainfo_caption(message.from_user, result['meta']['meta']),
photo=img photo=img,
reply_to_message_id=reply_id
) )
return return