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: how to call a module command from another module  (Read 4400 times)

0 Members and 1 Guest are viewing this topic.

Offline Wanuarmi

  • Contributor
  • *******
  • Posts: 121
  • Karma: +0/-0
how to call a module command from another module
« on: December 03, 2005, 07:12:33 am »
Can I do $this -> bot -> $commands["tell"]["command"] or something?

Offline Xenixa

  • Contributor
  • *******
  • Posts: 307
  • Karma: +0/-0
how to call a module command from another module
« Reply #1 on: December 03, 2005, 08:03:16 am »
$this -> bot -> commands["tell"]["COMMAND"] -> FUNCTION CALL IN OTHER MODULE
<<< Hack's in Zend Studio

All my Custom Bebot files may be Found Here <-clicky

Offline Wanuarmi

  • Contributor
  • *******
  • Posts: 121
  • Karma: +0/-0
how to call a module command from another module
« Reply #2 on: December 03, 2005, 08:59:09 am »
great thanks :)

Offline Akarah

  • Contributor
  • *******
  • Posts: 72
  • Karma: +0/-0
    • http://synergyfactor.net/
how to call a module command from another module
« Reply #3 on: December 03, 2005, 10:16:24 am »
hmm.. would that work for things like IRC where there is no actual command to send a line to irc that way?

i've just used $this -> bot -> irc -> message()  from TowerAttack.php and am waiting to see if it works (it seems that it should, though, because the main bot class knows what $irc is..)

the $this -> bot -> commands array is handy when the modules don't have a declaration in the bot class, and the command is actually accessable via tell, like $this -> bot -> commands["tell"]["online"] from within the irc module, since there's no $this -> [bot ->] online thingie.


edit: just realized i can use $this -> bot -> commands["tell"]["irc"] -> message() heh
but is that better or worse than doing $this -> bot -> irc -> message() ? guess i'll find out when there's a tower attack ;p

/the Aka noob

Offline Akarah

  • Contributor
  • *******
  • Posts: 72
  • Karma: +0/-0
    • http://synergyfactor.net/
how to call a module command from another module
« Reply #4 on: December 03, 2005, 05:28:47 pm »
welp doesnt work either way so im outta ideas.

Offline Akarah

  • Contributor
  • *******
  • Posts: 72
  • Karma: +0/-0
    • http://synergyfactor.net/
how to call a module command from another module
« Reply #5 on: December 03, 2005, 05:40:36 pm »
heh im gonna have to make a local function in the irc class and have it call $this -> irc -> message() arent i..

think that will work?

Offline Akarah

  • Contributor
  • *******
  • Posts: 72
  • Karma: +0/-0
    • http://synergyfactor.net/
how to call a module command from another module
« Reply #6 on: December 03, 2005, 06:24:17 pm »
Quote from: "Akarah"
heh im gonna have to make a local function in the irc class and have it call $this -> irc -> message() arent i..

think that will work?


worked perfectly. i am now relaying tower attack messages to irc.

i have also added per-towerfield-target rate limiting into towerattack messages, so it will only send one notice per target per 8 seconds.

i'll post my towerattack.php when i'm home from work, i've also got the color mods done, and have integrated Alreadythere's whois caching function into it.

roxor

Offline Dabaron

  • BeBot Apprentice
  • ***
  • Posts: 163
  • Karma: +0/-0
Re: how to call a module command from another module
« Reply #7 on: August 22, 2006, 09:20:58 am »
$this -> bot -> commands["tell"]["COMMAND"] -> FUNCTION CALL IN OTHER MODULE

Would this work for sending information to the Alts command so I can have everything use the "modified" alts instead of the standard one (the one with the seen command built in and stuff)?  I'm looking at how Akarah did it in the Online.php module he made but it dosen't seem to follow this same format and I can't seem to figure out how he did it.

Offline Dabaron

  • BeBot Apprentice
  • ***
  • Posts: 163
  • Karma: +0/-0
Re: how to call a module command from another module
« Reply #8 on: September 22, 2006, 01:01:24 am »
Ok, I'm still going crazy trying to figure this out.  What I'm trying to do is in the Logon_GUILD.php file I'm trying to add an alts part. so it will look something like this:

"Dabaron" (Lvl 193 Engineer Unit Member) logged on :: alts :: Logon message

The structure it has now is fine, except teh alts part.  I found one module where it just has an alts function built into it, but I would rather access the alts.php module so if any changes are made to the alts module it affects every reference to alts without having to hunt down everywhere that makes reference and modding them individually.  Tried this ( and a few variations) but it dosen't work.  It puts a "link" in the message but nothing happens when clicked.

Code: [Select]
/*
This gets called if a buddy logs on/off
*/
function buddy($name, $msg)
{
if ($this -> start < time())
{
if ($this -> bot -> is_member($name) == 1)
{
$id = $this -> bot -> aoc -> get_uid($name);
if ($msg == 1)
{
if ($this -> last_log["on"][$name] < (time() - 5))
{
$result = $this -> bot -> db -> select("SELECT nickname, firstname, lastname, level, profession, rank_name FROM members WHERE id = " . $id);


$res = "\"" . $name . "\"";
if (!empty($result[0][1]))
$res = $result[0][1] . " " . $res;
if (!empty($result[0][2]))
$res .= " " . $result[0][2];
$res .= " (Lvl " . $result[0][3] . " " . $result[0][4] . " " . $result[0][5] . ") logged on";

$main = $this -> bot -> alts -> main($name);
$alts = $this -> bot -> alts -> get_alts($main);

if (!empty($alts))
  $message = "<a href='chatcmd:///tell <botname> <pre>alts $main'>alts</a> ";
else
$message = "";

$res .= " :: " . $message;

$result = $this -> bot -> db -> select("SELECT message FROM logon WHERE id = " . $id);
if (!empty($result))
$res .= "  ::  " . $result[0][0];

$this -> bot -> send_gc("<font color=#10a5e5>" . $res . "</font>");
$this -> last_log["on"][$name] = time();
}
}
else
{
if ($this -> last_log["off"][$name] < (time() - 5))
{
$this -> bot -> send_gc("<font color=#10a5e5>" . $name . " logged off</font>");
$this -> bot -> send_pgroup("<font color=#10a5e5>" . $name . " logged off</font>");
$this -> last_log["off"][$name] = time();
}
}
}
}
}

Offline Malosar

  • BeBot Expert
  • ****
  • Posts: 259
  • Karma: +0/-0
    • http://www.lowerdimension.com
Re: how to call a module command from another module
« Reply #9 on: September 22, 2006, 06:39:39 pm »
This is my alts section of Logon:

Code: [Select]
                                                $main = $this -> bot -> alts -> main($name);
                                                $alts = $this -> bot -> alts -> get_alts($main);

                                                $result = "<font color=CCInfoHeadline>::: " . $main . "'s Alts :::</font>\n\n";

                                                if (!empty($alts))
                                                foreach ($alts as $alt)
                                                {
                                                        $result .= "<font color=CCCCTextColor><a href='chatcmd:///tell <botname> <pre>whois $alt'>$alt</a></font>\n";
                                                }

                                                if (empty($alts))
                                                $alts = "";

                                                else if ($main == $this -> bot -> aoc -> get_uname($name))
                                                {
                                                        $alts = " :: " . $this -> bot -> make_blob("Alts", $result);
                                                }

                                                else
                                                {
                                                        $blobname = $main . "'s Alts";
                                                        $alts = " :: " . $this -> bot -> make_blob($blobname, $result);                                                 }

                                                $res .= $alts;
Eternalist
General of The Syndicate

Offline Dabaron

  • BeBot Apprentice
  • ***
  • Posts: 163
  • Karma: +0/-0
Re: how to call a module command from another module
« Reply #10 on: September 22, 2006, 06:56:50 pm »
Yeah, I can code in to pull the alts manually within the module and just display them but that is counter productive to what I am trying to do.  I want it to access the already existing Alts.php module if possible so that way if I make a change to the way the alts look (like using the modified alts with the last seen info for example) it will show that in the logon message as well.

Offline Malosar

  • BeBot Expert
  • ****
  • Posts: 259
  • Karma: +0/-0
    • http://www.lowerdimension.com
Re: how to call a module command from another module
« Reply #11 on: September 22, 2006, 07:10:02 pm »
You can't make a href chatcmd to a word with some text and think that it will magically make a blob. You must use the make_blob command as it shows in my alts section. Once you have a list of alts in an array pass each name of that list through a foreach and .= a string the the name in the format you want. Then pass that string through a make_blob function and add that string to the end of the logon where you want it.
Eternalist
General of The Syndicate

Offline Dabaron

  • BeBot Apprentice
  • ***
  • Posts: 163
  • Karma: +0/-0
Re: how to call a module command from another module
« Reply #12 on: September 23, 2006, 04:16:14 am »
I realize that to make my own blob, however I don't want to write the alts functionality into this module and everything, I want it to use the already made alts module.

Is this possible?

Offline Malosar

  • BeBot Expert
  • ****
  • Posts: 259
  • Karma: +0/-0
    • http://www.lowerdimension.com
Re: how to call a module command from another module
« Reply #13 on: September 23, 2006, 03:48:03 pm »
You have $main and $alts from the alts module. Can you try $this -> bot -> alts -> make_alt_blob($main,$alts) ? Then add the result to the logon text.
Eternalist
General of The Syndicate

Offline Dabaron

  • BeBot Apprentice
  • ***
  • Posts: 163
  • Karma: +0/-0
Re: how to call a module command from another module
« Reply #14 on: September 28, 2006, 09:28:15 am »
Yeah, that worked.  I can't believe I didn't think of that   :-\

Thanks for the help

 

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