BeBot - An Anarchy Online and Age Of Conan chat automaton

Archive => Anarchy Online Archive => 0.2.x Custom/Unofficial Modules => Topic started by: Xenixa on December 29, 2005, 06:24:16 pm

Title: Experimental Rooster_GUILD.php
Post by: Xenixa on December 29, 2005, 06:24:16 pm
Okies... so I sat here mulling over the Auto update part with an integrated !seen command
This version is pretty much reworked in alot of ways.

Here's the code (http://www.box.net/public/xnnoxlook6), I have it running on my bot currently and it works. :) Take a read through it and if you've played with the Rooster enough you'll notice the changes. Oh and I also changed the formating a bit on the !seen output from Wanuarmi's

21 May 2006 Edit: I'm happy and I am done with this module. The member update Cron job does what it's supposed to do now and doesn't disturb guests on the bots Buddy list. It still contains all the previous notes above. I did this update mostly to fix issues with Guest auto inviting. BTW, the Auto inviting fixes go beyond the scope of this file. There were also fixes to AutoInv.php and Relay_GUILD.php. You can find those FILES HERE (http://www.box.net/public/3mdtm1ylso)
There are also some fixed functions in Bot.php that needed to be done. They are is_member() and inc_buddy(), I placed those functions in a text file here (http://www.box.net/public/m39e8rhh0m) rather than post my entire customized Bot.php. If your using a stock Bot.php replacing these functions shouldn't mess up anything else.

11 Jan 07 Edit: Updated links to files in this post. See link in my Sig for all other files posted by me around these forums.
Title: Re: Experimental Rooster_GUILD.php
Post by: Xenixa on December 30, 2005, 05:47:55 am
Little update to the code above. Turned out the order in which I had originally set the Command Processing function was keeping Members from using the !seen command if they weren't a bot admin. Updated to work correctly.
Title: Re: Experimental Rooster_GUILD.php
Post by: jjones666 on January 02, 2006, 12:39:36 am
Hi Xenixa,

Works great here, no problems at all so far =)

p.s. did you ever post your working auto-invite guests code, did a quick scout on forum and couldn't find.

Cheers,

-jj-
Title: Re: Experimental Rooster_GUILD.php
Post by: Xenixa on January 02, 2006, 01:01:46 am
No, unfortunatly the auto-invite code stuff is also still very experimantal. It kinda worked for a bit until I discovered other issues which lead back to the way Bot members are handled in the Roster updates. That whole Buddy list thing again.  :-\

Working on that though as time permits. :)
Title: Re: Experimental Rooster_GUILD.php
Post by: Ainen on January 02, 2006, 01:41:10 am
Just put this on my bot. One thing I noted is that my members table had the fields ai_rank_id and ai_rank instead of ailevel and aititle, so I had to go through and change all the references.
Title: Re: Experimental Rooster_GUILD.php
Post by: Xenixa on January 02, 2006, 11:57:07 am
The ailevel and aititle are inline with the SVN, so I just changed my column names in the DB and anywhere else it called those columns.. sorry I forgot to mention that, but what ever works for you :)

Edit: On another of my fixes I had for Auto invites of guests that was kinda working(which I didn't post here, was very ugly) I should have posted up tomarrow after work. Need sleepz before work. Doing APF raids is hard work too.  :P
Title: Re: Experimental Rooster_GUILD.php
Post by: Xenixa on January 05, 2006, 05:44:15 pm
Hrrm ok, so sow does the Roster Updates relate to auto invites you may be wondering?
Well else were I have posted fixes to Bot.php, and AutoInv.php that address actual Auto Inviting of people on the Guest list. Well since bots rely on knowing when people logon by them being in the bots Buddy list, Rooster_GUILD.php would prevent this.

So, I looked at this 2 ways and the best solution I could think of was to just do a simple comparison against the Guest Table. Or if you want to try it yourself, Find in Rooster_GUILD.php I have above:
Code: [Select]
// Remove buddys not on list...
foreach ($buds as $id => $value)
{
$this -> bot -> aoc -> buddy_remove($id);
$this -> bot -> log("BUDDY", "DEL", $this -> bot -> aoc -> get_uname($id));
}
Replace with:
Code: [Select]
// Remove buddys not on list...
foreach ($buds as $id => $value)
{
//Auto Invite Fix: Test to see if buddy exsists on Guestlist first. Don't remove if they are.
$gbuds = $this -> bot -> db -> select("SELECT id FROM guests WHERE id = $id");
if (empty($gbuds[0][0]))
{
$this -> bot -> aoc -> buddy_remove($id);
$this -> bot -> log("BUDDY", "DEL", $this -> bot -> aoc -> get_uname($id));
}
}
The updated AutoInv.php can be found on my ftp server here ftp://xen.afraid.org/bebot_files/
And changes to Bot.php can be found here: http://bebot.link/index.php/topic,255.0.html

You may have to remove then re-add people from the guest list so they can start getting Auto Invited on logon.
Also after restarting the bot don't forget to do a !autoinv on
Title: Re: Experimental Rooster_GUILD.php
Post by: Ainen on January 07, 2006, 07:29:22 am
I'm wondering if this has something to do with this module, but when someone joins the guest channel, they're added to both the Guild and private group online listing, but when they leave the private group, they do not leave the guild part of the listing. I have to restart the bot to clear that up. I'm running the version of 12/29.
Title: Re: Experimental Rooster_GUILD.php
Post by: Xenixa on January 07, 2006, 11:46:28 am
I saw that happen before the changes I made. Usually doing an !is will knock them off Online list if they logged out.

Edit: I looked this again Ainen, It's an issue with the Online.php ... It seems to base the Members online by read it's own buddylist with AND like condition on the is_member function.
Title: Re: Experimental Rooster_GUILD.php
Post by: Xenixa on January 11, 2006, 08:38:05 am
I'm wondering if this has something to do with this module, but when someone joins the guest channel, they're added to both the Guild and private group online listing, but when they leave the private group, they do not leave the guild part of the listing. I have to restart the bot to clear that up. I'm running the version of 12/29.

I just at this very moment fixed this issue Ainen. Was pretty strait forward.
Basically in the Online.php module find inside the function buddy($name, $msg) the following line:
Code: [Select]
if ($this -> bot -> is_member($name))Change to:
Code: [Select]
if ($this -> bot -> is_member($name) == 1)That should stop it from showing guests in the Members area of the Online Info window. This of course assumes your function is_member() in the Bot.php looks 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;
}
    }
Title: Re: Experimental Rooster_GUILD.php
Post by: jjones666 on January 25, 2006, 02:29:19 am
Hi Xenixa,

Still using the code above plus the various fixes - autoinvite works perfectly :-)

However, one problem I found is that if someone leaves org, the member does not get deleted at next roster check (you can delete manually with the !member command though).

Just wondered if this was a side-effect of not removing the guests from buddy list or could it be fixed?

Either way, just to let you know this problem exists (and is fixable manually).

Cheers,

-jj-
Title: Re: Experimental Rooster_GUILD.php
Post by: Xenixa on January 28, 2006, 08:48:54 am
Ya, I've noticed this one also. :)

Problem is in order to keep the lastseen column from getting nuked I changed it so it wouldn't delete the whole list of Org members. What I failed to realize was that members could get stuck on that table if no one wasn't actively keeping track of there Org's roster and deleting them from the bot.

I been working on another method actually as time permits that should fix this.

Oh I've also since 'fixed' another problem I was having with auto invites. Not so much a bot problem but a guest problem. Not all guests of the bot like to be auto invited every time they log on. So I modified the the autoinv.php to add an additional command(!notify) and check. It stores a boolean in the guests table for each of the guests preferences, 1 for on and 0 for off. Defaults to on. Also required changes to Relay_GUILD.php and the guests table of course. My copy of Relay_GUILD.php also uses Alreadythere's Whois Cache module to handle output of info on who joinded the Private channel. I can make them available if anyone is interested.
Title: Re: Experimental Rooster_GUILD.php
Post by: Khalem on January 28, 2006, 09:38:24 am
Ya, I've noticed this one also. :)

Problem is in order to keep the lastseen column from getting nuked I changed it so it wouldn't delete the whole list of Org members. What I failed to realize was that members could get stuck on that table if no one wasn't actively keeping track of there Org's roster and deleting them from the bot.

I been working on another method actually as time permits that should fix this.

There are two different approaches to this issue that i can see.

The easy way is to grab the messages from Org. Msg. which we should be doing (and will be doing) and use it to delete members, and simply leave it up to the administrators of the bot to delete any members missed by the automated system.

The second way, which isn't quite as easy, is still grabbing the messages by automated removal, but also actually validating the list somehow, I'm just not sure what way would be best.
My original thoughts went towards md5'ing the org XML, however that would pick up on a lot of changes not related to org additions and leavings. Another avenue would be using the member count, but even that is prone to problems as it can occur that a member leaves and a member is added in a single day, in which case the member count would stay the same but the org rooster would remain unchanged.

Bot's nowdays barring server issues tend to stay online almost constantly though so it could be argued that a more sophisticated approach than the first is a total waste anyways.
Title: Re: Experimental Rooster_GUILD.php
Post by: Xenixa on January 28, 2006, 09:54:43 am
Funny you should mention Org. Msg.'s from the gmsg channel. :)

I'm just now wrapping up adding that to Rooster_GUILD.php since its slow ingame and I have nothing better to do.
Title: Re: Experimental Rooster_GUILD.php
Post by: Tsuyoi on January 28, 2006, 09:55:52 am
You could use a combination of the the method used now and the ["Org. Msg."].  Just add the functionality of (.+) (joined|left) the org./i into the system, and max out the cron time.  I realize it's double redundancy, but it will not only provide real-time updates to the roster, but also provide the reliability of a periodic revamp of the roster as well.

Just starting my delve into Bebot, so I apologize if this method has been trashed before or there are prior reasons for not using it.

- Tsuyoi
Title: Re: Experimental Rooster_GUILD.php
Post by: Xenixa on January 28, 2006, 10:55:43 am
Done! If your using the code I have above in first post add these to it. Or modify to fit your current Rooster_GUILD.php

With the rest of the $commands group add:
Code: [Select]
$commands["gmsg"]["Org. Msg."][] = &$rooster;
Then add these 2 Functions somewhere in there. Near the bottom is fine.
(Note: I added an additional column to the LastSeen column. It's for recording the last time the record was 'updated'.)
Code: [Select]
/*Parses Kicked/Joined/Left messages from Org. Msg. channel*/
function gmsg($name, $group, $msg)
{
if ($name == "0")
{
if (preg_match("/(.+) kicked (.+) from your organization./i", $msg, $info))
{
$kickedname = $info[2];
$id = $this -> bot -> aoc -> get_uid($kickedname);
$this -> bot -> aoc -> buddy_remove($id);
$this -> bot -> log("BUDDY", "DEL", $kickedname);
$this -> bot -> db -> query("DELETE FROM members WHERE nickname = '$kickedname'");
$this -> bot -> send_gc("<font color=#ffff00>$kickedname</font> was removed from Bot Roster. [Kicked from Org]");
}
else if (preg_match("/(.+) has left your organization./i", $msg, $info))
{
$leftname = $info[1];
$id = $this -> bot -> aoc -> get_uid($leftname);
$this -> bot -> aoc -> buddy_remove($id);
$this -> bot -> log("BUDDY", "DEL", $leftname);
$this -> bot -> db -> query("DELETE FROM members WHERE nickname = '$leftname'");
$this -> bot -> send_gc("<font color=#ffff00>$leftname</font> was removed from Bot Roster. [Left the Org]");
}
else if (preg_match("/(.+) has joined your organization./i", $msg, $info))
{
$add_name = $info[1];
$members = $this -> get_player_info($add_name);
$members["id"] = $this -> bot -> aoc -> get_uid($add_name);

$this -> bot -> db -> query("INSERT INTO members (id, nickname, firstname, lastname, rank, rank_name, level, profession, gender, breed, ailevel, aititle, lastseen, updated)
                VALUES ('" . $members["id"] . "',
                        '" . $members["nickname"] . "', '" . $members["firstname"] . "',
                        '" . $members["lastname"] . "', '" . $members["rank"] . "',
                        '" . $members["rank_name"] . "', '" . $members["level"] . "',
                        '" . $members["profession"] . "', '" . $members["gender"] . "',
                        '" . $members["breed"] . "', '" . $members["ailevel"] . "',
                        '" . $members["aititle"] . "', '" . $members["lastseen"] . "', '" . time() . "')");

if (!$this -> bot -> aoc -> buddy_exists($members["id"])) {
$this -> bot -> aoc -> buddy_add($members["id"]);
$this -> bot -> log("BUDDY", "ADD", $this -> bot -> aoc -> get_uname($members["id"]));
}
$this -> bot -> send_gc("Welcome <font color=#ffff00>$add_name</font>!!! You have been added to <botname>'s Roster.");
}
}
}
Code: [Select]
/*Retrieves player info from FC's character server*/
function get_player_info($name)
{
$member = $this -> bot -> get_site("http://www.anarchy-online.com/character/bio/d/" . $this -> bot -> dimension . "/name/" . strtolower($name) . "/bio.xml");
$members["nickname"] = ucfirst(strtolower($add_name));
$members["firstname"] = $this -> bot -> xmlparse($member, "firstname");
$members["lastname"] = $this -> bot -> xmlparse($member, "lastname");
$members["rank"] = $this -> bot -> xmlparse($member, "rank_id");
$members["rank_name"] = $this -> bot -> xmlparse($member, "rank");
$members["level"] = $this -> bot -> xmlparse($member, "level");
$members["profession"] = $this -> bot -> xmlparse($member, "profession");
$members["gender"] = $this -> bot -> xmlparse($member, "gender");
$members["breed"] = $this -> bot -> xmlparse($member, "breed");
$members["ailevel"] = $this -> bot -> xmlparse($member, "defender_rank_id");
$members["aititle"] = $this -> bot -> xmlparse($member, "defender_rank");
return $members;
}

Edit: Ooops forgot to put some quotes around the name variables in the DB queries. Fixed.
 TEST Passed! yay. Works as advertised. I.E. it will remove characters that are Kicked/Leave and add them on Invite acceptance.
You can download my Rooster_GUILD.php here --> ftp://xen.afraid.org/bebot_files/Xens_Rooster_GUILD.php
Title: Re: Experimental Rooster_GUILD.php
Post by: jjones666 on January 28, 2006, 05:14:04 pm
Ya, I've noticed this one also. :)

Problem is in order to keep the lastseen column from getting nuked I changed it so it wouldn't delete the whole list of Org members. What I failed to realize was that members could get stuck on that table if no one wasn't actively keeping track of there Org's roster and deleting them from the bot.

I been working on another method actually as time permits that should fix this.

Oh I've also since 'fixed' another problem I was having with auto invites. Not so much a bot problem but a guest problem. Not all guests of the bot like to be auto invited every time they log on. So I modified the the autoinv.php to add an additional command(!notify) and check. It stores a boolean in the guests table for each of the guests preferences, 1 for on and 0 for off. Defaults to on. Also required changes to Relay_GUILD.php and the guests table of course. My copy of Relay_GUILD.php also uses Alreadythere's Whois Cache module to handle output of info on who joinded the Private channel. I can make them available if anyone is interested.

Hi Xenixa,
Thanks for the explanation and fix.  Would be interested in the updated files you mention above.
Cheers,
-jj-
Title: Re: Experimental Rooster_GUILD.php
Post by: Xenixa on January 28, 2006, 06:21:30 pm
OK ... You can find the Autoinv.php and Relay_GUILD.php I use here:
ftp://xen.afraid.org/bebot_files/autoinv_modules.zip

Just a couple reminders.
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
Title: Re: Experimental Rooster_GUILD.php
Post by: Tsuyoi on February 01, 2006, 01:09:51 am
Quite a few functions use the players info in them for random stuff (or could just for looks).  Would it hurt anything to toss the function above into Bot.php just so it can be called throughout.

- Tsuyoi
Title: Re: Experimental Rooster_GUILD.php
Post by: Khalem on February 01, 2006, 11:29:16 am
I plan to move the whois functionality into the core of the bot, based on the whois cache by Alreadythere, which will also eliminate the need for the members table to hold most of the Whois information
Title: Re: Experimental Rooster_GUILD.php
Post by: Tsuyoi on February 01, 2006, 04:53:28 pm
Shibby :)

Should seriously clean up the new roster and alts modules I've been working on without having to redo the xmlparsing every 2 steps :)

- Tsuyoi
Title: Re: Experimental Rooster_GUILD.php
Post by: Xenixa on February 02, 2006, 01:39:25 am
Actually I'm in the process of cleaning up this Rooster_Guild.php I have posted here to use Alreadythere's whois module. Looking much cleaner already. Trying to keep it as compatible to Bebot v0.2.x as possible atm.

Oh and if your using that whois module and looking for a spiffier looking Alts info view this is what I have.
Code: [Select]
/* 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);
    }

;)
Title: Re: Experimental Rooster_GUILD.php
Post by: Xenixa on February 08, 2006, 11:31:47 pm
Make a couple bug fixes to Xens_Rooster_GUILD.php that had posted on my FTP server.
The !seen command was causing a php that would restart the bot.

So if your using it you may want to re-download and review the changes.
ftp://xen.afraid.org/bebot_files/Xens_Rooster_GUILD.php
Title: Re: Experimental Rooster_GUILD.php
Post by: Sabkor on March 03, 2006, 04:34:39 am
I was just reading through this and thinking about an easy way to remove people from memberlist via the XML, here's what I thought.

- Add an extra column in the members table, boolean.
- Before Roster update, set that column, lets call it curr_member to false.
- As you update each member from the XML, set curr_member to true.
- Once we're done parsing the XML, delete all members with a curr_member = false.

Should work, I think, unless I'm just really tired ;)
Title: Re: Experimental Rooster_GUILD.php
Post by: Khalem on March 03, 2006, 05:25:54 am
Ive been giving this some more thought aswell, and your idea is the best one yet Sabkor.
We also need to use a timestamp to prevent members from being prematurely removed as members (ie a member gets added to the bot by join message, and then a few hours afterwards an XML check removes him since he is not in XML yet)
Title: Re: Experimental Rooster_GUILD.php
Post by: Alreadythere on March 03, 2006, 10:56:42 am
Just use the timestamp.

Every time the roster gets updated by the XML, update the timestamp of the org members.
If someone joins the org, put the timestamp to the time of joining.

And then simply delete all timestamps older than X hours.

Need to do some thinking about X, but should be something between 6 and 30, depending on how paranoid you want to be about the correct roster. You could even make the time a setting, so everybody can set it as he wants.
Title: Re: Experimental Rooster_GUILD.php
Post by: MatHack on March 03, 2006, 05:17:08 pm
Timestamp sounds the best to me too, also solves the problem that the seen command actually isn't very true, because it resets each time the cronjob runs. (I solved this atm with a seperate table for seen-times).

But only deleting records that are old (through the timestamp), would solve both problems I had with this module so far (other being members deleted because not on the XML).
Title: Re: Experimental Rooster_GUILD.php
Post by: Zakus on March 16, 2006, 05:36:03 pm
There might be a problem in xen's Rooster_guild at around line 136.

This:
Code: [Select]
<?php 
$badmemb 
$this -> bot -> db -> select("SELECT nickname FROM members WHERE nickname = $chkmemb");?>

I changed to this (added single quotes around the $chkmemb):
Code: [Select]
<?php 
$badmemb 
$this -> bot -> db -> select("SELECT nickname FROM members WHERE nickname = '$chkmemb'");?>

I still think there is something wrong with my copy of xen's rooster_guild.
I commented out the entire "Auto Invite Fix:" and it got a little better.
Xenixa, if you see someone on msn named [email protected] add you on msn, thats me. If you have time to troubleshoot this :)

Thanks,
-Z
Title: Re: Experimental Rooster_GUILD.php
Post by: Xenixa on March 22, 2006, 10:18:57 am
This info no longer valid: See info in first post.
Title: Re: Experimental Rooster_GUILD.php
Post by: Xenixa on March 28, 2006, 03:29:01 pm
Yet another issue with this version of Rooster_Guild. I discovered a situation were in newer versions of MySQL and PHP => 5 new members that were added via the members command or via the Org Msg event would toss a MySQL error and thusly not add the character to the members table.

Anyway Fixed. New version on my FTP server.

For those the want to know what was wrong. MySQL didn't like getting NULL values passed to it from a PHP script basically. Even with a Default Set and the NOT NULL flag disabled on the Table rows affected. *shrug*

Rows affected were 'rank' and 'lastseen'
Changed the get_player_info() function to set 'rank' to '6' and 'lastseen' to '0' as the XML that FC outputs doesn't have that info for Rank if the character wasn't previously in an Org. So I'm assuming Applicant(6) for Rank. Eventually I'll change the initial 'lastseen' to Eval if the character is online and use the current time() else set to 0.
Title: Re: Experimental Rooster_GUILD.php
Post by: jjones666 on May 09, 2006, 02:58:02 am
Hi Xen,

Still using the files you posted back in January for notify and autoinvite.  I just wondered if it would be possible to add code so that it is possible for superadmin to turn off/on autoinvite for particular members (rather than each guest having to send bot a tell).

ie. !notify <name> <on/off>

I would add this to the !guestlist output so this can be manually changed easily from there (alongside Whois and Remove).

Cheers,

-jj-
Title: Re: Experimental Rooster_GUILD.php
Post by: Xenixa on May 09, 2006, 01:33:24 pm
Well thats a Autoinv.php function actually.

In Autoinv.php Change:
Code: [Select]
function tell($name, $msg)
    {
if (preg_match("/^" . $this -> bot -> commpre . "autoinv (on|off)$/i", $msg, $info))
$this -> bot -> send_tell($name, $this -> switchauto($name, $info[1]));
if (preg_match("/^" . $this -> bot -> commpre . "notify (on|off)$/i", $msg, $info))
$this -> bot -> send_tell($name, $this -> notifymode($name, $info[1]));
else
$this -> bot -> send_help($name);
    }

To this:
Code: [Select]
function tell($name, $msg)
    {
if (preg_match("/^" . $this -> bot -> commpre . "autoinv (on|off)$/i", $msg, $info))
$this -> bot -> send_tell($name, $this -> switchauto($name, $info[1]));
if (preg_match("/^" . $this -> bot -> commpre . "notify (on|off)$/i", $msg, $info))
$this -> bot -> send_tell($name, $this -> notifymode($name, $info[1]));
elseif (preg_match("/^" . $this -> bot -> commpre . "notify (.+) (on|off)$/i", $msg, $info))
$this -> bot -> send_tell($name, $this -> notifymode($info[1], $info[2]));
else
$this -> bot -> send_help($name);
    }

I didn't test that but it should work when you do !notify Name on|off
Title: Re: Experimental Rooster_GUILD.php
Post by: jjones666 on May 09, 2006, 03:03:08 pm
Thank you, first testing looks perfect!  If I can add into the !guestlist succesfully, I'll send you back :-)

BTW, this line doesn't need to be in GC function, correct?

         if (preg_match("/^" . $this -> bot -> commpre . "points transfer (on|off)$/i", $msg, $info))
            $this -> bot -> send_gc($this -> switchauto($name, $info[1]));

Many thanks for your quick feedback and hard work on this forum ;-)

Cheers,

-b-
Title: Re: Experimental Rooster_GUILD.php
Post by: Xenixa on May 10, 2006, 03:30:44 am
The points transfer stuff is there for Bebot's ran as a raid bot. You can remove it if you want.
I myself just keep the command disabled using the commands module in v0.3.2

Oh btw, I've put yet a new version of Xens_Rooster_Guild.php on my FTP server. PHP5 is being a pain in my ass with a few things... most notibly order of evaluation concerning FOREACH loops and array's. Begining to think I should switch to the latest PHP5.1
Title: Re: Experimental Rooster_GUILD.php
Post by: Xenixa on May 21, 2006, 01:20:10 pm
My last and final update to this File is done.
See First post in this thread for more info.

Edit:
For those interested in how I came up with the fixes, here's the Cron Job step by step:
1.) Retrieve and build an array of the guild roster from FC servers
2.) Grab the Bots current buddylist and place it in an Array
3.) Insert/Replace the member records from the XML array with updated/new values into the Database
4.) Eval each Buddylist ID, Add only the new ID's to buddylist based on list from FC roster array.
5.) Remove each ID from buddylist array after it's eval'd. This leaves us with an Array of buddy ID's that are not Members
6.) Eval each remaining buddylist ID and remove the ID's that aren't on the Guest table.
7.) Delete characters from Member's Table if they match the current remaining ID in Buddylist array being evluated.

There it is. As plain and simple as I can get it. Blondengy had the right idea with this one originally btw, but the order of evaluation was all wrong. I had to pull up the original Cron job and read it step by step just to see what it was doing each step of the way. In it's basic form all I had to do was move the Insert/Replace to be before the buddylist stuff and add the guest table checks and member table deletions.

Title: Re: Experimental Rooster_GUILD.php
Post by: jjones666 on May 21, 2006, 08:46:33 pm
Thanks Xenixa, sounds good :-D

-jj-
Title: Re: Experimental Rooster_GUILD.php
Post by: captainwinky on May 22, 2006, 05:36:54 am
currently running this on 0.2.2 with necessary changes to other BeBot files, except those related to AutoInv.php, Relay_GUILD.php, and WhoisCache.php (WhoisCache appears to require a little more in depth reading and learning on my part).

at this point it's working very nicely :) except for some of the functionality regarding [Org. Msg.].  upon a new member joining the org, Rooster_GUILD does not appear to add them to the bot, and a kicked member does not seem to invoke the applicable message in the guild-chat.  i was able to add the new member using the !member command, which seems strange as my understanding of your first post is that this was deemed redundant and therefore removed.

i am wondering if these, albeit somewhat minor, problems are a result of me not having correctly set up AutoInv.php, Relay_GUILD.php, and WhoisCache.php... or if they are not working for some other reason.

any help on this matter would be greatly appreciated :)
Title: Re: Experimental Rooster_GUILD.php
Post by: Xenixa on May 22, 2006, 09:26:30 am
The [Org. Msg.] part will not work if your using an AOChat.php older than v1.19 or the custom v1.17.1 version I posted around here some where. I left the manual roster add/remove stuff for those occations that the bot may not witness a character leaving or joining org... like for example if the bot goes down. :) The redundancy part I wrote was about having redundant code in the module for each command types(tell, gc and pgmsg) hence it was consolidated into one function. Well two actually. :)

Also this version of Rooster_GUILD.php was written and tested on bebot 0.3.2, however I did have it working on 0.2.3 with the updated AOChat.php to handle FC's extended messages.
Title: Re: Experimental Rooster_GUILD.php
Post by: captainwinky on May 22, 2006, 12:47:29 pm
ahh, oki.  thanks very much for info.  trying this now with v1.17.1 on BeBot_v0.2.2 :)


EDIT: hmm, no luck yet.  anyone have any information on whether the [Org. Msg.] functions can work on BeBot_v0.2.2?
Title: Re: Experimental Rooster_GUILD.php
Post by: Xenixa on May 22, 2006, 03:30:44 pm
You may want to check on the function inc_gmsg()  in Bot.php. Does it look like this one?

Code: [Select]
/*
* Incoming group message (Guildchat, towers etc)
*/
function inc_gmsg($args)
{
$user = $this -> aoc -> get_uname($args[1]);

$found = false;

$group = $this -> aoc -> lookup_group($args[0]);

if (!$group)
{
$group = $this -> aoc -> get_gname($args[0]);
}

if($user == "0" && (substr($args[2], 0, 2) == "~&"))
{
$a_aoext = new AOExtMsg($args[2]);
$args[2] = $a_aoext -> text;
}
else
$args[2] = utf8_decode($args[2]);

if (preg_match("/<a type=chatclient version=(.+) href=(.+)>/isU", $args[2], $info))
{
if (isset($this -> commands["tell"]["online"]))
$this -> commands["tell"]["online"] -> chatclient ($user, $info[2]);
$args[2] = preg_replace("/<a type=chatclient version=(.+) href=(.+)><\/a>/isU", "", $args[2]);
}

if (isset($this -> commands["gmsg"][$group]) || ($group == $this -> guildname))
{
$this -> log("GROUP", "MSG", "[" . $group . "] " . $this -> aoc -> get_uname($args[1]) . ": " . $args[2]);
}

if (!isset($this -> other_bots[$user]))
{
if ($group == $this -> guildname)
{
if (!empty($this -> commands["gc"]))
{
$comms = array_keys($this -> commands["gc"]);
for ($i = 0; $i < count($comms); $i++)
{
if ($this -> is_command($comms[$i], $args[2]))
{
$this -> commands["gc"][$comms[$i]] -> gc ($user, $args[2]);
$i = count($comms);
$found = true;
}
}
}
}


if (isset($this -> commands["gmsg"][$group]) && !$found)
{
$comms = array_keys($this -> commands["gmsg"][$group]);
for ($i = 0; $i < count($comms); $i++)
{
$this -> commands["gmsg"]["$group"][$comms[$i]] -> gmsg($user, $group, $args[2]);
}
}
}
}
Title: Re: Experimental Rooster_GUILD.php
Post by: captainwinky on May 22, 2006, 07:08:44 pm
it's 3am and i'm tired, but i'm pretty sure it's identical  :-\
Title: Re: Experimental Rooster_GUILD.php
Post by: Pharexys on June 19, 2006, 09:19:06 am
Ok didnt worked how i wanted so deleted it,
I tryd to combine ur module with mine,
I get a error right now and that is :
Code: [Select]
Fatal error: Call to undefined method Rooster::buddy() in C:\bebot3.2\bebot\Bot.
php on line 464

The 464 line on bot.php is like this:
Code: [Select]
$this -> commands["buddy"][$key] -> buddy($user, $args[1]);
wich is nothing wrong.

The bug i think is here were i modified.

I changed :
Code: [Select]
// Get the guild roster
$org = $this -> bot -> get_site("http://community.anarchy-online.com/org/stats/d/" . $this -> bot -> dimension . "/name/" . $this -> bot -> guildid . "/basicstats.xml");
$org = explode("<member>", $org);

with this:
Code: [Select]
$orgids[0] = 5593094;
$orgids[1] = 4935681;
foreach ($orgids as $orgid)
{
$org = $this -> bot -> get_site("http://community.anarchy-online.com/org/stats/d/" . $this -> bot -> dimension . "/name/" . $orgid . "/basicstats.xml");
$org = explode("<member>", $org);

Any ideas what it has?


For more info my module is here:
http://devil-inside.org/modules/Rooster_Phar.phps
What i want is to combine this 2 roosters ;D
Title: Re: Experimental Rooster_GUILD.php
Post by: Malosar on June 19, 2006, 01:35:20 pm
The Class doesn't look to be closed, add a } at the end. (Before the ?> of course)
Title: Re: Experimental Rooster_GUILD.php
Post by: jjones666 on June 20, 2006, 02:57:52 am
Xen,

Just added a new member to org, funnily enough didn't add to roster.  See extract from log:

[2006-06-20 00:46:13]   [GROUP] [MSG]   [Org. Msg.] 0: xxxxxx has joined your o
rganization.

Perhaps cause the relay is on?  Maybe the leading 0: is causing the problem?

Cheers,

-jj-
Title: Re: Experimental Rooster_GUILD.php
Post by: Nesi on June 20, 2006, 01:30:16 pm
As this roster module depends on the messages delivered by AOChat.php it is suceptible to changes in these messages.
One such change was changing the "your organization" into "the organization" or the other way around... i forgot. Anyway, adding (?:the|your) in the preg_match reg.exp. should help compatability with newer/older AOChat versions.
Title: Re: Experimental Rooster_GUILD.php
Post by: jjones666 on June 20, 2006, 03:47:45 pm
I wasn't 100% sure which AOChat I am using, I think from the previous SVN builds - I know Khalem said that his latest update breaks a lot of stuff so didn't update.  I know Xen also distributes a modified AOChat also at one point (so assume this is the one his module is based on).

Hopefully these type of problems will go away when we have one "standard" AOchat to use for all modules.

I will try to fix the module module based on your above input Nesi (thanks very much!).  Will let you know the results.

Cheers,

-b-
Title: Re: Experimental Rooster_GUILD.php
Post by: jjones666 on June 21, 2006, 01:56:57 am
Works perfectly, thanks!

One thought, with new roster automatically adding person to roster - removing a new member from guestlist automatically before making a member would make sense.  (I know you can do this manually before invite).

Cheers,

-jj-
Title: Re: Experimental Rooster_GUILD.php
Post by: Alreadythere on June 21, 2006, 02:29:52 pm
The current way the cronjob adds buddies doesn't handle deleted characters well.
It adds them, printing an empty "[BUDDY] [ADD]" message, followed by "[BUDDY] [LOG]    logged [off] (not member)".

Adding a check so only IDs > 0 gets added as buddie seems to solve this.
Title: Re: Experimental Rooster_GUILD.php
Post by: Nesi on June 21, 2006, 09:31:22 pm
Hmmm tried using a while loop instead of a foreach?
Foreach can cause problems in some cases.

Edit: took a quick peek at the module code around the add buddy segment.

The foreach statement may go sideways through the columns of the array if there is only one row, in the array that is passed to it.
On numerous rows it will go downwards through the array, catching the key and value of the buddy in question as expected.

IE. if there is only one member to be added and this member is offline, the array from AOChat could look something like this $bud_del[id#] = false.

Foreach may then treat both the id# and the false (0) as an array value, adding both to the memberlist. And 0 is a valid "character" ingame.
 
Title: Re: Experimental Rooster_GUILD.php
Post by: Nesi on June 22, 2006, 01:38:53 pm
No promises, but try this line instead of the foreach..  will do the exact same thing as the foreach but not going sideways.

// Add to buddylist if not yet in there
   while(list($key, $memb) = each($members))
Title: Re: Experimental Rooster_GUILD.php
Post by: Alreadythere on June 22, 2006, 02:28:30 pm
The problem I noticed is this: a char that got deleted is still in the member table. Then you get the result I posted above.
Doesn't have anything to do with foreach, it's just a missing check for a valid ID before or in aorc -> addbuddy().
Title: Re: Experimental Rooster_GUILD.php
Post by: Nesi on June 22, 2006, 02:59:31 pm
Adding a check so only IDs > 0 gets added as buddie seems to solve this.

Well i assumed this was your fix, and you are talking about adding buddys.
Title: Re: Experimental Rooster_GUILD.php
Post by: Dabaron on August 18, 2006, 09:18:03 am
Found an error in here that was causing my bot to crash if I did a -seen on someone that it had never seen.  Was crashing with Fatal Error: Cannot use string offset as an array in C:\BeBot\Beerraid\modules\Rooster_GUILD.php on line 219.

I changed 219 from:
if ($t_result
to:
 if (empty($t_result))
and that seems to have fixed it.  Made more sense to me since it was looking for if (!empty($t_result)) for people that it had seen.
Title: Re: Experimental Rooster_GUILD.php
Post by: Xenixa on September 03, 2006, 02:45:59 am
Found an error in here that was causing my bot to crash if I did a -seen on someone that it had never seen.  Was crashing with Fatal Error: Cannot use string offset as an array in C:\BeBot\Beerraid\modules\Rooster_GUILD.php on line 219.

I changed 219 from:
if ($t_result
  • [0] ==

to:
 if (empty($t_result))
and that seems to have fixed it.  Made more sense to me since it was looking for if (!empty($t_result)) for people that it had seen.

Hmm strange my line 219 is:
Code: [Select]
if (!empty($t_result)) { $last['seen'] = $t_result[0][0]; }It's checking to make sure the timestamp field is not empty before it reassigns $t_result[0][0] to $last['seen']. Reassigning the value from the DB to a new string var clears up the offset error before the actuall value is used.

Also I updated my Xens_Rooster_GUILD.php on my ftp server that contains:
- Fix suggestion from Nesi about checking the regex in the gmsg function for the or your in the string that comes from aochat.php

Thanks Nesi. :)
Title: Re: Experimental Rooster_GUILD.php
Post by: buff on October 17, 2006, 08:38:49 pm
Not sure if anyone noticed a problem with the lastest update with Bot rekon the Org. Msg. when people join and leaves. When I temp invite my alts to org and leaves then log off. My online list still shows the name of the alts that temp join and leaves. Thought would bring that up if anyone noticed this issue.

Also when I use jj's gueslist function and turn alert on/off, i guess this warning:

MySQL error (# 0) on query: UPDATE guests SET alertstatus = 1 WHERE name = 'xxxxxxx'
Unknown column 'alertstatus' in 'field list'
Title: Re: Experimental Rooster_GUILD.php
Post by: Khalem on October 18, 2006, 02:56:46 am
Somewhat related, but the issue with people remaining on online list is resolved in 0.3 SVN which has a rewritten roster.
Title: Re: Experimental Rooster_GUILD.php
Post by: kuznechik on October 20, 2006, 07:29:53 pm
in Xens_Rooster_guild.php at line 131 there must be

if (empty($l_result[0]) || $l_result[0][1] != $memb["rank"] || $l_result[0][2] != $memb["level"] || $l_result[0][3] != $memb["ailevel"] || $l_result[0][5] = '')

instead of

if (empty($l_result[0]) || $l_result[1] != $memb["rank"] || $l_result[2] != $memb["level"] || $l_result[3] != $memb["ailevel"] || $l_result[5] = '')
Title: Re: Experimental Rooster_GUILD.php
Post by: buff on October 24, 2006, 07:02:36 pm
tried what kuznechik recommended but still not working :/
Title: Re: Experimental Rooster_GUILD.php
Post by: jjones666 on January 23, 2007, 01:59:27 pm
Branched and split discussion on autoinvite and alert plugins to...

http://bebot.link/index.php/topic,648.0.html (http://bebot.link/index.php/topic,648.0.html)

-jj-
Title: Re: Experimental Rooster_GUILD.php
Post by: pusikas on April 06, 2007, 09:59:50 pm
The Roster_GUILD.php module deletes a member from the raid_points table when you do a "!member del" on him. It doesn't do that when the person is kicked from org, or just leaves. It also only deletes the raid points if the command is executed on the main, not when it is done on an alt. This is especially annoying, as there is no easy way to find out how many raidpoints were deleted, and since everyone can use the !member command. While the "!points add" command is limited (for good reason) to superadmins. And guess who managed to delete all his raidpoints this way? ^^

Is there a reason for this, or can I just comment out the following line?

Code: [Select]
$this -> bot -> db -> query("DELETE FROM raid_points WHERE id = " . $id);
Title: Re: Experimental Rooster_GUILD.php
Post by: Vhab on April 07, 2007, 08:23:06 am
Actually, that makes me wonder, why ever delete raid points?
Title: Re: Experimental Rooster_GUILD.php
Post by: pusikas on April 07, 2007, 01:41:10 pm
Well, I sure don't want it to happen automatically. There is a command for it, you can use "!points del", and that should be the way to delete raidpoints. And space on my HD is not so precious that I cannot keep points for someone that left org and may come back one day.
Title: Re: Experimental Rooster_GUILD.php
Post by: Khalem on April 07, 2007, 03:10:42 pm
I'm a little bit out of touch. But for 0.3/0.4 i changed things around specifically to avoid issues like this. Here a member del doesn't actually delete anything about a user, it only marks them as no longer a member. To actually remove all records of someone you must erase the user. Not sure if that's been left out or changed during the past months however.
Title: Re: Experimental Rooster_GUILD.php
Post by: pusikas on April 10, 2007, 01:39:15 am
Another thing about the relay: if someone is is guestchannel and relay is on, it all works fine and the guest sees all that is said in orgchat. Status messages that have no source are prefixed with the name "0", tho. It looks like this:
Code: [Select]
[bot] bot: 0: Luuv turned the cloaking device in your city on.
That is not strictly speaking an error, just very weird... and it does not look intentional to me. :)
Title: Re: Experimental Rooster_GUILD.php
Post by: Khalem on April 10, 2007, 05:48:09 pm
This is how the chatserver sends it. City event messages originate from the user: 0 from Funcom's servers.
Title: Re: Experimental Rooster_GUILD.php
Post by: pusikas on April 10, 2007, 07:49:48 pm
OK, intentional then. :)
SimplePortal 2.3.7 © 2008-2024, SimplePortal