mirror of
https://github.com/believethehype/nostrdvm.git
synced 2025-11-18 21:06:39 +01:00
error handling on subscription check
This commit is contained in:
@@ -187,6 +187,8 @@ class Subscription:
|
||||
print(str(zapped_amount) + "/" + str(overall_amount))
|
||||
|
||||
if zapped_amount < overall_amount * 0.8: # TODO how do we handle failed zaps for some addresses? we are ok with 80% for now
|
||||
#if zapped_amount < int(zaps[0][3]):
|
||||
|
||||
success = False
|
||||
else:
|
||||
success = True
|
||||
@@ -404,36 +406,39 @@ class Subscription:
|
||||
send_event(evt, client=self.client, dvm_config=dvm_config)
|
||||
|
||||
def check_subscriptions():
|
||||
subscriptions = get_all_subscriptions_from_sql_table(dvm_config.DB)
|
||||
try:
|
||||
subscriptions = get_all_subscriptions_from_sql_table(dvm_config.DB)
|
||||
|
||||
for subscription in subscriptions:
|
||||
if subscription.active:
|
||||
if subscription.end < Timestamp.now().as_secs():
|
||||
# We could directly zap, but let's make another check if our subscription expired
|
||||
subscription_status = nip88_has_active_subscription(
|
||||
PublicKey.parse(subscription.subscriber),
|
||||
subscription.tier_dtag, self.client, subscription.recipent)
|
||||
for subscription in subscriptions:
|
||||
if subscription.active:
|
||||
if subscription.end < Timestamp.now().as_secs():
|
||||
# We could directly zap, but let's make another check if our subscription expired
|
||||
subscription_status = nip88_has_active_subscription(
|
||||
PublicKey.parse(subscription.subscriber),
|
||||
subscription.tier_dtag, self.client, subscription.recipent)
|
||||
|
||||
if subscription_status["expires"]:
|
||||
# if subscription expires, just note it as not active
|
||||
update_subscription_sql_table(dvm_config.DB, subscription_status["subscriptionId"],
|
||||
subscription.recipent,
|
||||
subscription.subscriber, subscription.nwc,
|
||||
subscription.cadence, subscription.amount,
|
||||
subscription.unit,
|
||||
subscription.begin, subscription.end,
|
||||
subscription.tier_dtag, subscription.zaps,
|
||||
subscription.recipe,
|
||||
False,
|
||||
Timestamp.now().as_secs(), subscription.tier)
|
||||
else:
|
||||
handle_subscription_renewal(subscription)
|
||||
if subscription_status["expires"]:
|
||||
# if subscription expires, just note it as not active
|
||||
update_subscription_sql_table(dvm_config.DB, subscription_status["subscriptionId"],
|
||||
subscription.recipent,
|
||||
subscription.subscriber, subscription.nwc,
|
||||
subscription.cadence, subscription.amount,
|
||||
subscription.unit,
|
||||
subscription.begin, subscription.end,
|
||||
subscription.tier_dtag, subscription.zaps,
|
||||
subscription.recipe,
|
||||
False,
|
||||
Timestamp.now().as_secs(), subscription.tier)
|
||||
else:
|
||||
handle_subscription_renewal(subscription)
|
||||
|
||||
else:
|
||||
handle_expired_subscription(subscription)
|
||||
else:
|
||||
handle_expired_subscription(subscription)
|
||||
|
||||
print(str(Timestamp.now().as_secs()) + ": Checking " + str(
|
||||
len(subscriptions)) + " Subscription entries..")
|
||||
print(str(Timestamp.now().as_secs()) + ": Checking " + str(
|
||||
len(subscriptions)) + " Subscription entries..")
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
self.client.handle_notifications(NotificationHandler())
|
||||
|
||||
|
||||
@@ -6,40 +6,40 @@ Reusable backend functions can be defined in backends (e.g. API calls)
|
||||
|
||||
Current List of Tasks:
|
||||
|
||||
| Module | Kind | Description | Backend |
|
||||
|--------------------------------------|------|------------------------------------------------------------|------------------|
|
||||
| TextExtractionPDF | 5000 | Extracts Text from a PDF file | local |
|
||||
| SpeechToTextGoogle | 5000 | Extracts Speech from Media files via Google Services | googleAPI |
|
||||
| SpeechToTextWhisperX | 5000 | Extracts Speech from Media files via local WhisperX | nserver |
|
||||
| ImageInterrogator | 5000 | Extracts Prompts from Images | nserver |
|
||||
| TextSummarizationHuggingChat | 5001 | Summarizes given Input | huggingface |
|
||||
| **TextSummarizationUnleasedChat** | 5001 | Summarizes given Input | unleashed api |
|
||||
| TranslationGoogle | 5002 | Translates Inputs to another language | googleAPI |
|
||||
| TranslationLibre | 5002 | Translates Inputs to another language | libreAPI |
|
||||
| TextGenerationLLMLite | 5050 | Chat with LLM backends like Ollama, ChatGPT etc | local/api/openai |
|
||||
| TextGenerationHuggingChat | 5050 | Chat with LLM backend on Huggingface | huggingface |
|
||||
| TextGenerationLLMUnleashedChat | 5050 | Chat with unleashed.chat LLMs | unleashed api |
|
||||
| ImageGenerationSDXL | 5100 | Generates an Image from Prompt with Stable Diffusion XL | nserver |
|
||||
| ImageGenerationSDXLIMG2IMG | 5100 | Generates an Image from an Image with Stable Diffusion XL | nserver |
|
||||
| ImageGenerationReplicateSDXL | 5100 | Generates an Image from Prompt with Stable Diffusion XL | replicate |
|
||||
| ImageGenerationMLX | 5100 | Generates an Image with Stable Diffusion 2.1 on M1/2/3 Mac | mlx |
|
||||
| ImageGenerationDALLE | 5100 | Generates an Image with OpenAI's Dall-E | openAI |
|
||||
| ImageUpscale | 5100 | Upscales an Image | nserver |
|
||||
| MediaConverter | 5200 | Converts a link of a media file and uploads it | openAI |
|
||||
| VideoGenerationReplicateSVD | 5202 | Generates a Video from an Image | replicate |
|
||||
| VideoGenerationSVD | 5202 | Generates a Video from an Image | nserver |
|
||||
| TextToSpeech | 5250 | Generate Audio from a prompt | local |
|
||||
| TrendingNotesNostrBand | 5300 | Show trending notes on nostr.band | nostr.band api |
|
||||
| **Discover Currently Popular Notes** | 5300 | Show trending notes in the last 2 hours | local/db |
|
||||
| **Discover CPN Followers** | 5300 | Show trending notes by people you follow | local/db |
|
||||
| DiscoverInactiveFollows | 5301 | Find inactive Nostr users | local |
|
||||
| **DiscoverNonFollows** | 5301 | Find Nostr users not following back | local |
|
||||
| **Discover Bot Farms** | 5301 | Find Bots, so you can mute them | local |
|
||||
| **Discover Censor WOT** | 5301 | Find users that have been reported by your follows/WOT | local |
|
||||
| AdvancedSearch | 5302 | Search Content on relays (nostr.band) | local/nostr.band |
|
||||
| AdvancedSearchWine | 5302 | Search Content on nostr.wine | api/nostr.wine |
|
||||
| **Search Users** | 5303 | Search Users based on search terms | local/db |
|
||||
| **Subscriptions** | 5906 | Manage Subscriptions for other DVMS | local |
|
||||
| Module | Kind | Description | Backend |
|
||||
|----------------------------|------|------------------------------------------------------|------------------|
|
||||
| TextExtractionPDF | 5000 | Extracts Text from a PDF file | local |
|
||||
| SpeechToTextGoogle | 5000 | Extracts Speech from Media files via Google Services | googleAPI |
|
||||
| SpeechToTextWhisperX | 5000 | Extracts Speech from Media files via local WhisperX | nserver |
|
||||
| ImageInterrogator | 5000 | Extracts Prompts from Images | nserver |
|
||||
| TextSumHuggingChat | 5001 | Summarizes given Input | huggingface |
|
||||
| **TextSumUnleashedChat** | 5001 | Summarizes given Input | unleashed api |
|
||||
| TranslationGoogle | 5002 | Translates Inputs to another language | googleAPI |
|
||||
| TranslationLibre | 5002 | Translates Inputs to another language | libreAPI |
|
||||
| TextGenerationLLMLite | 5050 | Chat with LLM backends like Ollama, ChatGPT etc | local/api/openai |
|
||||
| TextGenerationHuggingChat | 5050 | Chat with LLM backend on Huggingface | huggingface |
|
||||
| TextGenLLMUnleashedChat | 5050 | Chat with unleashed.chat LLMs | unleashed api |
|
||||
| ImageGenSDXL | 5100 | Generates an Image from Prompt with SD XL | nserver |
|
||||
| ImageGenSDXLIMG2IMG | 5100 | Generates an Image from an Image with SD XL | nserver |
|
||||
| ImageGenReplicateSDXL | 5100 | Generates an Image from Prompt with SDXL | replicate |
|
||||
| ImageGeneMLX | 5100 | Generates an Image with SD 2.1 on M-Mac | mlx |
|
||||
| ImageGenDALLE | 5100 | Generates an Image with OpenAI's Dall-E | openAI |
|
||||
| ImageUpscale | 5100 | Upscales an Image | nserver |
|
||||
| MediaConverter | 5200 | Converts a link of a media file and uploads it | openAI |
|
||||
| VideoGenReplicateSVD | 5202 | Generates a Video from an Image | replicate |
|
||||
| VideoGenerationSVD | 5202 | Generates a Video from an Image | nserver |
|
||||
| TextToSpeech | 5250 | Generate Audio from a prompt | local |
|
||||
| TrendingNotesNostrBand | 5300 | Show trending notes on nostr.band | nostr.band api |
|
||||
| **Discover Popular Notes** | 5300 | Show trending notes in the last 2 hours | local/db |
|
||||
| **Discover CPN Followers** | 5300 | Show trending notes by people you follow | local/db |
|
||||
| DiscoverInactiveFollows | 5301 | Find inactive Nostr users | local |
|
||||
| **DiscoverNonFollows** | 5301 | Find Nostr users not following back | local |
|
||||
| **Discover Bot Farms** | 5301 | Find Bots, so you can mute them | local |
|
||||
| **Discover Censor WOT** | 5301 | Find users that have been reported by follows/WOT | local |
|
||||
| AdvancedSearch | 5302 | Search Content on relays (nostr.band) | local/nostr.band |
|
||||
| AdvancedSearchWine | 5302 | Search Content on nostr.wine | api/nostr.wine |
|
||||
| **Search Users** | 5303 | Search Users based on search terms | local/db |
|
||||
| **Subscriptions** | 5906 | Manage Subscriptions for other DVMS | local |
|
||||
|
||||
Kinds with (inoff) are suggestions and not merged yet and might change in the future.
|
||||
Backends might require to add an API key to the .env file or run an external server/framework the dvm will communicate with.
|
||||
Reference in New Issue
Block a user