code cleanup

This commit is contained in:
Believethehype 2024-10-15 16:57:10 +02:00
parent 3742fe6a15
commit 3c4a900ff0
3 changed files with 18 additions and 16 deletions

View File

@ -1,7 +1,8 @@
import json
import os
from datetime import timedelta
from nostr_sdk import Client, Timestamp, PublicKey, Tag, Keys, Options, SecretKey, NostrSigner, Kind, RelayOptions
from nostr_sdk import Client, Timestamp, PublicKey, Tag, Keys, Options, SecretKey, NostrSigner, Kind
from nostr_dvm.interfaces.dvmtaskinterface import DVMTaskInterface, process_venv
from nostr_dvm.utils.admin_utils import AdminConfig

View File

@ -1,9 +1,8 @@
import json
import os
from datetime import timedelta
import requests
from nostr_sdk import Client, Timestamp, PublicKey, Tag, Keys, Options, SecretKey, NostrSigner, Event, Kind
from nostr_sdk import Timestamp, PublicKey, Tag, Kind
from nostr_dvm.interfaces.dvmtaskinterface import DVMTaskInterface, process_venv
from nostr_dvm.utils.admin_utils import AdminConfig
@ -85,7 +84,6 @@ class AdvancedSearchWine(DVMTaskInterface):
return request_form
async def process(self, request_form):
from nostr_sdk import Filter
options = self.set_options(request_form)
userkeys = []
for user in options["users"]:

View File

@ -1,9 +1,10 @@
import json
import os
from datetime import timedelta
from nostr_sdk import Client, Timestamp, PublicKey, Tag, Keys, Options, SecretKey, NostrSigner, NostrDatabase, \
ClientBuilder, Filter, NegentropyOptions, NegentropyDirection, init_logger, LogLevel, Event, EventId, Kind, \
RelayOptions, RelayLimits
from nostr_sdk import Timestamp, Tag, Keys, Options, SecretKey, NostrSigner, NostrDatabase, \
ClientBuilder, Filter, NegentropyOptions, NegentropyDirection, init_logger, LogLevel, Kind, \
RelayLimits
from nostr_dvm.interfaces.dvmtaskinterface import DVMTaskInterface, process_venv
from nostr_dvm.utils import definitions
@ -14,7 +15,6 @@ from nostr_dvm.utils.nip88_utils import NIP88Config, check_and_set_d_tag_nip88,
from nostr_dvm.utils.nip89_utils import NIP89Config, check_and_set_d_tag, create_amount_tag
from nostr_dvm.utils.output_utils import post_process_list_to_events
"""
This File contains a Module to discover popular notes
Accepted Inputs: none
@ -113,7 +113,7 @@ class DicoverContentLatestLongForm(DVMTaskInterface):
signer = NostrSigner.keys(keys)
database = NostrDatabase.lmdb(self.db_name)
#print(self.db_name)
# print(self.db_name)
cli = ClientBuilder().database(database).signer(signer).opts(opts).build()
await cli.connect()
@ -130,8 +130,8 @@ class DicoverContentLatestLongForm(DVMTaskInterface):
index = options["max_results"]
for event in events:
if event.created_at().as_secs() > timestamp_hour_ago:
ns.finallist[event.id().to_hex()] = index
index = index-1
ns.finallist[event.id().to_hex()] = index
index = index - 1
if len(ns.finallist) == 0:
await cli.shutdown()
return self.result
@ -189,7 +189,8 @@ class DicoverContentLatestLongForm(DVMTaskInterface):
timestamp_since = Timestamp.now().as_secs() - self.db_since
since = Timestamp.from_secs(timestamp_since)
filter1 = Filter().kinds([definitions.EventDefinitions.KIND_LONGFORM]).since(since) # Notes, reactions, zaps
filter1 = Filter().kinds([definitions.EventDefinitions.KIND_LONGFORM]).since(
since) # Notes, reactions, zaps
# filter = Filter().author(keys.public_key())
if self.dvm_config.LOGLEVEL.value >= LogLevel.DEBUG.value:
@ -202,10 +203,12 @@ class DicoverContentLatestLongForm(DVMTaskInterface):
await cli.shutdown()
if self.dvm_config.LOGLEVEL.value >= LogLevel.DEBUG.value:
print(
"[" + self.dvm_config.NIP89.NAME + "] Done Syncing Notes of the last " + str(self.db_since) + " seconds..")
"[" + self.dvm_config.NIP89.NAME + "] Done Syncing Notes of the last " + str(
self.db_since) + " seconds..")
except Exception as e:
print(e)
# We build an example here that we can call by either calling this file directly from the main directory,
# or by adding it to our playground. You can call the example and adjust it to your needs or redefine it in the
# playground or elsewhere
@ -254,7 +257,7 @@ def build_example(name, identifier, admin_config, options, cost=0, update_rate=1
# admin_config.REBROADCAST_NIP89 = False
return DicoverContentLatestLongForm(name=name, dvm_config=dvm_config, nip89config=nip89config,
admin_config=admin_config, options=options)
admin_config=admin_config, options=options)
def build_example_subscription(name, identifier, admin_config, options, update_rate=180, processing_msg=None,
@ -317,8 +320,8 @@ def build_example_subscription(name, identifier, admin_config, options, update_r
# admin_config.PRIVKEY = dvm_config.PRIVATE_KEY
return DicoverContentLatestLongForm(name=name, dvm_config=dvm_config, nip89config=nip89config,
nip88config=nip88config, options=options,
admin_config=admin_config)
nip88config=nip88config, options=options,
admin_config=admin_config)
if __name__ == '__main__':