collapse collapse
* User Info
 
 
Welcome, Guest. Please login or register.
* Search

* Board Stats
  • stats Total Members: 989
  • stats Total Posts: 18363
  • stats Total Topics: 2500
  • stats Total Categories: 7
  • stats Total Boards: 35
  • stats Most Online: 1144

Author Topic: modified alts  (Read 22675 times)

0 Members and 1 Guest are viewing this topic.

Offline jjones666

  • Contributor
  • *******
  • Posts: 353
  • Karma: +0/-0
Re: modified alts
« Reply #15 on: August 18, 2006, 08:16:03 am »
Be careful using the latest Bebot SVN code with any modules you find on here - a lot of modules here are designed for the Bebot 2.x member table setup etc and simply will not work with the SVN version.

I'm waiting for Khalem to give the green light on 3.x before updating anything (currently using 2.x SVN from around December last year with a few additions and a lot of modules from these pages and have a rock solid stable bot).

Cheers,

-jj-

Offline Dabaron

  • BeBot Apprentice
  • ***
  • Posts: 163
  • Karma: +0/-0
Re: modified alts
« Reply #16 on: August 18, 2006, 08:39:56 am »
I'm not using SVN code, I'm still in the .2 series not the .3 series   ;)

Offline Naturalistic

  • Contributor
  • *******
  • Posts: 221
  • Karma: +0/-0
Re: modified alts
« Reply #17 on: August 18, 2006, 05:53:18 pm »
Sucks for me, as I started with Bebot 0.2.3 and just re-coded a lot of it. Now, not possible to svn update it :P
220/25 Eternalist Doctor
-----------------------------
Campalot Coding Co-ordinator and Super Admin
http://www.campalot.info/index.php

Offline jjones666

  • Contributor
  • *******
  • Posts: 353
  • Karma: +0/-0
Re: modified alts
« Reply #18 on: August 18, 2006, 06:54:02 pm »
Same Naturalistic, damn Xenixa and the other community people for making so many useful mods :-)

Offline Dabaron

  • BeBot Apprentice
  • ***
  • Posts: 163
  • Karma: +0/-0
Re: modified alts
« Reply #19 on: August 18, 2006, 07:27:45 pm »
Any idea whats causing my error though?  I'm not SVN'd so no clue what it could be.

Offline Khalem

  • BeBot Founder
  • Administrator
  • ********
  • Posts: 1169
  • Karma: +0/-0
    • http://www.ancarim.com
Re: modified alts
« Reply #20 on: August 18, 2006, 10:48:52 pm »
Xen's site appears to be down so i can't look at the source code.

However the error you are getting indicates a missing error check on the MySQL return. It's very common to see this error when the code is not written to handle the event of no return values from the MySQL query, or plain simply a MySQL error.
BeBot Founder and Fixer Kingpin

Offline Dabaron

  • BeBot Apprentice
  • ***
  • Posts: 163
  • Karma: +0/-0
Re: modified alts
« Reply #21 on: August 19, 2006, 02:12:29 am »
Here is her code for it.

Code: [Select]
<?
  /*
   * Alts.php - Alternative character management
   *
   * 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.
   *
   * File last changed at $LastChangedDate: 2004-12-29 01:41:32 +0100 (Wed, 29 Dec 2004) $
   * Revision: $Id: Alts.php 8 2004-12-29 00:41:32Z blondengy $
   *
   * Added altadmin command by Akarah
   * Cleaned up Info view of alts - Xenixa
   */

  /*
  Prepare MySQL database
  */
  $db -> query("CREATE TABLE IF NOT EXISTS alts
        (alt VARCHAR(255) NOT NULL PRIMARY KEY,
        main VARCHAR(255))");



  $alts = new Alts($bot);

  $commands["tell"]["alts"] = &$alts;
  $commands["pgmsg"]["alts"] = &$alts;
  $commands["gc"]["alts"] = &$alts;
  $commands["tell"]["altadmin"] = &$alts;



  /*
    The Class itself...
  */
  class Alts
  {
    var $bot;


    /*
      Constructor:
        Hands over a referance to the "Bot" class.
    */
    function Alts (&$bot)
    {
      $this -> bot = &$bot;
      $this -> bot -> alts = &$this;
      $this -> date_format = 'M j, Y';
    }



    /*
      This gets called on a tell with the command
    */
    function tell($name, $msg)
    {
      if (preg_match("/^" . $this -> bot -> commpre . "alts add (.+)$/i", $msg, $info))
        $this -> bot -> send_tell($name, $this -> add_alt($name, $info[1]));
      else if (preg_match("/^" . $this -> bot -> commpre . "alts (rem|del) (.+)$/i", $msg, $info))
        $this -> bot -> send_tell($name, $this -> remove_alt($name, $info[2]));
      else if (preg_match("/^" . $this -> bot -> commpre . "alts (.+)$/i", $msg, $info))
        $this -> bot -> send_tell($name, $this -> show_alt($name, $info[1]));
      else if (preg_match("/^" . $this -> bot -> commpre . "alts$/i", $msg))
        $this -> bot -> send_tell($name, $this -> show_alt($name, $name));
      else if (preg_match("/^" . $this -> bot -> commpre . "altadmin add ([a-zA-Z0-9]+) ([a-zA-Z0-9]+)$/i", $msg, $info))
        $this -> bot -> send_tell($name, $this -> add_altadmin($info[1], $info[2]));
      else if (preg_match("/^" . $this -> bot -> commpre . "altadmin (rem|del) ([a-zA-Z0-9]+) ([a-zA-Z0-9]+)$/i", $msg, $info))
        $this -> bot -> send_tell($name, $this -> remove_altadmin($info[2], $info[3]));
      else
      $this -> bot -> send_help($name);
    }



    /*
      This gets called on a msg in the privgroup with the command
    */
    function pgmsg($name, $msg)
    {
      if (preg_match("/^" . $this -> bot -> commpre . "alts add (.+)$/i", $msg, $info))
        $this -> bot -> send_pgroup($this -> add_alt($name, $info[1]));
      else if (preg_match("/^" . $this -> bot -> commpre . "alts (rem|del) (.+)$/i", $msg, $info))
        $this -> bot -> send_pgroup($this -> remove_alt($name, $info[2]));
      else if (preg_match("/^" . $this -> bot -> commpre . "alts (.+)$/i", $msg, $info))
        $this -> bot -> send_pgroup($this -> show_alt($name, $info[1]));
      else if (preg_match("/^" . $this -> bot -> commpre . "alts$/i", $msg))
        $this -> bot -> send_pgroup($this -> show_alt($name, $name));
    }



    /*
      This gets called on a msg in the guildchat with the command
    */
    function gc($name, $msg)
    {
      if (preg_match("/^" . $this -> bot -> commpre . "alts add (.+)$/i", $msg, $info))
        $this -> bot -> send_gc($this -> add_alt($name, $info[1]));
      else if (preg_match("/^" . $this -> bot -> commpre . "alts (rem|del) (.+)$/i", $msg, $info))
        $this -> bot -> send_gc($this -> remove_alt($name, $info[2]));
      else if (preg_match("/^" . $this -> bot -> commpre . "alts (.+)$/i", $msg, $info))
        $this -> bot -> send_gc($this -> show_alt($name, $info[1]));
      else if (preg_match("/^" . $this -> bot -> commpre . "alts$/i", $msg))
        $this -> bot -> send_gc($this -> show_alt($name, $name));
    }


    /*
      Add an alt to your list.
    */
    function add_alt($name, $alt)
    {
      if (!$this -> bot -> aoc -> get_uid($alt))
        return "Character <font color=#ffff00>" . $alt . "</font> does not exist.";
      else
      {
        $result = $this -> bot -> db -> select("SELECT main FROM alts WHERE alt = '" . ucfirst(strtolower($name)) . "'");
        $result2 = $this -> bot -> db -> select("SELECT main FROM alts WHERE alt = '" . ucfirst(strtolower($alt)) . "' OR main = '" . ucfirst(strtolower($alt)) . "'");
        if (!empty($result))
          return "You are registered as an alt of <font color=#ffff00>" . $result[0][0] . "</font> and cannot register alts to yourself.";
        else if (!empty($result2))
          return "<font color=#ffff00>" . $alt . "</font> already exists in the database.";
        else
        {
          $this -> bot -> db -> query("INSERT INTO alts (alt, main) VALUES
                                      ('" . ucfirst(strtolower($alt)) . "', '" . ucfirst(strtolower($name)) . "')");
          return "<font color=#ffff00>" . $alt . "</font> has been registered as your new alt.";
        }
      }
    }


    function add_altadmin($main, $alt)
    {
    if ((!$this -> bot -> aoc -> get_uid($alt)) || (!$this -> bot -> aoc -> get_uid($main)))
    return "Character <font color=#ffff00>" . $main . "</font> or <font color=#ffff00>" . $alt . "</font> does not exist.";
    else
    {
    $result = $this -> bot -> db -> select("SELECT main FROM alts WHERE alt = '" . ucfirst(strtolower($main)) . "'");
    $result2 = $this -> bot -> db -> select("SELECT main FROM alts WHERE alt = '" . ucfirst(strtolower($alt)) . "' OR main = '" . ucfirst(strtolower($alt)) . "'");
    if (!empty($result))
    return "<font color=#ffff00>" . $main . "</font> is registered as an alt of <font color=#ffff00>" . $result[0][0] . "</font> and cannot have alts registered to it.";
    else if (!empty($result2))
    return "<font color=#ffff00>" . $alt . "</font> already exists in the database.";
    else
    {
    $this -> bot -> db -> query("INSERT INTO alts (alt, main) VALUES
                                  ('" . ucfirst(strtolower($alt)) . "', '" . ucfirst(strtolower($main)) . "')");
    return "<font color=#ffff00>" . $alt . "</font> has been registered to <font color=#ffff00>" . $main . "</font>.";
    }
    }
    }


    /*
      Remove an alt from your list.
    */
    function remove_alt($name, $alt)
    {
      if (!$this -> bot -> aoc -> get_uid($alt))
        return "Character <font color=#ffff00>" . $alt . "</font> does not exist.";
      else
      {
        $result = $this -> bot -> db -> select("SELECT main FROM alts WHERE alt = '" . ucfirst(strtolower($alt)) . "' AND main = '" . ucfirst(strtolower($name)) . "'");
        if (empty($result))
          return "<font color=#ffff00>" . $alt . "</font> is not registered as your alt.";
        else
        {
          $this -> bot -> db -> query("DELETE FROM alts WHERE alt = '" . ucfirst(strtolower($alt)) . "'");
          return "<font color=#ffff00>" . $alt . "</font> has been removed as your alt.";
        }
      }
    }


function remove_altadmin($main, $alt)
{
if ((!$this -> bot -> aoc -> get_uid($alt)) || (!$this -> bot -> aoc -> get_uid($main)))
return "Character <font color=#ffff00>" . $main . "</font> or <font color=#ffff00>" . $alt . "</font> does not exist.";
else
{
$result = $this -> bot -> db -> select("SELECT main FROM alts WHERE alt = '" . ucfirst(strtolower($alt)) . "' AND main = '" . ucfirst(strtolower($main)) . "'");
if (empty($result))
return "<font color=#ffff00>" . $alt . "</font> is not registered to <font color=#ffff00>" . $main . "</font>.";
else
{
$this -> bot -> db -> query("DELETE FROM alts WHERE alt = '" . ucfirst(strtolower($alt)) . "'");
return "<font color=#ffff00>" . $alt . "</font> has been removed from the database.";
}
}
}


    /*
      Show mains/alts
    */
    function show_alt($name, $who)
    {
      $main = $this -> main($who);
      $alts = $this -> get_alts($main);
      return $main . "'s alts: " . $this -> make_alt_blob($main, $alts);
    }



    /*
      Return main char
    */
    function make_alt_blob($main, $alts)
    {
      $who = $this -> bot -> whois -> lookup($main);
      $mainlog = $this -> bot -> db -> select("SELECT nickname, lastseen FROM members WHERE nickname = '$main'");
  if ($mainlog[0][1] == 0) $date_m = "This Bot hasn't Seen this character online.";
      else $date_m = gmdate($this -> date_format, $mainlog[0][1]);
      $result = "<font color=CCInfoHeadline>::: ".$who['firstname']." \"$main\" ".$who['lastname']." :::</font>\n\n";
      $result .= "• Level/AL: <font color=CCCCTextColor>".$who['level']." / <font color=#33FF33>".$who['at_name']."(".$who['at'].")</font></font>\n";
      $result .= "• Breed: <font color=CCCCTextColor>".$who['breed']."</font>\n";
      $result .= "• Gender: <font color=CCCCTextColor>".$who['gender']."</font>\n";
      $result .= "• Profession: <font color=CCCCTextColor>".$who['profession']."</font>\n";
      $result .= "• Org Rank: <font color=CCCCTextColor>".$who['rank']."</font>\n\n";
      $result .= "Last Login/out: <font color=#0099FF>$date_m</font>\n\n";
      $result .= "<font color=CCInfoHeadline>::: " . $main . "'s Alts :::</font>\n";
      $result .= "----------------------------------\n";
      if (!empty($alts))
        foreach ($alts as $alt)
        {
          $whoalt = $this -> bot -> db -> select("SELECT nickname, rank_name, lastseen FROM members WHERE nickname = '$alt'");
          if ($whoalt[0][2] == 0) $date = "Never";
          else $date = gmdate($this -> date_format, $whoalt[0][2]);
          if (empty($whoalt[0][0])) $rank = "None";
          else $rank = $whoalt[0][1];
          $result .= "• <font color=CCCCTextColor><a href='chatcmd:///tell <botname> <pre>whois $alt'>$alt</a></font>";
          $result .= " (".$rank.") <font color=#0099FF>Last Seen: $date</font>\n";
        }
      else
        return "No alts found.";
      return $this -> bot -> make_blob("View Alts", $result);
    }



    /*
      Return main char
    */
    function main($char)
    {
    $char = $this -> bot -> aoc -> get_uname($char);
      $result = $this -> bot -> db -> select("SELECT main FROM alts WHERE alt = '" . ucfirst(strtolower($char)) . "'");
      if (empty($result))
        return ucfirst(strtolower($char));
      else
        return $result[0][0];
    }



    /*
      Return array of alts
    */
    function get_alts($char)
    {
    $char = $this -> bot -> aoc -> get_uname($char);
      $result = $this -> bot -> db -> select("SELECT alt FROM alts WHERE main = '" . ucfirst(strtolower($char)) . "' ORDER BY alt ASC");
      $ret = array();

      if (!empty($result))
        foreach ($result as $res)
          $ret[] = $res[0];

      return $ret;
    }
  }
?>

Offline Khalem

  • BeBot Founder
  • Administrator
  • ********
  • Posts: 1169
  • Karma: +0/-0
    • http://www.ancarim.com
Re: modified alts
« Reply #22 on: August 19, 2006, 08:05:15 am »
Replace make_alt_blob with the following code:
Code: [Select]
    function make_alt_blob($main, $alts)
    {
  $date = "Never";
  $rank = "None";
      $who = $this -> bot -> whois -> lookup($main);
      $mainlog = $this -> bot -> db -> select("SELECT nickname, lastseen FROM members WHERE nickname = '$main'");
  if ($mainlog[0][1] == 0) $date_m = "This Bot hasn't Seen this character online.";
      else $date_m = gmdate($this -> date_format, $mainlog[0][1]);
      $result = "<font color=CCInfoHeadline>::: ".$who['firstname']." \"$main\" ".$who['lastname']." :::</font>\n\n";
      $result .= "• Level/AL: <font color=CCCCTextColor>".$who['level']." / <font color=#33FF33>".$who['at_name']."(".$who['at'].")</font></font>\n";
      $result .= "• Breed: <font color=CCCCTextColor>".$who['breed']."</font>\n";
      $result .= "• Gender: <font color=CCCCTextColor>".$who['gender']."</font>\n";
      $result .= "• Profession: <font color=CCCCTextColor>".$who['profession']."</font>\n";
      $result .= "• Org Rank: <font color=CCCCTextColor>".$who['rank']."</font>\n\n";
      $result .= "Last Login/out: <font color=#0099FF>$date_m</font>\n\n";
      $result .= "<font color=CCInfoHeadline>::: " . $main . "'s Alts :::</font>\n";
      $result .= "----------------------------------\n";
      if (!empty($alts))
        foreach ($alts as $alt)
        {
          $whoalt = $this -> bot -> db -> select("SELECT nickname, rank_name, lastseen FROM members WHERE nickname = '$alt'");
  if (!empty($whoalt))
  {
if ($whoalt[0][2] == 0) $date = "Never";
else $date = gmdate($this -> date_format, $whoalt[0][2]);
if (empty($whoalt[0][0])) $rank = "None";
else $rank = $whoalt[0][1];
  }
          $result .= "• <font color=CCCCTextColor><a href='chatcmd:///tell <botname> <pre>whois $alt'>$alt</a></font>";
          $result .= " (".$rank.") <font color=#0099FF>Last Seen: $date</font>\n";
        }
      else
        return "No alts found.";
      return $this -> bot -> make_blob("View Alts", $result);
    }
BeBot Founder and Fixer Kingpin

Offline Ainen

  • BeBot User
  • **
  • Posts: 22
  • Karma: +0/-0
Re: modified alts
« Reply #23 on: August 19, 2006, 06:29:41 pm »
I tried to plug that fix into the given alts.php on my bot and got this:
PHP Fatal error:  Call to a member function on a non-object in /home/pcm/BeBot3/core/Alts.php on line 218

This being the guilty line in function make_alt_blob:
$who = $this -> bot -> whois -> lookup($main);
BeBot 0.3.4 svn 91 // PHP 4.3.9 // MySQL 4.1.12

Offline Dabaron

  • BeBot Apprentice
  • ***
  • Posts: 163
  • Karma: +0/-0
Re: modified alts
« Reply #24 on: August 20, 2006, 01:10:03 am »
Do you have the WhoisCache thing setup?  Your error looks like it has to do with a reference to that.  Instead of doing a direct query to FC servers to get the data it checks your MySQL server first.  Without that setup it can't do that.

And I'll try the mod that you suggested Khalem and let you guys know how it goes.
« Last Edit: August 20, 2006, 01:13:40 am by Dabaron »

Offline Dabaron

  • BeBot Apprentice
  • ***
  • Posts: 163
  • Karma: +0/-0
Re: modified alts
« Reply #25 on: August 20, 2006, 10:27:21 am »
Worked like a charm... just don't make teh mistake of trying to lookup an alt of someone that isn't a member or it still dies.  No biggie though.

Offline Khalem

  • BeBot Founder
  • Administrator
  • ********
  • Posts: 1169
  • Karma: +0/-0
    • http://www.ancarim.com
Re: modified alts
« Reply #26 on: August 20, 2006, 11:59:19 am »
Code: [Select]
      $mainlog = $this -> bot -> db -> select("SELECT nickname, lastseen FROM members WHERE nickname = '$main'");
  if ($mainlog[0][1] == 0) $date_m = "This Bot hasn't Seen this character online.";
      else $date_m = gmdate($this -> date_format, $mainlog[0][1]);

Change to:

Code: [Select]
      $date_m = "This Bot hasn't Seen this character online.";
      $mainlog = $this -> bot -> db -> select("SELECT nickname, lastseen FROM members WHERE nickname = '$main'");
      if (!empty($mainlog[0][1]))
      {
         if ($mainlog[0][1] != 0)
         {
            $date_m = gmdate($this -> date_format, $mainlog[0][1]);
          }
       }
« Last Edit: August 20, 2006, 12:01:17 pm by Khalem »
BeBot Founder and Fixer Kingpin

Offline Dabaron

  • BeBot Apprentice
  • ***
  • Posts: 163
  • Karma: +0/-0
Re: modified alts
« Reply #27 on: August 21, 2006, 09:57:48 am »
Very cool, works perfectly now.   Thanks Khalem.  One last question, anyone know how to get this to show in the logon announcement (the alts part) and have it use this modified version?

Offline Dabaron

  • BeBot Apprentice
  • ***
  • Posts: 163
  • Karma: +0/-0
Re: modified alts
« Reply #28 on: August 22, 2006, 01:56:57 am »
Ok, I was wrong... that only semi-fixed it.  Now it does say that there are no alts found if its a non-org member, but if I do an alts on someone that is in org but has an alt that has never been seen it crashes it with:
Fatal error: Cannot use string offset in array in C:\BeBot\Beerraid\core\Alts.php on line 239

As far as the alts thing I have it semi-figured out.  I can get it to show the "Alts" in the string but it isn't clickable.  Been trying to compare with code in the Online.php module but just can't quite get it working.
« Last Edit: August 22, 2006, 02:42:22 am by Dabaron »

Offline Khalem

  • BeBot Founder
  • Administrator
  • ********
  • Posts: 1169
  • Karma: +0/-0
    • http://www.ancarim.com
Re: modified alts
« Reply #29 on: August 22, 2006, 05:51:03 am »
Could you post line 239 in your version along with a few lines of code leading up to and following line 239?
BeBot Founder and Fixer Kingpin

 

* Recent Posts
[AoC] special char for items module by bitnykk
[February 09, 2024, 09:41:18 pm]


0.8.x updates for AoC by bitnykk
[January 30, 2024, 11:16:08 pm]


0.8.x updates for AO by bitnykk
[January 30, 2024, 11:15:37 pm]


BeBot still alive & kicking ! by bitnykk
[December 17, 2023, 12:58:44 am]


Bebot and Rasberry by bitnykk
[November 29, 2023, 11:04:14 pm]

* Who's Online
  • Dot Guests: 686
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.
* Forum Staff
bitnykk admin bitnykk
Administrator
Khalem admin Khalem
Administrator
WeZoN gmod WeZoN
Global Moderator
SimplePortal 2.3.7 © 2008-2024, SimplePortal