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: db version of !callers  (Read 1703 times)

0 Members and 1 Guest are viewing this topic.

Offline Malosar

  • BeBot Expert
  • ****
  • Posts: 259
  • Karma: +0/-0
    • http://www.lowerdimension.com
db version of !callers
« on: October 12, 2005, 09:52:50 pm »
Can someone whip up a modified Callers.php so it writes the data to a table it creates? As a guild raidbot, we always have the same group of callers and like to have them there and just do !callers and say which one is caller for that raid. However if bot resets, then you lose the callers list.
Eternalist
General of The Syndicate

Offline Malosar

  • BeBot Expert
  • ****
  • Posts: 259
  • Karma: +0/-0
    • http://www.lowerdimension.com
db version of !callers
« Reply #1 on: October 13, 2005, 08:05:26 pm »
nevermind, i did it myself. For anyone that wants it:

Code: [Select]
<?
  /*
   * Callers.php - Designate and list "Callers" for raids and events.
   *
   * BeBot - An Anarchy Online Chat Automaton
   * Copyright (C) 2004 Jonas Jax
   *
   * Developed by Blondengy (RK1)
   * Special thanks goes out to Khalem (RK1) for his support.
   *
   * File last changed at $LastChangedDate: 2004-12-29 01:41:32 +0100 (Wed, 29 Dec 2004) $
   * Revision: $Id: Callers.php 8 2004-12-29 00:41:32Z blondengy $
   *
   * MySQL Version modifed by Malosar: 2005-10-12
   *
   */

  $db -> query("CREATE TABLE IF NOT EXISTS callers
              (id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
              name VARCHAR(30))");

 
  $callers = new Callers($bot);


  $commands["pgmsg"]["caller"] = &$callers;
  $commands["pgmsg"]["callers"] = &$callers;




  /*
    The Class itself...
  */
  class Callers
  {
    var $bot;
    var $callers;
   
   

    /*
      Constructor:
        Hands over a referance to the "Bot" class.
    */
    function Callers (&$bot)
    {
      $this -> bot = &$bot;
      $this -> callers = array();
    }
   
   
   
    /*
      This gets called on a msg in the privgroup with the command
    */
    function pgmsg($name, $msg)
    {
      if ($this -> bot -> is_member($name))
      {
        if (preg_match("/^" . $this -> bot -> commpre . "callers/i", $msg))
          $this -> bot -> send_pgroup($this -> show_callers());
        else if (preg_match("/^" . $this -> bot -> commpre . "caller add (.+)/i", $msg,

$info))
          $this -> caller_add($info[1]);
        else if (preg_match("/^" . $this -> bot -> commpre . "caller del (.+)/i", $msg,

$info))
          $this -> caller_del($info[1]);
      }
      else
        $this -> bot -> send_pgroup("You must be a member to use this command.");
    }



    /*
      Add a caller
    */
    function caller_add($name)
    {
      $name = ucfirst(strtolower($name));

      if ($this -> bot -> aoc -> get_uid($name))
      {
$this -> bot -> db -> query("INSERT INTO callers (name) VALUES ('". $name ."')");
        $this -> bot -> send_pgroup("<font color=#ffff00>" . $name . "</font> has been added

to caller list. " . $this -> show_callers());
      }
      else
        $this -> bot -> send_pgroup("Player <font color=#ffff00>" . $name . "</font> does

not exist.");

    }



    /*
      Remove a caller
    */
    function caller_del($name)
    {
      $name = ucfirst(strtolower($name));

if ($this -> bot -> aoc -> get_uid($name) != -1)
      {
        if ($this -> bot -> db -> select("SELECT id, name FROM callers ORDER BY name"))
        {
  $this -> bot -> db -> query("DELETE FROM callers WHERE name = '" . $msg . "'");
          $this -> bot -> send_pgroup("<font color=#ffff00>" . $name . "</font> has been

removed from caller list. " . $this -> show_callers());
        }
        else
          $this -> bot -> send_pgroup("<font color=#ffff00>" . $name . "</font> is not on

list of callers. " . $this -> show_callers());
      }
      else
        $this -> bot -> send_pgroup("Player <font color=#ffff00>" . $name . "</font> does

not exist.");

    }
   
   
   
    /*
      Return the list of callers
    */
    function show_callers()
    {
      $call = $this -> bot -> db -> select("SELECT id, name FROM callers ORDER BY name");
      if (empty($call))
        return "No callers on list.";
      else
      {
        $list = "<font color=CCInfoHeadline>::: List of callers :::</font>\n\n";
        foreach ($call as $player)
          $list .= " - <a href='chatcmd:///macro ".$player[1]." /assist ".$player[1]."'>".$player[1]."</a>\n";
        return $this -> bot -> make_blob("List of Callers", $list);
      }
    }
  }
?>

Eternalist
General of The Syndicate

Offline stonybg

  • BeBot User
  • **
  • Posts: 23
  • Karma: +0/-0
Re: db version of !callers
« Reply #2 on: March 09, 2006, 06:20:44 am »
can make to work in tell and org chenal?

Offline Malosar

  • BeBot Expert
  • ****
  • Posts: 259
  • Karma: +0/-0
    • http://www.lowerdimension.com
Re: db version of !callers
« Reply #3 on: March 29, 2006, 08:50:35 pm »
You would have to ask one of the real coders here for that, im just a hackjob.
Eternalist
General of The Syndicate

Offline Naturalistic

  • Contributor
  • *******
  • Posts: 221
  • Karma: +0/-0
Re: db version of !callers
« Reply #4 on: March 30, 2006, 01:22:58 am »
Just add the following:

$commands["gc"]["callers"] = &$callers;
$commands["tell"]["callers"] = &$callers;

And make a function tell ($name, msg) and the same for gc.



220/25 Eternalist Doctor
-----------------------------
Campalot Coding Co-ordinator and Super Admin
http://www.campalot.info/index.php

 

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