Archive > 0.2.x Custom/Unofficial Modules

Guild Raidbot

(1/2) > >>

Sojourner:
This module may be handy if you use the bot for your orgs AI raid bot.  It will go through the org member list and anyone that is high enough to work the city CC automatically gets added to the bots member list.

Basically a modified version of the rooster_GUILD.php file

Note that in order for it to work, you will need to add your guilds ID number to the Bot.conf file.

ForGuildRaidBot.php

Derroylo:
sry a bit confused atm for what do you need such a module?

nothing against your work just wondering :)

Sojourner:
We use the bot for our AI raids

We want everyone who is high enough in the org leadership to be able to drop the City cloak to also automatically be a member in the bot so that they can use it if they are organizing a raid.

It doesn't auto-invite or anything like that.  Just sits silent like a raid bot.  But, anyone in the org who can run the CC is automatically a member, so the bot will listen to them.

That way, they are not dependent on 3 or 4 bot admins to be online if they want to run a raid and use the bot.

I'm tempted to change the code to make them bot admins instead of just members.  Not entirely sure what what admins have access to that members don't.

Shelly:
We use our bot as just a raid bot also and liked your's and Xenixa's code so I added functions into your code based on Xenixa's post to capture the AI levels and auto populate the bot admin and bot raidleaders tables based on the org level of a member and also made it so any org member is added to the raid bot as a member.

I am sorry I don't have a way to upload a text copy to download. :oops:

Shelly


--- Quote from: "Sojourner" ---This module may be handy if you use the bot for your orgs AI raid bot.  It will go through the org member list and anyone that is high enough to work the city CC automatically gets added to the bots member list.

Basically a modified version of the rooster_GUILD.php file

Note that in order for it to work, you will need to add your guilds ID number to the Bot.conf file.

ForGuildRaidBot.php
--- End quote ---



--- Code: ---
ForGuildRaidBot.php
<?
  /*
   * ForGuildRaidBot.php - To automatically add guild leaders to the raidbot's member list
   * By Sojon (RK2), based off the rooster_GUILD.php file by Blondeny
   *
   * NOTE: Normally if you run your bot as a raid bot, you do not need your org's id # in the
   * Bot.conf file, but for this module you do.
   *
   * File last changed at $LastChangedDate: 2005-08-28 09:10:00 -0500 (Sun, 28 Aug 2005) $
   * Revision: $Id: ForGuildRaidBot.php 1 2005-08-28 09:10:00 sojon $
   *
   *
   * BeBot - An Anarchy Online Chat Automaton
   * Copyright (C) 2004 Jonas Jax
   *
   * Developed by Blondengy (RK1)
   * Special thanks goes out to Khalem (RK1) for his support.
   *
   */


  /* Prepare MySQL database  */
  $db -> query("CREATE TABLE IF NOT EXISTS members
              (id INT NOT NULL PRIMARY KEY,
              nickname VARCHAR(25),
              firstname VARCHAR(25),
              lastname VARCHAR(25),
              rank TINYINT,
              rank_name VARCHAR(20),
              level INT,
              profession VARCHAR(15),
              gender VARCHAR(10),
              breed VARCHAR(10),
              ai_rank_id INT,
              ai_rank VARCHAR(15),
              pic VARCHAR(100),
              lvlrange VARCHAR(10))");

  $db -> query("CREATE TABLE IF NOT EXISTS admin_groups
             (id int(11) NOT NULL auto_increment,
              name varchar(35) default NULL,
               PRIMARY KEY  (id),
               UNIQUE KEY name (name)
             ) TYPE=MyISAM AUTO_INCREMENT=4" );

  $db -> query("INSERT INTO admin_groups (id, name)
             VALUES (2, admin)");
  $db -> query("INSERT INTO admin_groups (id, name)
             VALUES (1, superadmin)");
  $db -> query("INSERT INTO admin_groups (id, name)
             VALUES (3, raidleader)");

  $db -> query("CREATE TABLE IF NOT EXISTS admin_members
            (name varchar(50) default NULL,
             admin_group int(11) default NULL
            ) TYPE=MyISAM");

  $roster = new Roster($bot);

  $cron["12hour"][] = &$roster;


  /* The Class itself... */
  class Roster
  {
    var $bot;
   
    /* Constructor: Hands over a referance to the "Bot" and "MySQL" class. */
    function Roster (&$bot)
    {
      $this -> bot = &$bot;
    }

    /* This gets called on cron */
    function cron()
    {
      $this -> bot -> log("ROSTER", "UPDATE", "Starting roster update");
      // Get the guild roster from the anarchy website
      $org = $this -> bot -> get_site("http://community.anarchy-online.com/org/stats/d/" . $this -> bot -> dimension . "/name/" . $t
his -> bot -> guildid . "/basicstats.xml");
      $org = explode("<member>", $org);
     
      // Parse members
      for ($i = 1; $i < count($org); $i++)
      {
        $members[($i - 1)]["nickname"] = $this -> bot -> xmlparse($org[$i], "nickname");
        $members[($i - 1)]["firstname"] = $this -> bot -> xmlparse($org[$i], "firstname");
        $members[($i - 1)]["lastname"] = $this -> bot -> xmlparse($org[$i], "lastname");
        $members[($i - 1)]["rank"] = $this -> bot -> xmlparse($org[$i], "rank");
        $members[($i - 1)]["rank_name"] = $this -> bot -> xmlparse($org[$i], "rank_name");
        $members[($i - 1)]["level"] = $this -> bot -> xmlparse($org[$i], "level");
        $members[($i - 1)]["profession"] = $this -> bot -> xmlparse($org[$i], "profession");
        $members[($i - 1)]["gender"] = $this -> bot -> xmlparse($org[$i], "gender");
        $members[($i - 1)]["breed"] = $this -> bot -> xmlparse($org[$i], "breed");
        $members[($i - 1)]["ai_rank_id"] = $this -> bot -> xmlparse($org[$i], "defender_rank_id");
        $members[($i - 1)]["ai_rank"] = $this -> bot -> xmlparse($org[$i], "defender_rank");
        $members[($i - 1)]["pic"] = $this -> bot -> xmlparse($org[$i], "photo_url");
        $members[($i - 1)]["id"] = $this -> bot -> aoc -> get_uid($members[($i - 1)]["nickname"]);

        if (($members[($i - 1)]["level"] >= 1) && ($members[($i - 1)]["level"] <= 99))
          $members[($i - 1)]["lvlrange"] = "1-99";
        else if (($members[($i - 1)]["level"] >= 100) && ($members[($i - 1)]["level"] <= 149))
          $members[($i - 1)]["lvlrange"] = "100-149";
        else if (($members[($i - 1)]["level"] >= 150) && ($members[($i - 1)]["level"] <= 199))
          $members[($i - 1)]["lvlrange"] = "150-199";
        else if (($members[($i - 1)]["level"] >= 200) && ($members[($i - 1)]["level"] <= 214))
          $members[($i - 1)]["lvlrange"] = "200-214";
        else if (($members[($i - 1)]["level"] >= 215) && ($members[($i - 1)]["level"] <= 220))
          $members[($i - 1)]["lvlrange"] = "215-220";
        else
          $members[($i - 1)]["lvlrange"] = "unknown";

        if ($members[($i - 1)]["nickname"] == ucfirst(strtolower($this -> bot -> botname)))
          unset($members[($i - 1)]);
        if ($members[($i - 1)]["nickname"] == "Ailbot")                                           // TEMP HACK!!
          unset($members[($i - 1)]);                                                              // TEMP HACK!!
      }
     
      // Update roster if there are more then 1 people on it.
      if (count($members) > 1)
      {
        $buds = $this -> bot -> aoc -> buddies;
        $added = 0;
        $removed = 0;
         
        foreach ($members as $memb)
        {
          // If the member is an org member (top 4 ranks)
          if($memb["rank"] < 4)
          {
            // Add to buddylist if not yet in there
            if (!$this -> bot -> aoc -> buddy_exists($memb["id"]))
            {
              $this -> bot -> aoc -> buddy_add($memb["id"]);
              $this -> bot -> log("BUDDY", "ADD", $this -> bot -> aoc -> get_uname($memb["id"]));
              $added++;
            }
          }
         
          unset($buds[$memb["id"]]);
         
          $removed = count($buds);
         
          // Remove buddys not on member list...
          foreach ($buds as $id => $value)
          {
            $this -> bot -> aoc -> buddy_remove($id);
            $this -> bot -> log("BUDDY", "DEL", $this -> bot -> aoc -> get_uname($id));
          }
         
          // Remove members that are on buddy list but aren't org leaders
          if($memb["rank"] > 4)
          {
             if($this -> bot -> aoc -> buddy_exists($memb["id"]))
             {
               $this -> bot -> aoc -> buddy_remove($id);
               $this -> bot -> log("BUDDY", "DEL", $this -> bot -> aoc -> get_uname($id));
             }
           }
         }
           
         // Update database...
         $this -> bot -> db -> query("DELETE FROM members");
         foreach ($members as $memb)
         {
           // If they are org top leaders (top 2 ranks) add them to the admin table of the Db
           if($memb["rank"] < 2)
           {
          $this -> bot -> db -> query("INSERT INTO admin_members (name, admin_group)
                      VALUES ('" . $memb["nickname"] . "', '" . 2 . "')");
           }

           // If they are org top leaders (top 3 ranks) add them to the raidleaders table of the Db
           if($memb["rank"] < 3)
           {
          $this -> bot -> db -> query("INSERT INTO admin_members (name, admin_group)
                      VALUES ('" . $memb["nickname"] . "', '" . 3 . "')");
           }

           // If they are org members (top 4 ranks) add them to the member table of the Db
           if($memb["rank"] < 4)
           {
          $this -> bot -> db -> query("INSERT INTO members (id, nickname, firstname, lastname, rank, rank_name, level, profession, g
ender, breed, ai_rank_id, ai_rank, pic, lvlrange)
                      VALUES ('" . $memb["id"] . "',
                              '" . $memb["nickname"] . "', '" . $memb["firstname"] . "',
                              '" . $memb["lastname"] . "', '" . $memb["rank"] . "',
                              '" . $memb["rank_name"] . "', '" . $memb["level"] . "',
                              '" . $memb["profession"] . "', '" . $memb["gender"] . "',
                              '" . $memb["breed"] . "', '" . $memb["ai_rank_id"] . "',
                              '" . $memb["ai_rank"] . "', '" . $memb["pic"] . "',
                              '" . $memb["lvlrange"] . "')");
           }
         }
        $this -> bot -> log("ROSTER", "UPDATE", "Roster update complete. Added $added members, removed $removed.");
      }
    }
  }
?>
--- End code ---

Xenixa:

--- Quote from: "Shelly" ---

--- Code: ---
ForGuildRaidBot.php
<?
        if ($members[($i - 1)]["nickname"] == "Ailbot")                                           // TEMP HACK!!
          unset($members[($i - 1)]);                                                              // TEMP HACK!!
      }

?>
--- End code ---

--- End quote ---


You can safely remove those 2 lines. It was for test purposes I believe.
The piece of code just before it serves the same purpose. I.E. remove the bot from the member list.

Or if you are running more than one bot I suppose you could use it to remove the other bot from the member list also. :)

Navigation

[0] Message Index

[#] Next page

Go to full version