8
submitted 1 year ago* (last edited 1 year ago) by tubbadu@lemmy.one to c/programming@beehaw.org

Hello fellow Lemmings! I'm trying to develop a Lemmy bot that reads posts and comments using the lemmy-bot library. So I created a new Node.js project, installed the library, and wrote this:

import LemmyBot from 'lemmy-bot';

const LEMMY_USERNAME = process.env.LEMMY_USERNAME;
const LEMMY_PASSWORD = process.env.LEMMY_PASSWORD;
const LEMMY_INSTANCE = process.env.LEMMY_INSTANCE;

const bot = new LemmyBot.LemmyBot({
  // Pass configuration options here
  credentials: {
    username: LEMMY_USERNAME,
    password: LEMMY_PASSWORD
  },
  instance: LEMMY_INSTANCE,
  federation: "all",
  dbFile: 'db.sqlite3',
  handler: {
    comment: {
      handle: ({
        commentView: {
          comment: { creator_id, id }
        },
        botActions: { createComment }
      }) => {
        console.warn("new comment:")
      }
    },
    post: {
      handle: (x) => {
        console.warn("new post", x)
      }
    }
  }
});

bot.start()

and then I run it: node index.js
this is the output:

Connected to Lemmy Instance
Initializing DB
Logging in
Marking account as bot account
Subscribing to communities

and then stops there. I waited a lot and nothing, not a single log. credentials are correct, because otherwise it wouldn't login. the bot is using an account hosted on sh.itjust.work, so there should be plenty of activity (I tried adding comments manually but nothing was detected)

What am I doing wrong?

thanks in advance

top 1 comments
sorted by: hot top controversial new old
[-] F04118F@feddit.nl 1 points 1 year ago

I noticed in my account settings, there is a tickbox "is bot". Perhaps try setting that to true or false on the account you are using?

this post was submitted on 14 Jun 2023
8 points (90.0% liked)

Programming

13269 readers
1 users here now

All things programming and coding related. Subcommunity of Technology.


This community's icon was made by Aaron Schneider, under the CC-BY-NC-SA 4.0 license.

founded 1 year ago
MODERATORS