Created: 2026/07/02 19:41:27 America/Chicago
By: admin
Views: 0

The auto-topic.lua script posts configured hub notices to Verlihub main chat at a set interval. Use it for rule reminders, maintenance notes, support links, command hints, and short community messages that do not need a separate external bot.

Keep this script small. It should send short configured messages and then return control to Verlihub. Do not add long-running jobs, database queries, external HTTP requests, file scans, or blocking waits to this script.

What This Script Does

The script sends automatic main chat messages from a configured bot name or hub identity.

Common uses include:

  • Posting hub rules reminders.
  • Posting website or support links.
  • Announcing scheduled maintenance.
  • Reminding users about available commands.
  • Sharing community links.
  • Displaying rotating notices.
  • Posting time-of-day messages.

Example main chat notice:

<HubNotice> Please review the hub rules with !rules before sharing or chatting.

Requirements

This script requires:

  • Verlihub installed and running.
  • The Verlihub Lua plugin installed.
  • The Lua plugin enabled in Verlihub.
  • Permission to load and unload Lua scripts.
  • A writable script directory for Verlihub Lua files.

Before loading the script, confirm that the Lua plugin is active:

!pluglist

If the Lua plugin is not listed, load or enable it first from the parent Lua setup article.

Use a dedicated script directory:

mkdir -p /PATH/TO/HUB/scripts

Place the script at:

/PATH/TO/HUB/scripts/auto-topic.lua

For production systems, the directory should be writable only by trusted administrators or by the Verlihub service user. Do not make the directory world-writable.

Load And Unload Commands

Load the script:

!luaload /PATH/TO/HUB/scripts/auto-topic.lua

Unload the script:

!luaunload /PATH/TO/HUB/scripts/auto-topic.lua

If you edit the script, unload it and load it again:

!luaunload /PATH/TO/HUB/scripts/auto-topic.lua
!luaload /PATH/TO/HUB/scripts/auto-topic.lua

Use the full absolute path unless your Verlihub Lua plugin configuration supports relative paths.

Script Code

-- Script: auto-topic.lua
-- Purpose: Sends rotating automatic notices to Verlihub main chat.
-- Scope: Lightweight hub notices only.
-- Notes: Keep interval reasonable to avoid chat spam.

botname = "HubNotice"
interval = 900
counter = 0
notice_index = 1

notices = {
    "Welcome to the hub. Please read the rules with !rules.",
    "Need help? Use !help or contact an operator.",
    "Visit our website for updates, guides, and hub information.",
    "Keep main chat respectful and avoid spam or repeated messages."
}

function SendNotice()
    if notices[notice_index] == nil then
        notice_index = 1
    end

    VH:SendToAll("<" .. botname .. "> " .. notices[notice_index])
    notice_index = notice_index + 1

    if notice_index > table.getn(notices) then
        notice_index = 1
    end
end

function OnTimer()
    counter = counter + 1

    if counter >= interval then
        counter = 0
        SendNotice()
    end
end

Configuration Options

botname

botname = "HubNotice"

The name shown before the automatic notice. Choose a clear name so users understand that the message is automated hub information.

Examples:

botname = "HubNotice"
botname = "RulesBot"
botname = "InfoBot"
botname = "Maintenance"

interval

interval = 900

Controls how often the script sends a notice. The intended value is usually seconds, depending on how the Verlihub Lua timer is configured in your environment.

Recommended values:

ValueMeaning
300Every 5 minutes.
600Every 10 minutes.
900Every 15 minutes.
1800Every 30 minutes.
3600Every 60 minutes.

For production hubs, 900 or 1800 is usually safer than a short interval. Avoid values that make the hub noisy:

interval = 10

A notice every 10 seconds is too aggressive for normal main chat.

counter

counter = 0

Internal counter used by the script. Do not change this unless you are modifying the script logic.

notice_index

notice_index = 1

Tracks which notice should be sent next. Leave this at 1 unless you want the script to start from a different message.

notices

notices = {
    "Welcome to the hub. Please read the rules with !rules.",
    "Need help? Use !help or contact an operator.",
    "Visit our website for updates, guides, and hub information.",
    "Keep main chat respectful and avoid spam or repeated messages."
}

The list of messages that rotate in main chat. Each notice should be short, useful, and non-disruptive.

Good notice examples:

notices = {
    "Use !rules to view hub rules.",
    "Use !help to see available commands.",
    "Operators are marked in the user list if you need assistance.",
    "Please keep main chat friendly and on topic."
}

Avoid long, repeated, or aggressive notices. Users are more likely to ignore automated messages when they appear too often.

Example Configurations

Basic Rules Reminder

botname = "RulesBot"
interval = 1800
notices = {
    "Please read the hub rules with !rules.",
    "Do not spam main chat or repeat the same message.",
    "Respect other users and follow operator instructions."
}

Website And Support Notice

botname = "InfoBot"
interval = 3600
notices = {
    "Visit the website for hub guides, updates, and support.",
    "Need help? Use !help or contact an operator.",
    "Check the articles section for Verlihub setup notes and Lua scripts."
}

Maintenance Notice

botname = "Maintenance"
interval = 900
notices = {
    "Scheduled maintenance may occur during low-traffic hours.",
    "If the hub disconnects during maintenance, reconnect after a few minutes.",
    "Check the website for maintenance updates."
}

Community Notice

botname = "Community"
interval = 1800
notices = {
    "Welcome to the hub. Keep chat friendly and helpful.",
    "Use main chat for general discussion. Contact operators for support issues.",
    "Invite trusted users and help keep the hub useful."
}

For most hubs, use a 15-minute or 30-minute interval:

botname = "HubNotice"
interval = 1800
notices = {
    "Welcome to the hub. Use !rules to review the hub rules.",
    "Need help? Use !help or contact an operator.",
    "Keep main chat respectful and avoid spam."
}

This keeps notices visible without flooding the chat. For busy hubs, use:

interval = 3600

For quiet hubs, use:

interval = 1800

Main chat automation should support the community, not interrupt it.

Testing The Script

After loading the script, confirm that:

  • The script loads without errors.
  • The notice appears in main chat.
  • Notices rotate in the expected order.
  • The interval is not too aggressive.
  • The bot name is clear.
  • The script unloads cleanly.
  • Reloading the script does not create duplicate timers or duplicate notices.

Test with a short interval first, then change it to the production interval.

Example test setting:

interval = 30

After testing, change it back:

interval = 1800

Then reload the script.

Troubleshooting

The Script Does Not Load

Check that the Lua plugin is active:

!pluglist

Check that the file path is correct:

!luaload /PATH/TO/HUB/scripts/auto-topic.lua

Use the absolute path if relative paths do not work.

Notices Do Not Appear

Check:

  • The Lua plugin is loaded.
  • The script path is correct.
  • Your Verlihub Lua plugin version supports the timer function.
  • The interval is not too high while testing.
  • The notices table contains at least one message.

Temporarily use:

interval = 30

Then reload the script and wait for the next notice.

Notices Appear Too Often

Increase the interval.

interval = 1800

or:

interval = 3600

Avoid short production intervals.

Duplicate Notices Appear

This usually means the script was loaded more than once or an old instance did not unload correctly.

Unload the script:

!luaunload /PATH/TO/HUB/scripts/auto-topic.lua

Then load it again:

!luaload /PATH/TO/HUB/scripts/auto-topic.lua

If duplicates continue, restart the Lua plugin or the Verlihub service during a maintenance window.

Script Errors After Editing Notices

Check Lua syntax. Each notice line should end with a comma except the last line, which may omit it.

Correct:

notices = {
    "First notice.",
    "Second notice.",
    "Third notice."
}

Incorrect:

notices = {
    "First notice."
    "Second notice."
}

The incorrect example is missing a comma after the first message.

Safety Notes

This script should stay lightweight. Do not add:

  • External HTTP requests.
  • Database queries.
  • File scanning.
  • Long loops.
  • Blocking sleep calls.
  • Per-user heavy processing.

The script should only rotate configured notices and send them at a reasonable interval.

Maintenance Notes

Keep a backup before changing the script:

cp /PATH/TO/HUB/scripts/auto-topic.lua /PATH/TO/HUB/scripts/auto-topic.lua.bak

If using Git:

cd /PATH/TO/HUB/scripts
git add auto-topic.lua
git commit -m "Update auto-topic.lua notices"

When changing only the bot name, notices, or interval, no logic changes are required.

Suggested Notice Writing Rules

Good notices are short and useful.

Recommended:

  • One idea per notice.
  • Clear wording.
  • No repeated punctuation.
  • No all-caps messages.
  • No overly frequent posting.
  • No long paragraphs in main chat.

Avoid:

  • Posting every few seconds.
  • Posting the same message repeatedly.
  • Using notices only as advertisements.
  • Sending large rule blocks to main chat.
  • Interrupting active conversations too often.

Parent Page