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: Experimental Rooster_GUILD.php  (Read 21870 times)

0 Members and 1 Guest are viewing this topic.

Offline Xenixa

  • Contributor
  • *******
  • Posts: 307
  • Karma: +0/-0
Re: Experimental Rooster_GUILD.php
« Reply #15 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
« Last Edit: January 28, 2006, 12:13:04 pm by Xenixa »
<<< Hack's in Zend Studio

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

Offline jjones666

  • Contributor
  • *******
  • Posts: 353
  • Karma: +0/-0
Re: Experimental Rooster_GUILD.php
« Reply #16 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-

Offline Xenixa

  • Contributor
  • *******
  • Posts: 307
  • Karma: +0/-0
Re: Experimental Rooster_GUILD.php
« Reply #17 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
<<< Hack's in Zend Studio

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

Offline Tsuyoi

  • BeBot User
  • **
  • Posts: 30
  • Karma: +0/-0
  • BigT
    • Adrenaline Rush Forums
Re: Experimental Rooster_GUILD.php
« Reply #18 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

Offline Khalem

  • BeBot Founder
  • Administrator
  • ********
  • Posts: 1169
  • Karma: +0/-0
    • http://www.ancarim.com
Re: Experimental Rooster_GUILD.php
« Reply #19 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
BeBot Founder and Fixer Kingpin

Offline Tsuyoi

  • BeBot User
  • **
  • Posts: 30
  • Karma: +0/-0
  • BigT
    • Adrenaline Rush Forums
Re: Experimental Rooster_GUILD.php
« Reply #20 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

Offline Xenixa

  • Contributor
  • *******
  • Posts: 307
  • Karma: +0/-0
Re: Experimental Rooster_GUILD.php
« Reply #21 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);
    }

;)
<<< Hack's in Zend Studio

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

Offline Xenixa

  • Contributor
  • *******
  • Posts: 307
  • Karma: +0/-0
Re: Experimental Rooster_GUILD.php
« Reply #22 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
<<< Hack's in Zend Studio

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

Offline Sabkor

  • Contributor
  • *******
  • Posts: 30
  • Karma: +0/-0
Re: Experimental Rooster_GUILD.php
« Reply #23 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 ;)

Offline Khalem

  • BeBot Founder
  • Administrator
  • ********
  • Posts: 1169
  • Karma: +0/-0
    • http://www.ancarim.com
Re: Experimental Rooster_GUILD.php
« Reply #24 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)
BeBot Founder and Fixer Kingpin

Offline Alreadythere

  • BeBot Maintainer
  • BeBot Hero
  • ******
  • Posts: 1288
  • Karma: +0/-0
Re: Experimental Rooster_GUILD.php
« Reply #25 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.

MatHack

  • Guest
Re: Experimental Rooster_GUILD.php
« Reply #26 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).

Offline Zakus

  • BeBot Rookie
  • *
  • Posts: 18
  • Karma: +0/-0
Re: Experimental Rooster_GUILD.php
« Reply #27 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

Offline Xenixa

  • Contributor
  • *******
  • Posts: 307
  • Karma: +0/-0
Re: Experimental Rooster_GUILD.php
« Reply #28 on: March 22, 2006, 10:18:57 am »
This info no longer valid: See info in first post.
« Last Edit: May 21, 2006, 01:47:02 pm by Xenixa »
<<< Hack's in Zend Studio

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

Offline Xenixa

  • Contributor
  • *******
  • Posts: 307
  • Karma: +0/-0
Re: Experimental Rooster_GUILD.php
« Reply #29 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.
<<< Hack's in Zend Studio

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

 

* 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: 667
  • 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