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: Guild Alliance Chat  (Read 10511 times)

0 Members and 1 Guest are viewing this topic.

Offline -Fionn-

  • BeBot Rookie
  • *
  • Posts: 9
  • Karma: +0/-0
Guild Alliance Chat
« on: February 08, 2009, 07:36:35 pm »
I would like to setup a simple guild alliance chat module between two bebots. How I want it to work is that it will use the builtin 'Say' module on the bot. So basically people in guildchat type "!alliance We need help in Keshatta, lots of xyz guild are around killing everyone" and the alliance module then takes that message and sends it in a tell to the other bot with Say before the message so it displays in their guild chat. Both bots would be members of the other bot to allow this to work. I know it should be quite simple to setup but I don't know exactly how to create the module.

Can someone please show me how I get the bot to send a tell in php? Do I use chatcmd:// or how do I do it. Any help you can give would be appreciated. In case of other suggestions to make this work, we don't want all normal guild chat to be linked but we want to be able to speak in each others guild chat when needed.

Thanks,
Fionn

Offline -Fionn-

  • BeBot Rookie
  • *
  • Posts: 9
  • Karma: +0/-0
Re: Guild Alliance Chat
« Reply #1 on: February 09, 2009, 12:14:38 pm »
So basically all I need to know is how I write in php to get the bot to send a tell to someone in game?

Offline Alreadythere

  • BeBot Maintainer
  • BeBot Hero
  • ******
  • Posts: 1288
  • Karma: +0/-0
Re: Guild Alliance Chat
« Reply #2 on: February 09, 2009, 05:28:10 pm »
$this->bot->send_tell($targetbot, "!say " . $whatever) is your friend ;)

Offline Temar

  • Contributor
  • *******
  • Posts: 1140
  • Karma: +0/-0
    • AoFiles
Re: Guild Alliance Chat
« Reply #3 on: February 09, 2009, 05:33:58 pm »
you should actually put <pre> instead of ! that way it will put your prefix even if your change it

or if the target being a dif bot and they might not have same prefix you might wana add a setting were you can define it

or dont use prefix at all but this will req the bot to allow no prefix (most do)
« Last Edit: February 09, 2009, 05:35:41 pm by Temar »

Offline -Fionn-

  • BeBot Rookie
  • *
  • Posts: 9
  • Karma: +0/-0
Re: Guild Alliance Chat
« Reply #4 on: February 09, 2009, 06:34:45 pm »
Excellent, thanks very much for your help. I should be able to sort this out now. :D

Offline -Fionn-

  • BeBot Rookie
  • *
  • Posts: 9
  • Karma: +0/-0
Re: Guild Alliance Chat
« Reply #5 on: February 10, 2009, 12:21:20 am »
This is my code

Code: [Select]
<?php

$alliance 
= new alliance($bot);

class 
alliance Extends BaseActiveModule
{
var $bot;
var $msg;




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

$this -> register_command("alliance");

$this -> help['description'] = 'Alliance Message Module';
$this -> help['command']['alliance <message>'] = "- Send a message to allied guild.";

}

function command_handler($name$msg$origin)
{
if (preg_match("/^alliance$/i"$msg))
                        return 
$this -> send_message($msg);
else    return "Learn how to use the command. See !help alliance";

}

function send_message($msg)
{
$this->bot->send_tell(bettie"say " $msg)
}
}
?>


When I attempt to start the bot it tells me that there is an unexpected } at line 34. I have checked a few times and I don't see that I have an extra } in there so I presume it's something else I have incorrect?

Offline Temar

  • Contributor
  • *******
  • Posts: 1140
  • Karma: +0/-0
    • AoFiles
Re: Guild Alliance Chat
« Reply #6 on: February 10, 2009, 02:47:54 am »
because you missed the ; at end of the $this->bot->send_tell(bettie, "say " . $msg)

Offline Temar

  • Contributor
  • *******
  • Posts: 1140
  • Karma: +0/-0
    • AoFiles
Re: Guild Alliance Chat
« Reply #7 on: February 10, 2009, 02:51:31 am »
also you should put bettie in  " "
you also need to use no color by telling the function to not color it see below
Code: [Select]
$this -> bot -> send_tell("bettie", "say " . $msg, 0, FALSE);

Offline -Fionn-

  • BeBot Rookie
  • *
  • Posts: 9
  • Karma: +0/-0
Re: Guild Alliance Chat
« Reply #8 on: February 10, 2009, 11:50:29 am »
Thanks again for your help, I'll add the changes and hopefully it will work.

Offline -Fionn-

  • BeBot Rookie
  • *
  • Posts: 9
  • Karma: +0/-0
Re: Guild Alliance Chat
« Reply #9 on: February 10, 2009, 01:14:31 pm »
I got the module working. This is the code I used in the end. Thanks for your help on this one. Note that I don't have a great understanding of php so I mostly went on using code from the say module and adapting it for what I needed this one to do. So I am sure its far from perfect but it works quite well so I'm happy!

Code: [Select]
<?php

$Alliance 
= new alliance($bot);

class 
alliance Extends BaseActiveModule
{
var $bot;
var $msg;




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

$this -> register_command("all""alliance""MEMBER");

$this -> help['description'] = 'Alliance Message Module';
$this -> help['command']['alliance <message>'] = "- Send a message to allied guild.";

}

function command_handler($name$msg$source)
{
$filters "rot13|chef|eleet|fudd|pirate|nofont";
if (preg_match("/^alliance (".$filters.") (.+)$/i"$msg$info))
return $this -> send_message($name$info[2], $info[1]);
else if (preg_match("/^alliance (.+)$/i"$msg$info))
return $this -> send_message($name$info[1]);
else    return "Learn how to use the command. See !help alliance";

}

function send_message($name$message$filter="off")
{
$filter strtolower($filter);

if ($filter <> "off")
{
$message $this -> bot -> core("stringfilter") -> funmode($message$filter);
}

$this -> bot -> send_tell("bettie""say " $name .": ".$message0FALSE);
                
$this -> bot -> send_gc("Your message has been sent to allies.");


}
}
?>
« Last Edit: February 10, 2009, 01:41:35 pm by -Fionn- »

 

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