-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
47 lines (39 loc) · 1.05 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
const {DVM, withExpiration} = require('nikabrik')
const {now} = require('@coracle.social/lib')
const {createEvent} = require('@coracle.social/util')
const {subscribe} = require('@coracle.social/network')
require('dotenv').config()
const tags = []
const sub = subscribe({
timeout: 30_000,
relays: ["wss://relay.wavlake.com"],
filters: [{
kinds: [31337],
'#p': ['8806372af51515bf4aef807291b96487ea1826c966a5596bca86697b5d8b23bc'],
}],
})
sub.emitter.on('event', (url, e) => tags.push(["e", e.id, url]))
const startDVM = () =>
new DVM({
sk: process.env.DVM_SK,
relays: [
'wss://nostrainsley.coracle.tools',
'wss://phantom-power.coracle.tools',
'wss://relay.damus.io',
],
strict: true,
agents: {
5300: dvm => ({
handleEvent: async function* (event) {
console.log(event)
yield createEvent(event.kind + 1000, {
content: JSON.stringify(tags),
tags: withExpiration([])
})
},
}),
}
})
// Main
startDVM()
console.log("Worker started")