collapse collapse
* User Info
 
 
Welcome, Guest. Please login or register.
* Search

* Board Stats
  • stats Total Members: 989
  • stats Total Posts: 18366
  • stats Total Topics: 2501
  • stats Total Categories: 7
  • stats Total Boards: 35
  • stats Most Online: 1144

Author Topic: update a code for 0.6.3  (Read 9458 times)

0 Members and 1 Guest are viewing this topic.

Offline clashbot

  • BeBot Expert
  • ****
  • Posts: 295
  • Karma: +0/-0
    • Ascension's Home
update a code for 0.6.3
« on: July 06, 2009, 06:07:37 am »
Hi my org was recently invited to an alliance, and they are all using 0.4.3 bebot. Naturally, I am running the latest and greatest, and working on converting them (heh heh). In the mean time they have a custom script that they use to pool the online lists into a separate db, and unfortunately it is still using a lot of the depreciated commands that are for 0.4.3. Can I have someone take a look at it and tell me what needs to be changed for it to work on 0.6.3? code is as follows:
Code: [Select]
<?php
$Allup 
= new Allup($bot);

$commands["buddy"][] = &$Allup;
$commands["connect"][] = &$Allup;

$commands["gc"]["aonline"] = &$Allup;
$commands["pgmsg"]["aonline"] = &$Allup;
$commands["tell"]["aonline"] = &$Allup;

$commands["gc"]["all"] = &$Allup;
$commands["pgmsg"]["all"] = &$Allup;
$commands["tell"]["all"] = &$Allup;

class 
Allup
{
var $bot;
var $start;

function Allup (&$bot)
{
$this -> bot = &$bot;

$this -> bot -> accesscontrol -> create("gc""aonline""GUEST");
$this -> bot -> accesscontrol -> create("pgmsg""aonline""GUEST");
$this -> bot -> accesscontrol -> create("tell""aonline""GUEST");

$this -> bot -> accesscontrol -> create("gc""all""GUEST");
$this -> bot -> accesscontrol -> create("pgmsg""all""GUEST");
$this -> bot -> accesscontrol -> create("tell""all""GUEST");

$this -> bot -> settings -> create("Allup""Enable_send"TRUE"Should the bot send online list to the alliance database?");
$this -> bot -> settings -> create("Allup""Enable_all"TRUE"Should this script be called using the 'online' command?");
$this -> bot -> settings -> create("Allup""Enable_aonline"TRUE"Should this script be called using the 'aonline' command?");
$this -> bot -> settings -> create("Allup""Alliance_address""hidden database address""The Internet address for the alliance files.");
$this -> bot -> settings -> create("Allup""Alliance_password""hidden database password""The password for accessing the alliance remote files.");
}


function buddy($name$msg)
{
if (($this -> start time()) && ($this -> bot -> settings -> get("Allup""Enable_send")))
{
if ($this -> bot -> notify -> check($name))
{
$online $this -> bot -> db -> select("SELECT t1.nickname, level, org_rank, org_name, profession FROM "
"#___online AS t1 LEFT JOIN #___whois AS t2 ON t1.nickname = t2.nickname WHERE status_gc=1 "
"ORDER BY profession ASC, t1.nickname ASC");

foreach ($online as $player)
{
$alname .= "|" $player[0];
$allevel .= "|" $player[1];
$alprof .= "|" $player[4];
$alorg .= "|" $this -> bot -> guildname;
$alrank .= "|" $player[2];
}

$query str_replace(" ""%20"$this -> bot -> settings -> get("Allup""Alliance_address") . "alliance.php?names="
substr($alname1) .  "&levels="
substr($allevel1) . "&profs="
substr($alprof1) .  "&orgs="
substr($alorg1) .   "&ranks="
substr($alrank1) .   "&pwd="
$this -> bot -> settings -> get("Allup""Alliance_password")); 

file($query);
}
}
}


function connect()
{
$this -> start time() + $this -> bot -> crondelay;
}


function tell($source$msg)
{
$this -> handler ($source$msg1);
}

function pgmsg($source$msg)
{
$this -> handler ($source$msg2);
}

function gc($source$msg)
{
$this -> handler ($source$msg3);
}


function handler($source$msg$type)
{
$vars explode(' 'strtolower($msg));
if (!empty($this -> bot -> commpre))
{
$vars[0] = substr($vars[0], 1);
}

$command $vars[0];

switch($command)
{
case 'aonline':
if ($this -> bot -> settings -> get("Allup""Enable_aonline"))
{
$the_list file($this -> bot -> settings -> get("Allup""Alliance_address") . "online.php");
$inside implode(""$the_list);
$blob trim($the_list[0]) . " :: " $this -> bot -> make_blob("click to view"$inside);
$this -> bot -> send_output($source$blob$type);
}
break;

case 'all':
if ($this -> bot -> settings -> get("Allup""Enable_all"))
{
$the_list file($this -> bot -> settings -> get("Allup""Alliance_address") . "online.php");
$inside implode(""$the_list);
$blob trim($the_list[0]) . " :: " $this -> bot -> make_blob("click to view"$inside);
$this -> bot -> send_output($source$blob$type);
}
break;

default:
$this -> bot -> send_output($source"Broken plugin, recieved unhandled command: $command"$type);
}
}
}
?>


Offline Slacklin

  • BeBot User
  • **
  • Posts: 52
  • Karma: +0/-0
  • My spoon is too big!
    • United Org Site
Re: update a code for 0.6.3
« Reply #1 on: July 06, 2009, 10:22:30 am »
Have you tried this module with the 0.4.0 support module?

http://bebot.link/0-5-x-customunofficial-modules/0-4_support-for-latest-0-5/

It may work since it can translate old bebot code to work with 0.5.0 and 0.6.2 (in theory)

Offline clashbot

  • BeBot Expert
  • ****
  • Posts: 295
  • Karma: +0/-0
    • Ascension's Home
Re: update a code for 0.6.3
« Reply #2 on: July 06, 2009, 12:34:46 pm »
yes I have (as I do use a few of the 0.4.x social modules). It defaults to the broken plugin.

Offline clashbot

  • BeBot Expert
  • ****
  • Posts: 295
  • Karma: +0/-0
    • Ascension's Home
Re: update a code for 0.6.3
« Reply #3 on: July 06, 2009, 08:38:10 pm »
ok, I attempted this myself, but messed up somewhere. Looks to be somewhere in the command handler, as it is passing off the user as the $source

Here is the updated code:
Code: [Select]
<?php
$allup 
= new allup($bot);
class 
allup extends BaseActiveModule
{
var $bot;
var $start;

function __construct(&$bot)
{
parent::__construct(&$botget_class($this));

$this -> register_command("all""aonline""GUEST");
$this -> register_command("all""all""GUEST");
$this -> bot -> core("settings") -> create("allup""Enable_send"TRUE"Should the bot send online list to the alliance database?");
$this -> bot -> core("settings") -> create("allup""Enable_all"TRUE"Should this script be called using the 'all' command?");
$this -> bot -> core("settings") -> create("allup""Enable_aonline"TRUE"Should this script be called using the 'aonline' command?");
$this -> bot -> core("settings") -> create("allup""Alliance_address""***********""The internet address for the alliance files.");
$this -> bot -> core("settings") -> create("allup""Alliance_password""***********""The password for accessing the alliance remote files.");
}
function buddy($name$msg)
{
if (($this -> start time()) && ($this -> bot -> core("settings") -> get("allup""Enable_send")))
{
if ($this -> bot -> core("notify") -> check($name))
{
$online $this -> bot -> db -> select("SELECT t1.nickname, level, org_rank, org_name, profession FROM "
"#___online AS t1 LEFT JOIN #___whois AS t2 ON t1.nickname = t2.nickname WHERE status_gc=1 "
"ORDER BY profession ASC, t1.nickname ASC");

foreach ($online as $player)
{
$alname .= "|" $player[0];
$allevel .= "|" $player[1];
$alprof .= "|" $player[4];
$alorg .= "|" $this -> bot -> guildname;
$alrank .= "|" $player[2];
}
}
}
}
function connect()
{
$this -> start time() + $this -> bot -> crondelay;
}


function tell($source$msg)
{
$this -> handler ($source$msg1);
}

function pgmsg($source$msg)
{
$this -> handler ($source$msg2);
}

function gc($source$msg)
{
$this -> handler ($source$msg3);
}


function command_handler($source$msg$type)
{
$vars explode(' 'strtolower($msg));
if (!empty($this -> bot -> commpre))
{
$vars[0] = substr($vars[0], 1);
}

$command $vars[0];

switch($command)
{
case 'aonline':
if ($this -> bot -> core("settings") -> get("Allup""Enable_aonline"))
{
$the_list file($this -> bot -> core("settings") -> get("Allup""Alliance_address") . "online.php");
$inside implode(""$the_list);
$blob trim($the_list[0]) . " :: " $this -> bot -> core("tools") -> make_blob("click to view"$inside);
$this -> bot -> core("tools") -> send_output($source$blob$type);
}
break;

case 'all':
if ($this -> bot -> core("settings") -> get("Allup""Enable_all"))
{
$the_list file($this -> bot -> settings -> get("Allup""Alliance_address") . "online.php");
$inside implode(""$the_list);
$blob trim($the_list[0]) . " :: " $this -> bot -> core("tools") -> make_blob("click to view"$inside);
$this -> bot -> core("tools") -> send_output($source$blob$type);
}
break;

default:
$this -> bot -> send_output($source"Broken plugin, recieved unhandled command: $command"$type);
}
}
}
?>

Offline Alreadythere

  • BeBot Maintainer
  • BeBot Hero
  • ******
  • Posts: 1288
  • Karma: +0/-0
Re: update a code for 0.6.3
« Reply #4 on: July 06, 2009, 11:14:48 pm »
Remove the if (!empty(compre)) part including the substring in there, the command prefix is removed before handing over commands to the modules now. And remove the var $bot definition, it's done in BaseActiveModule. Otherwise looks ok.

Offline clashbot

  • BeBot Expert
  • ****
  • Posts: 295
  • Karma: +0/-0
    • Ascension's Home
Re: update a code for 0.6.3
« Reply #5 on: July 06, 2009, 11:21:03 pm »
ok, running the command I get: undefined function handler(lillitheve, aonline, 1)! on the console

somehow it is passing the character as $source


Offline Alreadythere

  • BeBot Maintainer
  • BeBot Hero
  • ******
  • Posts: 1288
  • Karma: +0/-0
Re: update a code for 0.6.3
« Reply #6 on: July 07, 2009, 06:11:16 pm »
Sorry - either change handler() to command_handler() in the tell(), gc() and pgmsg() functions, or simply remove those three functions.

Offline clashbot

  • BeBot Expert
  • ****
  • Posts: 295
  • Karma: +0/-0
    • Ascension's Home
Re: update a code for 0.6.3
« Reply #7 on: July 07, 2009, 06:52:00 pm »
new errors:
using !all gets me: call to member function get() on a non-object line 85

using aonline gets me:
[error] [tools] undefined function send_output(lilltheve, 16 alliance members online :: [link]click to view[/linl],1)!


 

* Recent Posts
Com bot module by bitnykk
[November 25, 2024, 05:36:11 pm ]


0.8.x updates for AO by bitnykk
[June 23, 2024, 03:19:47 pm ]


0.8.x updates for AoC by bitnykk
[June 23, 2024, 03:19:44 pm ]


[AoC] special char for items module by bitnykk
[February 09, 2024, 09:41:18 pm ]


BeBot still alive & kicking ! by bitnykk
[December 17, 2023, 12:58:44 am ]

* Who's Online
  • Dot Guests: 218
  • 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