const { RouterOSClient } = require('routeros-client');

async function test() {
  const host = "sg-6.hostddns.us";
  const port = 47808;
  const user = "mymikrobil";
  const pass = "241020";

  try {
    const client = new RouterOSClient({
      host: host,
      port: port,
      user: user,
      password: pass,
      timeout: 10,
      keepalive: false
    });
    await client.connect();
    console.log("Connected!");

    const users = await client.api().menu("/ip/hotspot/user").get();
    console.log(`Total users: ${users.length}`);

    const wifiUsers = users.filter(u => {
      const name = String(u.name || "");
      return name.startsWith("wifi_") || name.startsWith("WA_") || name.startsWith("ag_");
    });
    console.log(`Matching users (wifi_ or WA_ or ag_): ${wifiUsers.length}`);
    wifiUsers.forEach(u => {
      console.log(` - Name: ${u.name}, Profile: ${u.profile}, Comment: ${u.comment}`);
    });

    await client.close();
  } catch (err) {
    console.log("Error:", err.message);
  }
}

test();
