BeBot - An Anarchy Online and Age Of Conan chat automaton

Development => Coding and development discussion => Topic started by: joey12344 on June 30, 2006, 05:30:41 pm

Title: Attempt of a recruition type script:
Post by: joey12344 on June 30, 2006, 05:30:41 pm
Code: [Select]
<?
    $shout = new shout($bot);

    $commands["tell"]["joinorg"] = &$shout;
    $commands["tellout"]["joinorg"] = &$shout;

    class shout
     {
       var $bot;
       function shout($bot)
      {
         $this -> bot = &$bot;
      }
 
       function tell($name)
       {
          if ( (preg_match("/^" . $this -> bot -> commpre . "shout (.+)$/i", $info)) )
      {
          $this -> spew ($name, $info[1], "gc");
      }
       }
   
       function tellout($name)
       {
          if ( (preg_match("/^" . $this -> bot -> commpre . "shout (.+)$/i", $info)) )
      {
          $this -> spew ($name, $info[1], "gc");
      }
       }
   
       function spew ($name, $where)
       {
          if ($this -> bot -> is_member($name))
      {
 
          $output = "<br>";
      $output .= "<font color=#ff0000>-------------------------</font>";
      $output .= "<font color=#ffff45>" . $name . " Wants to Join Barador Arin!! </font>";
      $output .= "<font color=#ffffc9>Click <a href='chatcmd:///tell $name'>Here</a> to send them a tell!";
      $output .= "<font color=#ff0000>-------------------------</font>";
      $output .= "<br>";
 
      switch ($where)
      {
          case "gc":
          $this -> bot -> send_gc($output);
      break;
      }
          }
       }
     }
?>

Thats the code for it , For some resaon it doesnt work when i type !joinorg to the bot , Any errors i made i would be greatful for , After all this is my first module :)

Thanks!
Title: Re: Attempt of a recruition type script:
Post by: Wolfbiter on June 30, 2006, 11:10:47 pm
Instead of flaming you (as I really really should) I'll tell you to...
1) Go read php tutorials on the web, google is Your friend!
2) Read up on how to code for BeBot, don't guess and code.
Title: Re: Attempt of a recruition type script:
Post by: Naturalistic on June 30, 2006, 11:28:41 pm
Aww, you got off easy Joey, he usually always flames. ;P
Title: Re: Attempt of a recruition type script:
Post by: Blondengy on July 01, 2006, 02:02:26 am
I haven't toutched bebot code for over a year now but as far as I remember "tell2" handles tells from people who are not a member of the bot (not tell, like you're using). (This might have been changed in recent updates though - don't take my word for it, just check the code. ;))

You also registered the command as "!joinorg" but in the preg_match you're testing for "!shout" . Ofcause that'll always return false, since the tell function only gets called on "!joinorg". ;)

Third error: You're testing if the sender is a member of the guild ($this -> bot -> is_member($name)) but if he wants to join the guild, he'll definatly not be a member... ;)

Then you're calling "spew" with three diferent parameters ($name, $info[1] and "gc") but you only defined it with two ($name and $where).

On a little side note, you might want to change "Barador Arin" to the guild name stored in "$this -> bot" so that people who also want to use this module won't have to edit the sourcecode, just the config, which they'll have edited to suit their guildname anyway. ;)

Thats about all that I can find wrong with it at first sight. ;)
Title: Re: Attempt of a recruition type script:
Post by: joey12344 on July 01, 2006, 09:09:18 am
Oh , ok :D I tried my best though
SimplePortal 2.3.7 © 2008-2024, SimplePortal