mirror of
https://github.com/believethehype/nostrdvm.git
synced 2025-08-08 12:51:43 +02:00
some more code cleanup
This commit is contained in:
@@ -1,18 +1,14 @@
|
||||
# DATABASE LOGIC
|
||||
import json
|
||||
import sqlite3
|
||||
|
||||
from sqlite3 import Error
|
||||
from dataclasses import dataclass
|
||||
from datetime import timedelta
|
||||
from logging import Filter
|
||||
from sqlite3 import Error
|
||||
|
||||
|
||||
from nostr_sdk import Timestamp, Keys, PublicKey, EventBuilder, Filter, Kind
|
||||
from nostr_sdk import Timestamp, Keys, PublicKey, Filter, Kind
|
||||
|
||||
from nostr_dvm.utils.definitions import relay_timeout
|
||||
|
||||
from nostr_dvm.utils.nostr_utils import send_event, send_nip04_dm
|
||||
from nostr_dvm.utils.nostr_utils import send_nip04_dm
|
||||
|
||||
|
||||
@dataclass
|
||||
@@ -190,17 +186,15 @@ async def update_user_balance(db, npub, additional_sats, client, config, giftwra
|
||||
|
||||
if config is not None:
|
||||
keys = Keys.parse(config.PRIVATE_KEY)
|
||||
# time.sleep(1.0)
|
||||
|
||||
message = ("Added " + str(additional_sats) + " Sats to balance. New balance is " + str(
|
||||
new_balance) + " Sats.")
|
||||
|
||||
if giftwrap:
|
||||
# always send giftwrapped. sorry not sorry.
|
||||
#if giftwrap:
|
||||
await client.send_private_msg(PublicKey.parse(npub), message, None)
|
||||
else:
|
||||
#await client.send_direct_msg(PublicKey.parse(npub), message, None)
|
||||
#await client.send_private_msg(PublicKey.parse(npub), message, None)
|
||||
await send_nip04_dm(client, message, PublicKey.parse(npub), config)
|
||||
#else:
|
||||
# await send_nip04_dm(client, message, PublicKey.parse(npub), config)
|
||||
|
||||
|
||||
def update_user_subscription(npub, subscribed_until, client, dvm_config):
|
||||
|
@@ -1,4 +1,3 @@
|
||||
import os
|
||||
from dataclasses import dataclass
|
||||
from datetime import timedelta
|
||||
|
||||
@@ -63,7 +62,6 @@ class EventDefinitions:
|
||||
KIND_NIP88_TIER_EVENT = Kind(37001)
|
||||
KIND_NUT_WALLET = Kind(37375)
|
||||
|
||||
|
||||
ANY_RESULT = [KIND_NIP90_RESULT_EXTRACT_TEXT,
|
||||
KIND_NIP90_RESULT_SUMMARIZE_TEXT,
|
||||
KIND_NIP90_RESULT_TRANSLATE_TEXT,
|
||||
@@ -97,6 +95,7 @@ class RequiredJobToWatch:
|
||||
event: Event
|
||||
timestamp: int
|
||||
|
||||
|
||||
@dataclass
|
||||
class InvoiceToWatch:
|
||||
sender: str
|
||||
|
@@ -1,6 +1,6 @@
|
||||
import os
|
||||
|
||||
from nostr_sdk import Keys, LogLevel, PublicKey
|
||||
from nostr_sdk import Keys, LogLevel
|
||||
|
||||
from nostr_dvm.utils.nip88_utils import NIP88Config
|
||||
from nostr_dvm.utils.nip89_utils import NIP89Config
|
||||
@@ -8,6 +8,7 @@ from nostr_dvm.utils.nostr_utils import check_and_set_private_key
|
||||
from nostr_dvm.utils.outbox_utils import AVOID_OUTBOX_RELAY_LIST
|
||||
from nostr_dvm.utils.zap_utils import check_and_set_ln_bits_keys
|
||||
|
||||
|
||||
class DVMConfig:
|
||||
SUPPORTED_DVMS = []
|
||||
PRIVATE_KEY: str = ""
|
||||
@@ -31,11 +32,9 @@ class DVMConfig:
|
||||
]
|
||||
WOT_DEPTH = 2
|
||||
|
||||
|
||||
AVOID_PAID_OUTBOX_RELAY_LIST = AVOID_OUTBOX_RELAY_LIST
|
||||
# If a DVM has a paid subscription, overwrite list without the paid one.
|
||||
|
||||
|
||||
RELAY_TIMEOUT = 5
|
||||
RELAY_LONG_TIMEOUT = 30
|
||||
EXTERNAL_POST_PROCESS_TYPE = 0 # Leave this on None, except the DVM is external
|
||||
|
@@ -1,15 +1,15 @@
|
||||
from nostr_sdk import Tag, Keys, EventBuilder, Kind
|
||||
from nostr_sdk import Keys, EventBuilder, Kind
|
||||
|
||||
from nostr_dvm.utils.nostr_utils import send_event
|
||||
from nostr_dvm.utils.print_utils import bcolors
|
||||
|
||||
|
||||
async def gallery_announce_list(tags, dvm_config, client):
|
||||
|
||||
|
||||
keys = Keys.parse(dvm_config.NIP89.PK)
|
||||
content = ""
|
||||
event = EventBuilder(Kind(10011), content, tags).to_event(keys)
|
||||
eventid = await send_event(event, client=client, dvm_config=dvm_config, blastr=True)
|
||||
|
||||
print(bcolors.BLUE + "[" + dvm_config.NIP89.NAME + "] Announced Gallery for " + dvm_config.NIP89.NAME +" (EventID: " + str(eventid.to_hex()) +")" + bcolors.ENDC)
|
||||
print(
|
||||
bcolors.BLUE + "[" + dvm_config.NIP89.NAME + "] Announced Gallery for " + dvm_config.NIP89.NAME + " (EventID: " + str(
|
||||
eventid.to_hex()) + ")" + bcolors.ENDC)
|
||||
|
@@ -2,9 +2,10 @@ import os
|
||||
import urllib
|
||||
from datetime import time
|
||||
from urllib.parse import urlparse
|
||||
import ffmpegio
|
||||
|
||||
import ffmpegio
|
||||
import requests
|
||||
|
||||
from nostr_dvm.utils.nostr_utils import get_event_by_id
|
||||
from nostr_dvm.utils.scrapper.media_scrapper import YTDownload, get_media_duration
|
||||
|
||||
|
@@ -5,14 +5,15 @@ from collections import namedtuple
|
||||
from datetime import timedelta
|
||||
|
||||
import requests
|
||||
from nostr_sdk import Tag, Keys, nip44_encrypt, nip44_decrypt, Nip44Version, EventBuilder, Client, Filter, Kind, \
|
||||
EventId, nip04_decrypt, nip04_encrypt, Options, NostrSigner, PublicKey, Metadata
|
||||
|
||||
from nostr_dvm.utils.database_utils import fetch_user_metadata
|
||||
from nostr_dvm.utils.definitions import EventDefinitions, relay_timeout, relay_timeout_long
|
||||
from nostr_dvm.utils.dvmconfig import DVMConfig
|
||||
from nostr_dvm.utils.nostr_utils import check_and_set_private_key
|
||||
from nostr_dvm.utils.zap_utils import pay_bolt11_ln_bits, zaprequest
|
||||
from nostr_sdk import Tag, Keys, nip44_encrypt, nip44_decrypt, Nip44Version, EventBuilder, Client, Filter, Kind, \
|
||||
EventId, nip04_decrypt, nip04_encrypt, Options, NostrSigner, PublicKey, init_logger, LogLevel, Metadata
|
||||
from nostr_dvm.utils.print_utils import bcolors
|
||||
from nostr_dvm.utils.zap_utils import pay_bolt11_ln_bits, zaprequest
|
||||
|
||||
|
||||
class NutWallet(object):
|
||||
@@ -783,7 +784,6 @@ class NutZapWallet:
|
||||
from cashu.wallet.wallet import Wallet
|
||||
from cashu.core.crypto.keys import PrivateKey
|
||||
|
||||
|
||||
outgoing_mint = self.get_mint(nut_wallet, outgoing_mint_url)
|
||||
|
||||
outgoing_wallet = await Wallet.with_db(
|
||||
@@ -797,7 +797,6 @@ class NutZapWallet:
|
||||
|
||||
print(outgoing_wallet.available_balance)
|
||||
|
||||
|
||||
incoming_mint = self.get_mint(nut_wallet, incoming_mint_url)
|
||||
incoming_wallet = await Wallet.with_db(
|
||||
url=incoming_mint_url,
|
||||
@@ -808,8 +807,6 @@ class NutZapWallet:
|
||||
await incoming_wallet.load_mint()
|
||||
incoming_wallet.proofs = incoming_mint.proofs
|
||||
|
||||
|
||||
|
||||
if incoming_wallet.url == outgoing_wallet.url:
|
||||
raise Exception("mints for swap have to be different")
|
||||
|
||||
|
@@ -19,8 +19,6 @@ async def create_reaction(keys, title, dtag):
|
||||
emoji_tag1 = Tag.parse(["emoji", name, url])
|
||||
emoji_tags.append(emoji_tag1)
|
||||
|
||||
|
||||
|
||||
keys = Keys.parse(keys)
|
||||
content = ""
|
||||
event = EventBuilder(Kind(30030), content, [d_tag, title_tag] + emoji_tags).to_event(keys)
|
||||
|
Reference in New Issue
Block a user