mirror of
https://github.com/believethehype/nostrdvm.git
synced 2025-11-19 13:17:08 +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))
|
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 < 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
|
success = False
|
||||||
else:
|
else:
|
||||||
success = True
|
success = True
|
||||||
@@ -404,36 +406,39 @@ class Subscription:
|
|||||||
send_event(evt, client=self.client, dvm_config=dvm_config)
|
send_event(evt, client=self.client, dvm_config=dvm_config)
|
||||||
|
|
||||||
def check_subscriptions():
|
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:
|
for subscription in subscriptions:
|
||||||
if subscription.active:
|
if subscription.active:
|
||||||
if subscription.end < Timestamp.now().as_secs():
|
if subscription.end < Timestamp.now().as_secs():
|
||||||
# We could directly zap, but let's make another check if our subscription expired
|
# We could directly zap, but let's make another check if our subscription expired
|
||||||
subscription_status = nip88_has_active_subscription(
|
subscription_status = nip88_has_active_subscription(
|
||||||
PublicKey.parse(subscription.subscriber),
|
PublicKey.parse(subscription.subscriber),
|
||||||
subscription.tier_dtag, self.client, subscription.recipent)
|
subscription.tier_dtag, self.client, subscription.recipent)
|
||||||
|
|
||||||
if subscription_status["expires"]:
|
if subscription_status["expires"]:
|
||||||
# if subscription expires, just note it as not active
|
# if subscription expires, just note it as not active
|
||||||
update_subscription_sql_table(dvm_config.DB, subscription_status["subscriptionId"],
|
update_subscription_sql_table(dvm_config.DB, subscription_status["subscriptionId"],
|
||||||
subscription.recipent,
|
subscription.recipent,
|
||||||
subscription.subscriber, subscription.nwc,
|
subscription.subscriber, subscription.nwc,
|
||||||
subscription.cadence, subscription.amount,
|
subscription.cadence, subscription.amount,
|
||||||
subscription.unit,
|
subscription.unit,
|
||||||
subscription.begin, subscription.end,
|
subscription.begin, subscription.end,
|
||||||
subscription.tier_dtag, subscription.zaps,
|
subscription.tier_dtag, subscription.zaps,
|
||||||
subscription.recipe,
|
subscription.recipe,
|
||||||
False,
|
False,
|
||||||
Timestamp.now().as_secs(), subscription.tier)
|
Timestamp.now().as_secs(), subscription.tier)
|
||||||
else:
|
else:
|
||||||
handle_subscription_renewal(subscription)
|
handle_subscription_renewal(subscription)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
handle_expired_subscription(subscription)
|
handle_expired_subscription(subscription)
|
||||||
|
|
||||||
print(str(Timestamp.now().as_secs()) + ": Checking " + str(
|
print(str(Timestamp.now().as_secs()) + ": Checking " + str(
|
||||||
len(subscriptions)) + " Subscription entries..")
|
len(subscriptions)) + " Subscription entries..")
|
||||||
|
except Exception as e:
|
||||||
|
print(e)
|
||||||
|
|
||||||
self.client.handle_notifications(NotificationHandler())
|
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:
|
Current List of Tasks:
|
||||||
|
|
||||||
| Module | Kind | Description | Backend |
|
| Module | Kind | Description | Backend |
|
||||||
|--------------------------------------|------|------------------------------------------------------------|------------------|
|
|----------------------------|------|------------------------------------------------------|------------------|
|
||||||
| TextExtractionPDF | 5000 | Extracts Text from a PDF file | local |
|
| TextExtractionPDF | 5000 | Extracts Text from a PDF file | local |
|
||||||
| SpeechToTextGoogle | 5000 | Extracts Speech from Media files via Google Services | googleAPI |
|
| SpeechToTextGoogle | 5000 | Extracts Speech from Media files via Google Services | googleAPI |
|
||||||
| SpeechToTextWhisperX | 5000 | Extracts Speech from Media files via local WhisperX | nserver |
|
| SpeechToTextWhisperX | 5000 | Extracts Speech from Media files via local WhisperX | nserver |
|
||||||
| ImageInterrogator | 5000 | Extracts Prompts from Images | nserver |
|
| ImageInterrogator | 5000 | Extracts Prompts from Images | nserver |
|
||||||
| TextSummarizationHuggingChat | 5001 | Summarizes given Input | huggingface |
|
| TextSumHuggingChat | 5001 | Summarizes given Input | huggingface |
|
||||||
| **TextSummarizationUnleasedChat** | 5001 | Summarizes given Input | unleashed api |
|
| **TextSumUnleashedChat** | 5001 | Summarizes given Input | unleashed api |
|
||||||
| TranslationGoogle | 5002 | Translates Inputs to another language | googleAPI |
|
| TranslationGoogle | 5002 | Translates Inputs to another language | googleAPI |
|
||||||
| TranslationLibre | 5002 | Translates Inputs to another language | libreAPI |
|
| TranslationLibre | 5002 | Translates Inputs to another language | libreAPI |
|
||||||
| TextGenerationLLMLite | 5050 | Chat with LLM backends like Ollama, ChatGPT etc | local/api/openai |
|
| TextGenerationLLMLite | 5050 | Chat with LLM backends like Ollama, ChatGPT etc | local/api/openai |
|
||||||
| TextGenerationHuggingChat | 5050 | Chat with LLM backend on Huggingface | huggingface |
|
| TextGenerationHuggingChat | 5050 | Chat with LLM backend on Huggingface | huggingface |
|
||||||
| TextGenerationLLMUnleashedChat | 5050 | Chat with unleashed.chat LLMs | unleashed api |
|
| TextGenLLMUnleashedChat | 5050 | Chat with unleashed.chat LLMs | unleashed api |
|
||||||
| ImageGenerationSDXL | 5100 | Generates an Image from Prompt with Stable Diffusion XL | nserver |
|
| ImageGenSDXL | 5100 | Generates an Image from Prompt with SD XL | nserver |
|
||||||
| ImageGenerationSDXLIMG2IMG | 5100 | Generates an Image from an Image with Stable Diffusion XL | nserver |
|
| ImageGenSDXLIMG2IMG | 5100 | Generates an Image from an Image with SD XL | nserver |
|
||||||
| ImageGenerationReplicateSDXL | 5100 | Generates an Image from Prompt with Stable Diffusion XL | replicate |
|
| ImageGenReplicateSDXL | 5100 | Generates an Image from Prompt with SDXL | replicate |
|
||||||
| ImageGenerationMLX | 5100 | Generates an Image with Stable Diffusion 2.1 on M1/2/3 Mac | mlx |
|
| ImageGeneMLX | 5100 | Generates an Image with SD 2.1 on M-Mac | mlx |
|
||||||
| ImageGenerationDALLE | 5100 | Generates an Image with OpenAI's Dall-E | openAI |
|
| ImageGenDALLE | 5100 | Generates an Image with OpenAI's Dall-E | openAI |
|
||||||
| ImageUpscale | 5100 | Upscales an Image | nserver |
|
| ImageUpscale | 5100 | Upscales an Image | nserver |
|
||||||
| MediaConverter | 5200 | Converts a link of a media file and uploads it | openAI |
|
| MediaConverter | 5200 | Converts a link of a media file and uploads it | openAI |
|
||||||
| VideoGenerationReplicateSVD | 5202 | Generates a Video from an Image | replicate |
|
| VideoGenReplicateSVD | 5202 | Generates a Video from an Image | replicate |
|
||||||
| VideoGenerationSVD | 5202 | Generates a Video from an Image | nserver |
|
| VideoGenerationSVD | 5202 | Generates a Video from an Image | nserver |
|
||||||
| TextToSpeech | 5250 | Generate Audio from a prompt | local |
|
| TextToSpeech | 5250 | Generate Audio from a prompt | local |
|
||||||
| TrendingNotesNostrBand | 5300 | Show trending notes on nostr.band | nostr.band api |
|
| 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 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 |
|
| **Discover CPN Followers** | 5300 | Show trending notes by people you follow | local/db |
|
||||||
| DiscoverInactiveFollows | 5301 | Find inactive Nostr users | local |
|
| DiscoverInactiveFollows | 5301 | Find inactive Nostr users | local |
|
||||||
| **DiscoverNonFollows** | 5301 | Find Nostr users not following back | local |
|
| **DiscoverNonFollows** | 5301 | Find Nostr users not following back | local |
|
||||||
| **Discover Bot Farms** | 5301 | Find Bots, so you can mute them | 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 |
|
| **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 |
|
| AdvancedSearch | 5302 | Search Content on relays (nostr.band) | local/nostr.band |
|
||||||
| AdvancedSearchWine | 5302 | Search Content on nostr.wine | api/nostr.wine |
|
| AdvancedSearchWine | 5302 | Search Content on nostr.wine | api/nostr.wine |
|
||||||
| **Search Users** | 5303 | Search Users based on search terms | local/db |
|
| **Search Users** | 5303 | Search Users based on search terms | local/db |
|
||||||
| **Subscriptions** | 5906 | Manage Subscriptions for other DVMS | local |
|
| **Subscriptions** | 5906 | Manage Subscriptions for other DVMS | local |
|
||||||
|
|
||||||
Kinds with (inoff) are suggestions and not merged yet and might change in the future.
|
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.
|
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