Published script

honeypot

Protects a channel by removing accounts that post in it

u0/honeypot@1 Message received v1 0

Readme

Install this exact publication into an existing channel reserved as a honeypot. Each user account that posts there is kicked after Macchi attempts to remove that account’s messages from the previous five minutes in the current channel. Server owners, channel managers, bots, and system accounts are ignored. The caught-account counter is stored in shared channel storage.

Source

Showing version 1

Changelog: Initial channel honeypot with five-minute cleanup and a persistent caught-account counter.

function run()
  if not ctx.guild or not ctx.channel or not ctx.member then
    return
  end

  if ctx.user.isBot or ctx.user.isSystem or ctx.member.isOwner then
    return
  end

  if ctx.member:hasPermission("administrator") or ctx.member:hasPermission("manage_channels") then
    return
  end

  local result = ctx.member:kick({
    reason = "Honeypot channel message",
    deleteMessages = {
      withinSeconds = 300,
      channels = "current",
      ignorePinned = false,
      onFailure = "abort"
    }
  })

  if not result.applied then
    return
  end

  local store = macchi.storage:open("channel")
  local caught = store:increment("honeypot.caught", 1)
  macchi.reply("Self-bots or curious users caught: **" .. caught.value .. "**")
end