Skip to content

Commit

Permalink
example using fetch()
Browse files Browse the repository at this point in the history
  • Loading branch information
fiatjaf committed Nov 25, 2023
1 parent 6c6d515 commit 634b191
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions custom.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,15 @@ var defaultScripts = map[scriptPath]string{
if (event.tags.length > 0) return 'notes cannot have tags'
}`,
REJECT_FILTER: `export default function (filter) {
if ((filter.authors?.length || 0) === 0)
return 'must specify an author to query, sync bots not allowed'
if (filter.authors?.length > 30)
return 'too many authors in filter, this may be a badly written client logic'
return fetch(
'https://www.random.org/integers/?num=1&min=1&max=9&col=1&base=10&format=plain&rnd=new'
)
.then(r => r.text())
.then(res => {
if (parseInt(res) > 4)
return ` + "`" + `you were not lucky enough: got ${res.trim()} but needed 4 or less` + "`" + `
return null
})
}`,
}

Expand Down

0 comments on commit 634b191

Please sign in to comment.