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
Published at
2024-11-10 09:20:13Event JSON
{
"id": "3f1e5b3a0dd95bfcd235b4a48d721a2194f1d33747b3261689320b3d63192729",
"pubkey": "0aa39e5aef99a000a7bdb0b499158c92bc4aa20fb65931a52d055b5eb6dff738",
"created_at": 1731230413,
"kind": 1,
"tags": [
[
"e",
"000092a7d21ee379cb2475c5d3f68d60f8c5fb7dac3786fdccb5c2376c75937d",
"wss://nostr.x0f.org/",
"root"
],
[
"e",
"000092a7d21ee379cb2475c5d3f68d60f8c5fb7dac3786fdccb5c2376c75937d",
"wss://nostr.x0f.org/",
"reply"
]
],
"content": "currently i have a script that is periodically run and deletes certain bots from the sqlite database, which works\n\n===\n#!/usr/bin/env python3\nimport json\nimport sqlite3\nimport sys\n\nfrom nostr.util import decode\n\ndef make_db_connection():\n con = sqlite3.connect(os.path.join(os.getenv(\"HOME\"), \"data\", \"nostr.db\"))\n con.execute('PRAGMA foreign_keys = ON')\n cursor = con.cursor()\n return (con, cursor)\n\nconn, cursor = make_db_connection()\n\njunk = [\n...\n]\n\nfor npub in junk:\n author = decode(npub)['pubkey']\n res = cursor.execute(\"DELETE FROM event WHERE author=?\", (author, ))\n\nconn.commit()\n===\n\nbut 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",
"sig": "60d18fa88ad5990ca8ec7e3e60cf5041ee6807591f6dfb11deb82b50b72115b5e4ca71f44cc835f1ead072539694309951db83607e38cb0ccc5330d9cb3e8b47"
}