forked from bluesky-social/atproto
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a simple command to generate a bunch of random posts (bluesky-soc…
…ial#73) * add a simple command to generate a bunch of random posts * move spam command into its own subcommand grouping: * learn how the typescript build system works
- Loading branch information
1 parent
53847a1
commit 96a96f4
Showing
4 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import cmd from '../../lib/command.js' | ||
import { loadDelegate } from '../../lib/client.js' | ||
import { REPO_PATH } from '../../lib/env.js' | ||
import { TID } from '@bluesky/common' | ||
|
||
function makeRandText(l: number) { | ||
var set = ' abcdefghijklmnopqrstuvwxyz '; | ||
var len = set.length; | ||
var out = ''; | ||
for ( let i = 0; i < len; i++ ) { | ||
out += set.charAt(Math.floor(Math.random() * | ||
len)); | ||
} | ||
return out; | ||
} | ||
|
||
export default cmd({ | ||
name: 'gen-random-posts', | ||
category: 'dev', | ||
help: 'Create a large number of random posts.', | ||
args: [{ name: 'count' }], | ||
async command(args) { | ||
const count : number = +(args._[0]) | ||
const client = await loadDelegate(REPO_PATH) | ||
|
||
for (let i = 0; i < count; i++) { | ||
await client.addPost(makeRandText(100)) | ||
} | ||
|
||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters