Add new ipfs links to telegram bot

pull/26/head
Guillermo Rodriguez 2023-10-05 15:58:00 -03:00
parent c6e58c36d8
commit 10044c6d12
No known key found for this signature in database
GPG Key ID: EC3AB66D5D83B392
1 changed files with 17 additions and 2 deletions

View File

@ -237,9 +237,24 @@ class SkynetTelegramFrontend:
user, params, tx_hash, worker, reward) user, params, tx_hash, worker, reward)
# attempt to get the image and send it # attempt to get the image and send it
ipfs_link = f'https://ipfs.{DEFAULT_DOMAIN}/ipfs/{ipfs_hash}/image.png' results = {}
resp = await get_ipfs_file(ipfs_link) ipfs_link = f'https://ipfs.{DEFAULT_DOMAIN}/ipfs/{ipfs_hash}'
ipfs_link_legacy = ipfs_link + '/image.png'
async def get_and_set_results(link: str):
results[link] = await get_ipfs_file(link)
tasks = [
get_and_set_results(ipfs_link),
get_and_set_results(ipfs_link_legacy)
]
await asyncio.gather(*tasks)
resp = results[ipfs_link_legacy]
if not resp or resp.status_code != 200:
logging.error(f'couldn\'t get ipfs hosted image at {ipfs_link_legacy}!')
resp = results[ipfs_link]
if not resp or resp.status_code != 200: if not resp or resp.status_code != 200:
logging.error(f'couldn\'t get ipfs hosted image at {ipfs_link}!') logging.error(f'couldn\'t get ipfs hosted image at {ipfs_link}!')
await self.update_status_message( await self.update_status_message(