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: Auto invites revisited  (Read 2734 times)

0 Members and 1 Guest are viewing this topic.

Offline Xenixa

  • Contributor
  • *******
  • Posts: 307
  • Karma: +0/-0
Auto invites revisited
« on: December 12, 2005, 10:44:17 pm »
So for the last month I have been sitting here playing with (and some times banging my head on the desk) a way to get auto invites to work correctly.

So what did I discover? Well I discovered Guests only got invited one time and one time only. That would be the first time the bot see's them. Why do they never get another Invite to the private channel was my question. It never occured to me that someone would in Bot.php do this:
Code: [Select]
if (!$mem)
      $end = " (not member)";
else if ($mem == 2)
$end = " (guest)";
if (!$mem || ($mem == 2))
$this -> aoc -> buddy_remove($user);

if ($this -> is_member($name) != 1)
        $this -> aoc -> buddy_remove($name);
So just to make this clear, as long as the Bot adds Buddies when a Guild member adds a Guest to the bot, the code piece above will never let any module Auto invite Guests to Private chat channel. They keep getting removed as buddies!!
<<< Hack's in Zend Studio

All my Custom Bebot files may be Found Here <-clicky

Offline Xenixa

  • Contributor
  • *******
  • Posts: 307
  • Karma: +0/-0
Re: Auto invites revisited
« Reply #1 on: December 13, 2005, 12:36:31 am »
On a Related note, the is_member function will never work as written in the SVN version of Bot.php to eval if they are a Member or a Guest.
This will not work:
Code: [Select]
<?
function is_member($uname)
{
$result = $this -> db -> select("SELECT nickname FROM members WHERE id = " . $this -> aoc -> get_uid($uname));
if (!empty($result))
return 1;

$result = $this -> db -> select("SELECT id FROM guests WHERE id = " . $this -> aoc -> get_uid($uname));
if (!empty($result))
return 2;

return false;
}
?>
I'll explain why. Return can't be used conditionally like that. When PHP encounters a Return it forces the Function to exit with the value set. So in the code above guess what will always be returned? If you guessed 1 or NOTHING(Null) you would be correct.
My suggestion would be to do something like this:
Code: [Select]
    function is_member($uname)
    {
if ($uid = $this -> aoc -> get_uid($uname))
{
$result = $this -> db -> select("SELECT nickname FROM members WHERE id = " . $uid);
    if (!empty($result))
        return 1;   
else
$result = $this -> db -> select("SELECT id FROM guests WHERE id = " . $uid);
      if (!empty($result))
      return 2;     
else
      return false;
}
    }
The above works for me and doesn't break the bot in other places were it uses the is_member() function.
« Last Edit: December 13, 2005, 01:06:10 pm by Xenixa »
<<< Hack's in Zend Studio

All my Custom Bebot files may be Found Here <-clicky

Offline Khalem

  • BeBot Founder
  • Administrator
  • ********
  • Posts: 1169
  • Karma: +0/-0
    • http://www.ancarim.com
Re: Auto invites revisited
« Reply #2 on: December 13, 2005, 01:24:29 am »
Blondengy wrote the checks, and i assume it was done this way to keep guests from generating logon/login notices.

Its essentially a part of the entire rooster cleanup id like to do where the members table contains everyone with access, guest or member, and then use flags to signify if they are a guest, if they should generate a login notification, recieve announce and massinvites etc.
BeBot Founder and Fixer Kingpin

Offline Xenixa

  • Contributor
  • *******
  • Posts: 307
  • Karma: +0/-0
Re: Auto invites revisited
« Reply #3 on: December 13, 2005, 09:01:16 am »
Hmmm... well since the function inc_buddy() in Bot.php just outputs to the Log and since it would be nice for Org bots to auto invite Guests automatically as an option(using Autoinv.php), I changed/tweaked the Function a bit to not remove Characters on the Guest Table from the bots buddy list. Will only remove names from the Buddy list if they are not on either the Members or Guest table the next time the bot see's them.
Re-written looks like this:
Code: [Select]
function inc_buddy($args)
{
$user = $this -> aoc -> get_uname($args[0]);

$mem = $this -> is_member($user);

$end = "";
if (!$mem)
{
$end = " (not member)";
}
else if ($mem == 2)
{
$end = " (guest)";
}

if ($this -> is_member($name) != 1)
$this -> aoc -> buddy_remove($name);

$this -> log("BUDDY", "LOG", $user . " logged [" . (($args[1] == 1) ? "on" : "off") . "]" . $end);

if (!empty($this -> commands["buddy"]))
{
$keys = array_keys($this -> commands["buddy"]);
foreach ($keys as $key)
$this -> commands["buddy"][$key] -> buddy($user, $args[1]);
}
}
This assumes you're using the modified is_member() I have above since the original would never return a 2.

The generation of logon/login notices is handled by Logon_GUILD.php which uses it's own Funtion to see if they are a Member. Players on Guests list aren't announced unless you've done like I have in Relay_GUILD.php and have it only announce when they actually Join the Private channel rather then when they logon. Which IMHO is the better solution... Untill that 1000 character Buddy list limitation is hit anyway.

Guess this means I'll have to re-write autoinv.php also so it can be set via ingame to auto invite either Members, Guests, Both or Off rather than just On or Off. :)
« Last Edit: December 13, 2005, 01:16:03 pm by Xenixa »
<<< Hack's in Zend Studio

All my Custom Bebot files may be Found Here <-clicky

Offline Oneforderoad

  • BeBot Rookie
  • *
  • Posts: 4
  • Karma: +0/-0
Re: Auto invites revisited
« Reply #4 on: December 14, 2005, 12:58:03 pm »
pardon me for sticking in my 2 cents worth but:

 function is_member($uname)
    {
   if ($uid = $this -> aoc -> get_uid($uname))

shouldnt that be
      if ($uid  == $this -> aoc -> get_uid($uname))


Offline Alreadythere

  • BeBot Maintainer
  • BeBot Hero
  • ******
  • Posts: 1288
  • Karma: +0/-0
Re: Auto invites revisited
« Reply #5 on: December 14, 2005, 01:18:14 pm »
pardon me for sticking in my 2 cents worth but:

 function is_member($uname)
    {
   if ($uid = $this -> aoc -> get_uid($uname))

shouldnt that be
      if ($uid  == $this -> aoc -> get_uid($uname))


No. It's ugly C tradition, but you actually are allowed to set variables in if () checks - then the value of the variable is the comparator.

Offline Xenixa

  • Contributor
  • *******
  • Posts: 307
  • Karma: +0/-0
Re: Auto invites revisited
« Reply #6 on: December 14, 2005, 01:35:23 pm »
Yup, and since the Value of the comparitor($uid) in the condition check remains the same through each step, it relies on the inner/sub condition check to move the comparitive pointer down the list.

This can also be done with a "While" loop in PHP btw. Kinda of a dirty trick I did there but PHP's parser handles it well enough. That and I just wanted to show a way to keep Return from exiting the the function before all conditions were checked.   ;D
<<< Hack's in Zend Studio

All my Custom Bebot files may be Found Here <-clicky

Offline Naturalistic

  • Contributor
  • *******
  • Posts: 221
  • Karma: +0/-0
Re: Auto invites revisited
« Reply #7 on: December 15, 2005, 05:34:22 pm »
What that is saying:

Set $uid to be $this -> aoc -> get_uid($uname), when inside the if statement, if that varible is "valid" or a true variable (meaning there is info in that variable)...that makes the If statement true.

Hope that kinda clears things up ;)


You can also have: (but it's faster to do it the first way :P)
...
$uid = $this -> aoc -> get_uid($uname);
if ($uid)
{
  blah blah;
}
...
220/25 Eternalist Doctor
-----------------------------
Campalot Coding Co-ordinator and Super Admin
http://www.campalot.info/index.php

Offline Khalem

  • BeBot Founder
  • Administrator
  • ********
  • Posts: 1169
  • Karma: +0/-0
    • http://www.ancarim.com
Re: Auto invites revisited
« Reply #8 on: December 15, 2005, 07:39:08 pm »
Once i do my member table changes, is_member will be rewritten to work properly anyways. *kicks is_member*
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: 487
  • 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