laanwj on Nostr: currently i have a script that is periodically run and deletes certain bots from the ...
currently i have a script that is periodically run and deletes certain bots from the sqlite database, which works
===
#!/usr/bin/env python3
import json
import sqlite3
import sys
from nostr.util import decode
def make_db_connection():
con = sqlite3.connect(os.path.join(os.getenv("HOME"), "data", "nostr.db"))
con.execute('PRAGMA foreign_keys = ON')
cursor = con.cursor()
return (con, cursor)
conn, cursor = make_db_connection()
junk = [
...
]
for npub in junk:
author = decode(npub)['pubkey']
res = cursor.execute("DELETE FROM event WHERE author=?", (author, ))
conn.commit()
===
but a way to reject them upfront would be better 🙂 there's the "event admission server" gRPC functionality that's probably intended to be used for scenarios like this... but haven't really looked into it, kinda hesitant to add more moving parts
===
#!/usr/bin/env python3
import json
import sqlite3
import sys
from nostr.util import decode
def make_db_connection():
con = sqlite3.connect(os.path.join(os.getenv("HOME"), "data", "nostr.db"))
con.execute('PRAGMA foreign_keys = ON')
cursor = con.cursor()
return (con, cursor)
conn, cursor = make_db_connection()
junk = [
...
]
for npub in junk:
author = decode(npub)['pubkey']
res = cursor.execute("DELETE FROM event WHERE author=?", (author, ))
conn.commit()
===
but a way to reject them upfront would be better 🙂 there's the "event admission server" gRPC functionality that's probably intended to be used for scenarios like this... but haven't really looked into it, kinda hesitant to add more moving parts