@botkit@hollo.social · Reply to BotKit by Fedify :botkit:
Like

The onLike event handler is called when someone likes messages on your bot or actors your bot follows. It receives a Like object, which represents the like activity, as the second argument.

The following is an example of a like event handler that sends a direct message when someone likes a message on your bot:

bot.onLike = async (session, like) => {
  if (like.message.actor.id?.href !== session.actorId.href) return;
  await session.publish(
    text`Thanks for liking my message, ${like.actor}!`,
    { visibility: "direct" },
  );
};

Unlike

The onUnlike event handler is called when someone undoes a Like activity on messages on your bot or actors your bot follows. It receives a Like object, which represents the Like activity which was undone, as the second argument.

The following is an example of an unlike event handler that sends a direct message when someone undoes a like activity on a message on your bot:

bot.onUnlike = async (session, like) => {
  if (like.message.actor.id?.href !== session.actorId.href) return;
  await session.publish(
    text`I'm sorry to hear that you unliked my message, ${like.actor}.`,
    { visibility: "direct" },
  );
};
ALT text

Like The onLike event handler is called when someone likes messages on your bot or actors your bot follows. It receives a Like object, which represents the like activity, as the second argument. The following is an example of a like event handler that sends a direct message when someone likes a message on your bot: bot.onLike = async (session, like) => { if (like.message.actor.id?.href !== session.actorId.href) return; await session.publish( text`Thanks for liking my message, ${like.actor}!`, { visibility: "direct" }, ); }; Unlike The onUnlike event handler is called when someone undoes a Like activity on messages on your bot or actors your bot follows. It receives a Like object, which represents the Like activity which was undone, as the second argument. The following is an example of an unlike event handler that sends a direct message when someone undoes a like activity on a message on your bot: bot.onUnlike = async (session, like) => { if (like.message.actor.id?.href !== session.actorId.href) return; await session.publish( text`I'm sorry to hear that you unliked my message, ${like.actor}.`, { visibility: "direct" }, ); };