BeBot - An Anarchy Online and Age Of Conan chat automaton

Development => Module Requests => Topic started by: Xenixa on September 02, 2005, 01:45:17 am

Title: Help!! About Auto Invites
Post by: Xenixa on September 02, 2005, 01:45:17 am
Trying to get the auto invites to only invite people on the guest list and not the Members list and the answer is eluding me. Running Bebot as a guildbot.

First I noticed only the players ID number from FC is stored in the Guests table. That don't work so good as a reference for me.

I know the answer is in here:
Code: [Select]
function buddy($name, $msg)
    {
      if (($this -> auto == 1) && ($msg == 1) && ($this -> bot -> is_member($name) == 1))
            $this -> bot -> aoc -> privategroup_invite($name);
    }


I can not find a reference var to people on guest list to use.
Title: Help!! About Auto Invites
Post by: Zacix on September 02, 2005, 02:23:22 am
change to:
Code: [Select]
function buddy($name, $msg)
    {
      if (($this -> auto == 1) && ($msg == 1) && ($this -> bot -> is_member($name) == 2))
            $this -> bot -> aoc -> privategroup_invite($name);
    }


a little late now, but think this should solve it.
Title: Help!! About Auto Invites
Post by: jjones666 on November 18, 2005, 12:37:27 am
Hi Xenixa,

Autoinviting guests would be useful for my bot - currently have a small org set up for a farm city using a guildbot setup.  How can the code above be incorporated into the guildbot?  It was a pain having it turned on as it is current setup as it was just inviting members to the guest chat all the time and not guests :)

Also, Is it possible to get the !massinv feature to work in Guild mode?  This would be useful if it could have a setting also to invite members and guests or just guests (using your script for guestlist too so not sure if this could pull info from there) :-)

Cheers,

-jj-
Title: Help!! About Auto Invites
Post by: Xenixa on November 18, 2005, 02:05:55 pm
Oooh geez... I forgot I had shoved this little trinket on the bottom of the pile, My org and guests have gotten so used to using !join for getting on the bots private channel I hadn't thought about it.

I did however track it down to the function that causes the autoinv function to only invite members and not guests. I just never did anything with it. It's in the core Bot file(bot.php) and it's name is function is_member().
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;
 }

Problem with that function at first glance is it's never given conditions on what to Return. Gunna poke at it with a stick for a little bit and see what comes out.
Title: Help!! About Auto Invites
Post by: krosis on November 20, 2005, 12:49:11 am
I think the main problem you're running into here is the buddy function is called when someone signs onto the bot's friendlist.

Guests are not stored in that list, only members.

You could add people manually but then every roster update it would remove them again ><

I have a bot setup now in guild mode and used your updated Rooster_GUILD module except I noticed you do not have it add people to the bots friend list with your add_member function.

If you used your member function in that module (and make it add them to friend list) and disable the part that removes people from the roster you might get your desired effect.
Title: Help!! About Auto Invites
Post by: Xenixa on November 20, 2005, 09:24:42 am
Naw the problem with auto invite on and it only inviting members is the is_member ($name) function always seems to return false for some reason.

Guests on the guests table are added to the bots buddy list via the Relay_GUILD.php. Problem is the way is_member is determining a guest from a member when called from autoinv.php or any other place its used.

If I'm reading the PHP docs correctly a User defined function using the Return command can only be one value. Normally the last value it was set to inside the function or to point it out the way I read it, it will always return False in the is_member function. But that doesn't tell me why Org Members get auto invited to the privatechannel when they login.
Title: Help!! About Auto Invites
Post by: Xenixa on November 20, 2005, 08:39:14 pm
Ok now that I am more awake and have had some time to look at it, this is what I came up with.
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;
}
    }
Basically I gave it more conditional checking. Haven't tested this yet but it shouldn't break other modules that call is_member from the Bot.php

Oh and as per Zacix post above you would need to make his change he shows to autoinv.php ... basically changing the 1 to a 2 should in theory only auto invite guests using the is_member function I posted here.
Title: Help!! About Auto Invites
Post by: Xenixa on November 20, 2005, 10:32:10 pm
Hmm ok had a chance to test the above function change as written.
Problem: Even with autoinv on not even members or guests get an invite.... *scratch head*

It's doesn't seem to affect anything else though which is good. I'll fiddle with it more later.
Title: Re: Help!! About Auto Invites
Post by: Linachan on March 16, 2006, 09:30:39 pm
it seems as if autoinv still invites members ... nobody working on this anymore?
Title: Re: Help!! About Auto Invites
Post by: Naturalistic on March 16, 2006, 10:16:41 pm
I just did this:

Code: [Select]
function buddy($name, $msg)
{
$result = $this -> bot -> db -> select("SELECT name FROM guests WHERE name = " . $name);
if (($this -> auto == 1) && ($msg == 1) && (!empty($result)))
$this -> bot -> aoc -> privategroup_invite($name);
}

Seems to be working just fine for me :)
Title: Re: Help!! About Auto Invites
Post by: Xenixa on March 17, 2006, 01:03:58 am
I fixed this months ago. Only the changes and fixes were posted in a couple different threads.

Just to recap:
You will need fixes for the Autoinv.php and Relay_GUILD.php which you can find here:
ftp://xen.afraid.org/bebot_files/autoinv_modules.zip

Some notes on these files:
The Relay_GUILD.php uses Alreadythere's Whois cache module.
Autoinv.php uses the fixes to the is_member() function I posted earlier in this thread to work properly.
There are some changes(if you havn't done them yet) to the Guests table to get Autoinv.php to work correctly. Info on those changes are in Relay_GUILD.php
Also you'll want to add 2 functions to Bot.php if yours doesn't have them. (Autoinv.php uses them)
Place these just below the function disconnect()
Code: [Select]
   function get_setting($set)
    {
    $res = $this -> db -> select("SELECT * FROM settings WHERE setting = '" . $set . "'");
    if (!empty($res))
return $res[0][1];
    else
return "";
    }

    function set_setting($set, $value)
{
$this -> db -> query("UPDATE settings SET value = '" . $value . "' WHERE setting = '" . $set . "'");
}
Title: Re: Help!! About Auto Invites
Post by: buff on March 30, 2006, 05:16:47 am
Error Code : 1062
Duplicate entry 'auto_invite' for key 1
(0 ms taken)

got above error msg when i run the bot
Title: Re: Help!! About Auto Invites
Post by: Xenixa on March 30, 2006, 08:46:39 am
Strange, the function AutoInv() I have in that version shouldn't allow that to happen.
Any other errors from the bot other than that? Did you make sure to add the function get_setting() to Bot.php? Only reason I can think it did that is that it couldn't find auto_invite in the settings table and tried to insert it again.
Title: Re: Help!! About Auto Invites
Post by: buff on March 31, 2006, 06:26:01 am
Code: [Select]
/*
        Returns a selected setting:
        */
        function get_setting($set)
    {
    $res = $this -> db -> select("SELECT * FROM settings WHERE setting = '" . $set . "'");
    if (!empty($res))
return $res[0][1];
    else
return "";
    }

    function set_setting($set, $value)
{
$this -> db -> query("UPDATE settings SET value = '" . $value . "' WHERE setting = '" . $set . "'");
}

above is what i have in my bot.php
i also noticed that if i turn autoinv on and if bot reboot
it will get an error on line 53
i had to go in mysql server to change autoinvite value back to 0 and then it will give me the error code: 1062

also tested out the autoinv but it doesn't work on my bot for some reason :/
Title: Re: Help!! About Auto Invites
Post by: Dabaron on August 20, 2006, 12:10:55 pm
Ok, added those 2 files that you have, put those entries in the bot.php, turned auto-invite on, and then turned notify on on the character I want auto-invited and nothing.  No errors in bot, the sql database is updating properly, but I just dont' get invited.  Any ideas?
Title: Re: Help!! About Auto Invites
Post by: jjones666 on August 20, 2006, 12:56:22 pm
Did you drop and readd guest table?

-jj-
Title: Re: Help!! About Auto Invites
Post by: Dabaron on January 21, 2007, 10:49:50 pm
Back to autoinvite issues for me.  I hadn't updgraded my bot to each version as we have gone along due to heavily modified versions of everything but decided it was time to update the bot.php file for the extra things that have been added.  I made sure that the get_setting function was there (and it was by default in the new one) and then remodified the bot.php for my ign <-> bebot relay stuff to work.

Now comes my problem.  Some guests are getting auto-invited but most aren't (seems to be mostly random what ones are and what ones aren't.  I exported the guests table, dropped it, then re-imported and same thing.  Then I dropped guest table, just restarted bot so it re-created a blank guests table and added all the guests again via in-game guests command but also same thing.  No errors in bot window or anything, just some get invites and some don't.  All of the guests in question are set to 1 not 0 for the invite.

Any ideas?
Title: Re: Help!! About Auto Invites
Post by: jjones666 on January 22, 2007, 05:11:38 am
Hmm, from what I remember the standard bot.php deletes guests from the buddylist on logon (this was something Xenixa fixed in his roster module).

Check if the following 2 code snippets in bot.php are the same.  Also, are you using the standard roster module?

-jj-


Code: [Select]
/*
Buddy logging on/off
*/
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 (!$mem)
$this -> aoc -> buddy_remove($user);

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]);
}
}

Code: [Select]
/*
Check if person is a member of the bot
*/
function is_member($uname)
{
$result = $this -> db -> select("SELECT nickname FROM members WHERE id = " . $this -> aoc -> get_uid($uname));
if (!empty($result))
return 1;

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

if ($this -> admin -> in_group($uname, "superadmin"))
{
return 1;
}

if ($this -> admin -> in_group($uname, "admin"))
{
return 1;
}

return false;
}
Title: Re: Help!! About Auto Invites
Post by: Dabaron on January 22, 2007, 09:12:46 am
This is how mine looks in the bot.php.  I assume its for the "user has logged on" spam removal that is the difference.

Code: [Select]
/*
Buddy logging on/off
*/
function inc_buddy($args)
{
$user = $this -> aoc -> get_uname($args[0]);

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

// Make sure we only cache members and guests to prevent any issues with !is and anything else that might do buddy actions on non members.
if ($mem)
{
// Buddy logging on
if ($args[1] == 1)
{
// Do we have a logon for a user already logged on?
if (isset($this -> glob["online"][$user]))
{
$this -> log("BUDDY", "ERROR", $user . " logged on despite of already being marked as logged on!!");
return;
}
else
{
// Enter the user into the online buddy list
$this -> glob["online"][$user] = $user;
}
}
else
{
// Do we have a logoff without a prior login?
if (!isset($this -> glob["online"][$user]))
{
//$this -> log("BUDDY", "ERROR", $user . " logged off with no prior logon!!");
return;
}
else
{
unset($this -> glob["online"][$user]);
}
}
}

$end = "";
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);

$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]);
}
}

Code: [Select]
/*
Check if person is a member of the bot
*/
function is_member($uname)
{
$result = $this -> db -> select("SELECT nickname FROM members WHERE id = " . $this -> aoc -> get_uid($uname));
if (!empty($result))
return 1;

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

if ($this -> admin -> in_group($uname, "superadmin"))
{
return 1;
}

if ($this -> admin -> in_group($uname, "admin"))
{
return 1;
}

return false;
}
Title: Re: Help!! About Auto Invites
Post by: jjones666 on January 22, 2007, 11:01:54 am
There's the nasty code:

      if (!$mem || ($mem == 2))
      $this -> aoc -> buddy_remove($user);

Just change it to:

      if (!$mem)
      $this -> aoc -> buddy_remove($user);

I think that should be ok, you'll probably need to re-add the guests (doing via SQL is prolly not enough as it won't add the buddies back).  There's a module of mine somewhere with this "delete / readd" included into the !guestlist for exactly this reason.

Cheers,

-jj-
Title: Re: Help!! About Auto Invites
Post by: Xenixa on January 22, 2007, 09:22:39 pm
/me scratches his noggin.

Hmm.. I'm surprised the old is_member() and inc_buddy() functions are still in 0.2.10. I wrote fixes for those eons ago. The ones JJ pointed out that is.
Title: Re: Help!! About Auto Invites
Post by: Dabaron on January 23, 2007, 05:34:28 am
You two seriously ROCK!! (aka that fixed it  ;))
SimplePortal 2.3.7 © 2008-2024, SimplePortal