-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
59 lines (49 loc) · 1.81 KB
/
index.ts
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
48
49
50
51
52
53
54
55
56
57
58
59
import 'dotenv/config';
import { LemmyBot } from 'lemmy-bot';
import { MongoClient } from 'mongodb';
const USERNAME = process.env.LEMMY_USERNAME || '';
const PASSWORD = process.env.LEMMY_PASSWORD || '';
const INSTANCE = process.env.LEMMY_INSTANCE || '';
const OWN_ACTOR_ID = `https://${INSTANCE}/u/${USERNAME}`;
const MONGODB_URI = process.env.MONGODB_URI || '';
const COMMUNITY = 'lemmy.basedcount.com/c/pcm';
const client = new MongoClient(MONGODB_URI);
const bot = new LemmyBot({
instance: INSTANCE,
handlers: {
comment: async ({
commentView: {
comment: { id: commentId },
post: { id: postId },
community: { actor_id: communityActorId },
creator: { actor_id: actorId }
},
botActions: { createComment },
preventReprocess
}) => {
if (actorId === OWN_ACTOR_ID || communityActorId !== COMMUNITY) return;
/*
Use commentId and createComment to reply to comment => createComment({ post_id: postId, content: 'SAMPLE TEXT', parent_id: id });
*/
preventReprocess();
},
post: async ({
postView: {
post: { id: postId },
community: { actor_id: communityActorId },
creator: { actor_id: actorId }
},
botActions: { createComment },
preventReprocess
}) => {
if (actorId === OWN_ACTOR_ID || communityActorId !== COMMUNITY) return;
/*
Use postId and createComment to reply to comment => createComment({ post_id: postId, content: 'SAMPLE TEXT', parent_id: null (or leave empty?) });
*/
preventReprocess();
},
}
});
async function run() {
bot.start();
}