L* R*
HOME FORUM DOWNLOADS
Content
  Links
     Browse SVN
     SVN Commit log
     Documentation (Wiki)
  Developers
     Taskmanager
User
Welcome, Guest. Please login or register.
Did you miss your activation email?
November 21, 2008, 10:17:03 PM

Login with username, password and session length
Search



Advanced search
Support GoPHP5.org
BeBot - An Anarchy Online/Age Of Conan chat automaton > Forum > Modules > Modules for older versions > 0.2.x Custom/Unofficial Modules > Topic: Experimental Rooster_GUILD.php
Pages: 1 [2] 3 4 5   Go Down
« previous next »
Print
Author Topic: Experimental Rooster_GUILD.php  (Read 8458 times)
0 Members and 1 Guest are viewing this topic.
Xenixa
BeBot Contributor
Expert
*******
Offline Offline

Posts: 307



Re: Experimental Rooster_GUILD.php
« Reply #15 on: January 28, 2006, 04: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:
$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:
/*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:
/*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, 06:13:04 AM by Xenixa » Logged

<<< Hack's in Zend Studio

All my Custom Bebot files may be Found Here <-clicky
jjones666
BeBot Contributor
Champion
*******
Offline Offline

Posts: 353


Re: Experimental Rooster_GUILD.php
« Reply #16 on: January 28, 2006, 11:14:04 AM »

Quote from: Xenixa on January 28, 2006, 02:48:54 AM
Ya, I've noticed this one also. Smiley

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-
Logged
Xenixa
BeBot Contributor
Expert
*******
Offline Offline

Posts: 307



Re: Experimental Rooster_GUILD.php
« Reply #17 on: January 28, 2006, 12: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
Logged

<<< Hack's in Zend Studio

All my Custom Bebot files may be Found Here <-clicky
Tsuyoi
Rookie
**
Offline Offline

Gender: Male
Posts: 30


BigT


WWW
Re: Experimental Rooster_GUILD.php
« Reply #18 on: January 31, 2006, 07:09:51 PM »

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
Logged
Khalem
BeBot Founder
Administrator
Grandmaster
********
Offline Offline

Gender: Male
Posts: 670



WWW
Re: Experimental Rooster_GUILD.php
« Reply #19 on: February 01, 2006, 05: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
Logged

BeBot Founder and Fixer Kingpin
Madman coder and destroyer of good code
Tsuyoi
Rookie
**
Offline Offline

Gender: Male
Posts: 30


BigT


WWW
Re: Experimental Rooster_GUILD.php
« Reply #20 on: February 01, 2006, 10:53:28 AM »

Shibby Smiley

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

- Tsuyoi
Logged
Xenixa
BeBot Contributor
Expert
*******
Offline Offline

Posts: 307



Re: Experimental Rooster_GUILD.php
« Reply #21 on: February 01, 2006, 07:39:25 PM »

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:
/* 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);
    }

Wink
Logged

<<< Hack's in Zend Studio

All my Custom Bebot files may be Found Here <-clicky
Xenixa
BeBot Contributor
Expert
*******
Offline Offline

Posts: 307



Re: Experimental Rooster_GUILD.php
« Reply #22 on: February 08, 2006, 05: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
Logged

<<< Hack's in Zend Studio

All my Custom Bebot files may be Found Here <-clicky
Sabkor
Rookie
**
Offline Offline

Posts: 21


Re: Experimental Rooster_GUILD.php
« Reply #23 on: March 02, 2006, 10:34:39 PM »

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 Wink
Logged
Khalem
BeBot Founder
Administrator
Grandmaster
********
Offline Offline

Gender: Male
Posts: 670



WWW
Re: Experimental Rooster_GUILD.php
« Reply #24 on: March 02, 2006, 11:25:54 PM »

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)
Logged

BeBot Founder and Fixer Kingpin
Madman coder and destroyer of good code
Alreadythere
BeBot Maintainer
Administrator
Grandmaster
********
Offline Offline

Posts: 1077


Re: Experimental Rooster_GUILD.php
« Reply #25 on: March 03, 2006, 04: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.
Logged
MatHack
Guest
Re: Experimental Rooster_GUILD.php
« Reply #26 on: March 03, 2006, 11:17:08 AM »

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).
Logged
Zakus
Freshman
*
Offline Offline

Posts: 18


Re: Experimental Rooster_GUILD.php
« Reply #27 on: March 16, 2006, 11:36:03 AM »

There might be a problem in xen's Rooster_guild at around line 136.

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

I changed to this (added single quotes around the $chkmemb):
Code:
<?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 eric_borgen@hotmail.com add you on msn, thats me. If you have time to troubleshoot this Smiley

Thanks,
-Z
Logged
Xenixa
BeBot Contributor
Expert
*******
Offline Offline

Posts: 307



Re: Experimental Rooster_GUILD.php
« Reply #28 on: March 22, 2006, 04:18:57 AM »

This info no longer valid: See info in first post.
« Last Edit: May 21, 2006, 06:47:02 AM by Xenixa » Logged

<<< Hack's in Zend Studio

All my Custom Bebot files may be Found Here <-clicky
Xenixa
BeBot Contributor
Expert
*******
Offline Offline

Posts: 307



Re: Experimental Rooster_GUILD.php
« Reply #29 on: March 28, 2006, 08:29:01 AM »

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.
Logged

<<< Hack's in Zend Studio

All my Custom Bebot files may be Found Here <-clicky
Pages: 1 [2] 3 4 5   Go Up
Print
BeBot - An Anarchy Online/Age Of Conan chat automaton > Forum > Modules > Modules for older versions > 0.2.x Custom/Unofficial Modules > Topic: Experimental Rooster_GUILD.php
« previous next »
 
Jump to:  

Recent
Change text in remember "...
by gerborg
[Today at 05:14:57 PM]

Log playtime from buddys ...
by Temar
[November 20, 2008, 10:33:57 AM]

Vote Core module and Simp...
by Temar
[November 19, 2008, 09:26:52 AM]

Restrict access for one m...
by Organizer
[November 19, 2008, 03:21:19 AM]

Custom / Revised Modules ...
by Elesar1
[November 17, 2008, 03:51:46 PM]

TWC
by Temar
[November 16, 2008, 11:39:12 AM]

Are there any FUN modules...
by Elesar1
[November 15, 2008, 07:39:15 PM]

Call to a member function...
by exxie
[November 15, 2008, 09:29:31 AM]

Ported Modules
by Alreadythere
[November 14, 2008, 06:10:07 PM]

cURL and other non-defaul...
by Temar
[November 14, 2008, 04:11:44 PM]
Stats
Members
Total Members: 1235
Latest: DDDepressionnn
Stats
Total Posts: 11037
Total Topics: 1496
Online Today: 17
Online Ever: 168
(July 01, 2007, 09:30:02 PM)
Users Online
Users: 1
Guests: 15
Total: 16
Elesar1

Powered by SMF 1.1.7 | SMF © 2006-2008, Simple Machines LLC
TinyPortal v0.9.8 © Bloc | NewDef design by Bloc
Page created in 0.475 seconds with 29 queries. (Pretty URLs adds 0.044s, 4q)
Loading...