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

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

Author Topic: 0.5.0_Support.php (so 0.5.0 modules work)  (Read 29675 times)

0 Members and 1 Guest are viewing this topic.

Offline Ixiaan

  • BeBot Rookie
  • *
  • Posts: 7
  • Karma: +0/-0
Re: 0.5.0_Support.php (so 0.5.0 modules work)
« Reply #15 on: September 02, 2008, 12:49:26 am »
I'm having a problem with the automember module:

Parse error: parse error, unexpected T_VARIABLE, expecting ';' in ...\custom\modules\0.5.0_Support.php(67) : eval()'d cod on line 321

Using Bebot 4.3, any idea what the problem is?

Offline Temar

  • Contributor
  • *******
  • Posts: 1140
  • Karma: +0/-0
    • AoFiles
Re: 0.5.0_Support.php (so 0.5.0 modules work)
« Reply #16 on: September 02, 2008, 04:09:13 am »
its an error in the automember module
Line 314:                   unset($this -> invites[$name])
add a ; so its
                  unset($this -> invites[$name]);

unable to update attached file as adding/deleting attachments are currently broke

Offline Temar

  • Contributor
  • *******
  • Posts: 1140
  • Karma: +0/-0
    • AoFiles
Re: 0.5.0_Support.php (so 0.5.0 modules work)
« Reply #17 on: September 24, 2008, 08:13:43 pm »
this update will work

* Removed (old)
« Last Edit: October 20, 2008, 02:24:31 am by Temar »

Offline Temar

  • Contributor
  • *******
  • Posts: 1140
  • Karma: +0/-0
    • AoFiles
Re: 0.5.0_Support.php (so 0.5.0 modules work)
« Reply #18 on: October 20, 2008, 02:25:02 am »
Ok i have Fixed the Register_event function

Code: [Select]
<?php

// Version 0.9

define("SAME"1);
define("TELL"2);
define("GC"4);
define("PG"8);
define("RELAY"16);
define("IRC"32);
define("ALL"255);


class 
BasePassiveModule
{
protected $bot// A reference to the bot
public $module_name//Name of the module extending this class.

function __construct (&$bot$module_name)
{
//Save reference to bot
$this -> bot = &$bot;
$this -> module_name $module_name;
$this -> link_name NULL;
$this -> error = new BotError($bot$module_name);
}

protected function register_event($event$target=false)
{
$event strtolower($event);

$events = array('connect''disconnect''pgjoin''pgleave''buddy''privgroup''gmsg''cron''timer''logon_notify''pginvite''extpgjoin''extpgleave''tells''extprivgroup');
if(in_array($event$events))
{
if($event == 'gmsg')
{
if ($target)
{
$this -> bot -> commands[$event][$target][get_class($module)] = &$module;
return false;
}
else
{
return "No channel specified for gmsg. Not registering.";
}
}
elseif($event == 'cron')
{
$time strtotime($target0);

if($time 0)
{
if (!isset($this -> cron_job_active[$time]))
{
  $this -> cron_job_active[$time] = false;
}
if (!isset($this -> cron_job_timer[$time]))
{
$this -> cron_job_timer[$time] = max(time(), $this -> startup_time);
}
$this -> cron_times[$time] = $time;
$this -> cron[$time][get_class($module)] = &$module;
return false;
}
else
{
return "Cron time '$target' is invalid. Not registering.";
}
}
elseif ($event == 'timer')
{
if ($target)
{
$this -> bot -> timer -> register_callback($target, &$module);
return false;
}
else
{
return "No name for the timer callback given! Not registering.";
}
}
elseif ($event == 'logon_notify')
{
$this -> bot -> logon_notify -> register(&$module);
return false;
}
else
{
$this -> bot -> commands[$event][get_class($module)] = &$module;
return false;
}
}
else
{
return "Event '$event' is invalid. Not registering.";
}
return false;
}

/* protected function register_module($name)
{
$this -> bot -> register_module(&$this, strtolower($name));
// TODO: Use $module_name in general as $name? May require a bit of code editing - though that has to happen anyways...
// TODO: Everytime a line like $bot -> var = &$class gets replaced with this function do global search and replace!
} */

protected function output($name$msg$channel=false)
{
if($channel!==false)
{
if($channel SAME)
{
if($channel $this->source)
{
$channel -= SAME;
}
else
{
$channel += $this->source;
}
}
}
else
{
$channel += $this->source;
}
if ($channel TELL)
$this->bot->send_tell($name$msg);
if ($channel GC)
$this->bot->send_gc($msg);
if($channel PG)
$this->bot->send_pgroup($msg);
if($channel RELAY)
$this->bot->relay->relay_to_pgroup($name$msg);
if($channel IRC)
$this->bot->irc->send_irc($this->module_name$name$msg);
}

public function __call($name$args)
{
$args=implode(', '$args);
$msg "Undefined function $name($args)!";
$this->error->set($msg);
return $this->error->message();
}
}

$support_05 = new Support_05($bot);

$bot -> support_05 = &$support_05;

class 
Support_05
{
var $bot;

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

$this -> update_table($this -> bot -> db -> master_tablename"schemaversion""add""ALTER TABLE ".$this -> bot -> db -> master_tablename." ADD COLUMN schemaversion INT(3) NOT NULL DEFAULT 1"FALSE);
}

function get_timer($id)
{
$ret $this -> bot -> db -> select("SELECT * FROM #___timer WHERE id = " $idMYSQL_ASSOC);
if (empty($ret))
{
return NULL;
}
else
{
return $ret[0];
}
}

function list_timed_events($owner)
{
return $this -> bot -> db -> select("SELECT id, name FROM #___timer WHERE channel = 'internal' AND owner = '"
$owner "'"MYSQL_ASSOC);
}

function get_version($table)
{
$version $this -> bot -> db -> select("SELECT schemaversion, use_prefix FROM " $this -> bot -> db -> master_tablename " WHERE internal_name = '" $table "'");
if(!empty($version))
{
if($version[0][1] == "false")
{
$version2 $this -> bot -> db -> select("SELECT schemaversion FROM table_versions WHERE internal_name = '" $table "'");
if(!empty($version2))
{
Return($version2[0][0]);
}
}
Return($version[0][0]);
}
else
{
Return(1);
}
}

function set_version($table$version)
{
if(!is_numeric($version))
{
$this -> bot -> log("DB""ERROR""Trying to set version: " $version " for table " $table "!");
}
else
{
$this -> bot -> db -> query("UPDATE " $this -> bot -> db -> master_tablename " SET schemaversion = ".$version." WHERE internal_name = '" $table "'");
$usep $this -> bot -> db -> select("SELECT use_prefix FROM " $this -> bot -> db -> master_tablename " WHERE internal_name = '" $table "'");
if($usep[0][0] == "false")
{
$this -> bot -> db -> query("INSERT INTO table_versions (internal_name, schemaversion) VALUES ('".$table."', ".$version.") ON DUPLICATE KEY UPDATE schemaversion = VALUES(schemaversion)");
}
}
}

function update_table($table$column$action$query$prefix TRUE)
{
if($prefix)
$sql "#___";
$fields $this -> bot -> db -> select("EXPLAIN " $sql $tableMYSQL_ASSOC);
if (!empty($fields))
{
foreach ($fields AS $field)
{
$columns[$field['Field']] = TRUE;
}
}

Switch(strtolower($action))
{
case 'add'// make sure it doesnt exist
$do TRUE;
if(is_array($column))
{
foreach($column as $c)
{
if(isset($columns[$c]))
$do FALSE;
}
}
else
{
if(isset($columns[$column]))
$do FALSE;
}
if($do)
{
$this -> bot -> db -> query($query);
}
Break;
case 'drop'// Make sure it does exist
case 'alter':
case 'modify':
$do TRUE;
if(is_array($column))
{
foreach($column as $c)
{
if(!isset($columns[$c]))
$do FALSE;
}
}
else
{
if(!isset($columns[$column]))
$do FALSE;
}
if($do)
{
$this -> bot -> db -> query($query);
}
Break;
case 'change':
if(isset($columns[$column[0]]) && !isset($columns[$column[1]]))
{
$this -> bot -> db -> query($query);
}
Break;
Default:
echo "Unknown MYSQL UPDATE Action '".$action."'";
$this -> bot -> db -> query($query);
}
}
}

abstract class 
BaseActiveModule extends BasePassiveModule
{
public $help//A window containing help text for this module
protected $source;

function __construct (&$bot$module_name)
{
//Save reference to bot
parent::__construct(&$bot$module_name);
}

// Prototype for the command_handler
abstract protected function command_handler($name$msg$origin);

// Interface to register command. Now with checks for duplicate command definitions.
// $channel is the channel the command should be registered for. "all" can be used to register a command for gc, pgmsg and tell at once.
// $command is the command to register.
// $access is the minimum access level required to use the command on default.
// $subcommands is an array with keys of subcommands and entries of access levels to define access
// rights for possible subcommands. If $subcommands is NULL it will be ignored.
protected function register_command($channel$command$access "OWNER"$subcommands NULL)
{
$levels=array('ANONYMOUS''GUEST''MEMBER''LEADER''ADMIN''SUPERADMIN''OWNER');
$channels = array('gc''pgmsg''tell''extpgmsg''all');
$allchannels = array ('gc''pgmsg''tell');
if((in_array($channel$channels))&&(in_array($access$levels)))
{
if($channel == "all")
{
$this -> bot -> commands["gc"][$command] = &$this;
$this -> bot -> commands["pgmsg"][$command] = &$this;
$this -> bot -> commands["tell"][$command] = &$this;
}
else
{
$this -> bot -> commands[$channel][$command] = &$this;
}
$this -> bot -> accesscontrol -> create($channel$command$access);
if ($subcommands != NULL)
{
foreach ($subcommands AS $subcommand => $subacl)
{
$this -> bot -> accesscontrol -> create_subcommand($channel$command$subcommand$subacl); 
}
}
}
else
{
echo "Illegal channel or access level when registering command '$command'\n";
}
}

// Registers a command alias for an already defined command.
protected function register_alias($command$alias)
{
//$this -> bot -> commandalias -> register($command, $alias);
}

// This function aids in parsing the command.
protected function parse_com($command$pattern = array('com''sub''args'))
{
//preg_match for items and insert a replacement.
$search_pattern='|<a href="itemref://([0-9]+)/([0-9]+)/([0-9]{1,3})">([^<]+)</a>|';
$item_count preg_match_all($search_pattern$command$itemsPREG_SET_ORDER);
for($cnt 0$cnt $item_count$cnt++)
{
$command preg_replace($search_pattern"##item_$cnt##"$command1);
}

//Split the command
$num_pieces=count($pattern);
$num_com=count(explode(' '$command));
$pieces explode(' '$command$num_pieces);
$com array_combine(array_slice($pattern0$num_com), $pieces);

//Replace any item references with the original item strings.
foreach($com as &$com_item)
{
for($cnt 0$cnt $item_count$cnt++)
{
$com_item=str_replace("##item_$cnt##"$items[$cnt][0], $com_item);
}
}
unset($com_item);
return ($com);
}

/************************************************************************
 Default to replying in the same channel as the command has been recieved
*************************************************************************/

public function reply($name$msg)
{
if ($msg != false)
{
if($msg instanceof BotError)
{
//We got an error. Return the error message.
$this->reply($name$msg->message());
}
else
{
$this -> output($name"##normal##$msg##end##"SAME);
}
}
}

public function tell($name$msg)
{
$this->source=TELL;
$this->error->reset();
$reply $this -> command_handler($name$msg"tell");
if(($reply !== false) && ($reply !==''))
{
$this->reply($name$reply);
}
}

public function gc($name$msg)
{
$this->source=GC;
$this->error->reset();
$reply $this -> command_handler($name$msg"gc");
if(($reply !== false) && ($reply !==''))
{
$this->reply($name$reply);
}
}

public function pgmsg($name$msg)
{
$this->source=PG;
$this->error->reset();
$reply $this -> command_handler($name$msg"pgmsg");
if(($reply !== false) && ($reply !==''))
{
$this->reply($name$reply);
}
}
}

class 
BotError
{
private $bot;
protected $status;
private $is_fatal;
private $description;
private $source;

function __construct(&$bot$module)
{
$this-> status=false;
$this->is_fatal=false;
$this->description='';
$this->source=$module;
$this->bot=$bot;
}

function status()
{
return $this->status;
}

function reset()
{
$this->status=false;
$this->is_fatal=false;
$this->description='';
}

function set($description$log=true$fatal=false)
{
$this->description $description;
$this->is_error=true;
$this->is_fatal $fatal;
if($log)
{
$this -> bot -> log('ERROR'$this->source$description);
}
if($fatal)
{
$this -> bot -> log('FATAL'$this->source$description);
exit(1);
}
}

function get()
{
return $this->description;
}

function message()
{
return "##error##Error: ##end##The module ##highlight##{$this->source}##end## returned the error ##error##{$this->description}##end##";
}
}
if (
is_dir("./custom/050"))
{
$bot -> log("050-CUSTOM""DIR""Loading Version 0.5.0 Modules in directory custom/050/");
$folder05 dir("./custom/050/");
while ($mod050 $folder05 -> read())
{
if (!is_dir($mod050) && !preg_match("/^_/"$mod050) && preg_match("/\.php$/i"$mod050)
&& $value != "FALSE")
{
// get contents of a file into a string
$filename "./custom/050/".$mod050;
$handle fopen($filename"r");
$contents fread($handlefilesize($filename));
fclose($handle);

$contents str_replace('$this->bot->core->db''$this -> bot -> core -> db'$contents);
$contents str_replace('$this->bot->core->timer''$this -> bot -> core -> timer'$contents);
$contents str_replace('$this->bot->core''$this -> bot -> core'$contents);
$contents str_replace("<?php"""$contents);
$contents str_replace("<?"""$contents);
$contents str_replace("?>
", "", $contents);
$contents = str_replace("function command_handler", 'function command_handler($name, $msg, $type)
{
$msg = substr($msg, 1);
Return $this -> command_handler2($name, $msg, $type);
}

function command_handler2', $contents);

$contents = str_replace('$this -> bot -> core("access_control")', '$this -> bot -> accesscontrol', $contents);
$contents = str_replace('$this -> bot -> core("security")', '$this -> bot -> security', $contents);
$contents = str_replace('$this -> bot -> core("settings")', '$this -> bot -> settings', $contents);
$contents = str_replace('$this -> bot -> core("chat")', '$this -> bot -> chat', $contents);
$contents = str_replace('$this -> bot -> core("help")', '$this -> bot -> help', $contents);
$contents = str_replace('$this -> bot -> core("ini")', '$this -> bot -> ini', $contents);
$contents = str_replace('$this -> bot -> core("chat_queue")', '$this -> bot -> queue', $contents);
$contents = str_replace('$this -> bot -> core("colors")', '$this -> bot -> colors', $contents);
$contents = str_replace('$this -> bot -> core("command_alias")', '$this -> bot -> commandalias', $contents);
$contents = str_replace('$this -> bot -> core("notify")', '$this -> bot -> notify', $contents);
$contents = str_replace('$this -> bot -> core("alts")', '$this -> bot -> alts', $contents);
$contents = str_replace('$this -> bot -> core("logon_notifies")', '$this -> bot -> logon_notify', $contents);
$contents = str_replace('$this -> bot -> core("timer")', '$this -> bot -> timer', $contents);
$contents = str_replace('$this -> bot -> core("user")', '$this -> bot -> user', $contents);
$contents = str_replace('$this -> bot -> core("whois")', '$this -> bot -> whois', $contents);
$contents = str_replace('$this -> bot -> core("shortcuts")', '$this -> bot -> shortcuts', $contents);
$contents = str_replace('$this -> bot -> core("tools")', '$this -> bot', $contents);
$contents = str_replace('$this -> bot -> core("time")', '$this -> bot -> time', $contents);
$contents = str_replace('$this -> bot -> timer -> get_timer', '$this -> bot -> support_05 -> get_timer', $contents);
$contents = str_replace('$this -> bot -> timer -> list_timed_events', '$this -> bot -> support_05 -> list_timed_events', $contents);
$contents = str_replace('$this -> bot -> db -> get_version', '$this -> bot -> support_05 -> get_version', $contents);
$contents = str_replace('$this -> bot -> db -> set_version', '$this -> bot -> support_05 -> set_version', $contents);
$contents = str_replace('$this -> bot -> db -> update_table', '$this -> bot -> support_05 -> update_table', $contents);

$bot -> log("050-CUSTOM", "LOAD", $mod050);
eval($contents);
}
}
echo "\n";
}
?>

Offline Slacklin

  • BeBot User
  • **
  • Posts: 52
  • Karma: +0/-0
  • My spoon is too big!
    • United Org Site
Re: 0.5.0_Support.php (so 0.5.0 modules work)
« Reply #19 on: October 24, 2008, 11:13:17 am »
The latest version now gives the following error when it is in use.

Fatal error: Call to a member function connect() on a non-object in C:\<botdir>\Sources\Bot.php on line 236

Any ideas?

Offline Slacklin

  • BeBot User
  • **
  • Posts: 52
  • Karma: +0/-0
  • My spoon is too big!
    • United Org Site
Re: 0.5.0_Support.php (so 0.5.0 modules work)
« Reply #20 on: December 29, 2008, 08:04:36 pm »
Any thoughts on this, I am still having issues with the 0.9 version of the 0.5.0 module regarding the above error.

Offline Pharexys

  • BeBot Apprentice
  • ***
  • Posts: 117
  • Karma: +0/-0
Re: 0.5.0_Support.php (so 0.5.0 modules work)
« Reply #21 on: March 16, 2009, 12:10:14 am »
any1 know link to download this?

Offline Temar

  • Contributor
  • *******
  • Posts: 1140
  • Karma: +0/-0
    • AoFiles
Re: 0.5.0_Support.php (so 0.5.0 modules work)
« Reply #22 on: March 16, 2009, 01:12:09 am »
the module is posted inside my post, just above

 

* Recent Posts
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 ]


Bebot and Rasberry by bitnykk
[November 29, 2023, 11:04:14 pm ]

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