some more cleanup, preparations to update nostr sdk

This commit is contained in:
Believethehype
2023-11-21 23:51:48 +01:00
parent 1735a45513
commit 2286701453
15 changed files with 173 additions and 208 deletions

View File

@@ -2,6 +2,8 @@ import json
import datetime as datetime
import os
from types import NoneType
import emoji
import requests
from pyupload.uploader import CatboxUploader
@@ -109,7 +111,7 @@ Will probably need to switch to another system in the future.
'''
def uploadMediaToHoster(filepath):
def upload_media_to_hoster(filepath: str):
print("Uploading image: " + filepath)
try:
files = {'file': open(filepath, 'rb')}
@@ -144,3 +146,40 @@ def uploadMediaToHoster(filepath):
return result
except:
return "Upload not possible, all hosters didn't work"
def build_status_reaction(status, task, amount, content):
alt_description = "This is a reaction to a NIP90 DVM AI task. "
if status == "processing":
alt_description = "NIP90 DVM AI task " + task + " started processing. "
reaction = alt_description + emoji.emojize(":thumbs_up:")
elif status == "success":
alt_description = "NIP90 DVM AI task " + task + " finished successfully. "
reaction = alt_description + emoji.emojize(":call_me_hand:")
elif status == "chain-scheduled":
alt_description = "NIP90 DVM AI task " + task + " Chain Task scheduled"
reaction = alt_description + emoji.emojize(":thumbs_up:")
elif status == "error":
alt_description = "NIP90 DVM AI task " + task + " had an error. "
if content is None:
reaction = alt_description + emoji.emojize(":thumbs_down:")
else:
reaction = alt_description + emoji.emojize(":thumbs_down:") + content
elif status == "payment-required":
alt_description = "NIP90 DVM AI task " + task + " requires payment of min " + str(
amount) + " Sats. "
reaction = alt_description + emoji.emojize(":orange_heart:")
elif status == "payment-rejected":
alt_description = "NIP90 DVM AI task " + task + " payment is below required amount of " + str(
amount) + " Sats. "
reaction = alt_description + emoji.emojize(":thumbs_down:")
elif status == "user-blocked-from-service":
alt_description = "NIP90 DVM AI task " + task + " can't be performed. User has been blocked from Service. "
reaction = alt_description + emoji.emojize(":thumbs_down:")
else:
reaction = emoji.emojize(":thumbs_down:")
return alt_description, reaction