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: Tell relay to guild chat  (Read 11076 times)

0 Members and 3 Guests are viewing this topic.

Offline Malosar

  • BeBot Expert
  • ****
  • Posts: 259
  • Karma: +0/-0
    • http://www.lowerdimension.com
Tell relay to guild chat
« on: March 30, 2006, 05:04:09 am »
I'd write this myself if I really knew what I was doing, however I can't so im asking if someone can write one up quickly as it shouldn't take long. All I need is a simple module to relay a tell from a specific username to guild chat. So if the bot gets a tell from Infonet it will relay the same message to guild chat.

Im in the process of finally converting my guild bot to bebot and I wrote in my own code in IGN bot to handle this, however not sure how to go about it in bebot.
Eternalist
General of The Syndicate

Offline Jarras

  • BeBot Rookie
  • *
  • Posts: 12
  • Karma: +0/-0
Re: Tell relay to guild chat
« Reply #1 on: April 09, 2006, 09:44:59 am »
Looking for a way to do this as well. Would be a nice feature to have.

Offline Naturalistic

  • Contributor
  • *******
  • Posts: 221
  • Karma: +0/-0
Re: Tell relay to guild chat
« Reply #2 on: April 09, 2006, 05:27:45 pm »
That's easy :P

Code: [Select]
$commands["tell"][] = &$mod;

function tell ($name, $msg)
{
    if (preg_match(yadda yadda))
    {
         $this->bot->send_gc ($msg);
     }
}

That of course is just to give you the idea of what to do. If you want to relay *anything* from infonet, just change the preg_match to:
 if ($name == "Infonet")) {} instead. To get it working, you'll have to fix it up :P Hope that helps.
220/25 Eternalist Doctor
-----------------------------
Campalot Coding Co-ordinator and Super Admin
http://www.campalot.info/index.php

Offline Blondengy

  • BeBot Creator and Founder
  • BeBot Hero
  • ******
  • Posts: 51
  • Karma: +0/-0
Re: Tell relay to guild chat
« Reply #3 on: April 09, 2006, 05:34:28 pm »
The following is quick but ugly (there're nicer ways to do this).

At the top you can set a list of nick of people from whom you'd like to accept tells to be relayed.
(Tells must be in the format of: !relaytell <message to relay>)

Code: ("RelayTell.php") [Select]
<?
/*
* RelayTell.php - Relays tells from certain members to GC
*
* 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$
* Revision: $Id$
*/


// List of people from whom to relay:
$relaytellnames["SomeGuy1"] = 1;
$relaytellnames["SomeGuy2"] = 1;
$relaytellnames["Malosar"] = 1;
$relaytellnames["ifonet"] = 1;

$relaytell = new RelayTell($bot, $relaytellnames);
$commands["tell"]["relaytell"] = &$relaytell;
$commands["tell2"]["relaytell"] = &$relaytell;


/*
The Class itself...
*/
class RelayTell
{
var $bot;
var $names;


/*
Constructor:
Hands over a referance to the "Bot" class
*/
function RelayTell (&$bot, &$names)
{
$this -> bot = &$bot;
$this -> names = $names;
}



/*
This gets called on a tell with the command
*/
function tell($name, $msg)
{
if (($this -> names[$name]) && preg_match("/^" . $this -> bot -> commpre . "relaytell (.+)$/i", $msg, $info))
$this -> bot -> send_gc("<font color=#ffff00>$name:</font> " . $info[1]);
}



/*
This gets called on a tell with the command from person outside guild
*/
function tell2($name, $msg)
{
if (($this -> names[$name]) && preg_match("/^" . $this -> bot -> commpre . "relaytell (.+)$/i", $msg, $info))
$this -> bot -> send_gc("<font color=#ffff00>$name:</font> " . $info[1]);
}
}
?>

This should work but since I've cancled my account long ago I have no means of checking... :P
« Last Edit: April 09, 2006, 05:37:53 pm by Blondengy »

Offline Naturalistic

  • Contributor
  • *******
  • Posts: 221
  • Karma: +0/-0
Re: Tell relay to guild chat
« Reply #4 on: April 09, 2006, 07:12:25 pm »
You don't have to make it use a tell command, it should work if it matches a specified name.

Needs to be tested, but I'm pretty sure that it would work.

The other way is using a !command like Blond suggested.
220/25 Eternalist Doctor
-----------------------------
Campalot Coding Co-ordinator and Super Admin
http://www.campalot.info/index.php

Offline Malosar

  • BeBot Expert
  • ****
  • Posts: 259
  • Karma: +0/-0
    • http://www.lowerdimension.com
Re: Tell relay to guild chat
« Reply #5 on: April 09, 2006, 07:21:30 pm »
Thanks for the attempts however the first one won't work because the bot.php overrides incoming tell handling if a command isn't known and will just return a /help to the sender without following any relay rules.

The second one won't work in this regard because the server-wide infonet messages won't include a !relaytell command in them though would be useful for other commands I might want.

So I'd hacked this into the bot.php when it resolves an incoming tell:
Code: [Select]
/*
Incomeing Tell
*/
function inc_tell($args)
{
$infonet = $this -> aoc -> get_uname($args[0]);
if ($infonet == "Infonet")
    {
        $this->send_gc("Infonet: ".$args[1]);
      }

Which works but the only problem now is to squash any replies to Infonet. Fortunately Infonet is written to not reply to garbage it doesn't understand so it's not a big problem and won't cause tell tennis. I guess I need to hack something into this section to make sure it doesn't reply either response to Infonet. I've added Infonet as a member as well.

Code: [Select]
if (!$found && $this -> is_member($user))
$this -> send_help($args[0], "/tell " . $this -> botname . " " .

str_replace("\\", "", $this -> commpre) . "help");
else if (!$found)
{
if ($this -> guild_bot)
$this -> send_tell($args[0], "I only listen to members of

" . $this -> guildname . ".");
else
$this -> send_tell($args[0], "I only listen to members of

this bot.");
}
Eternalist
General of The Syndicate

Offline Blondengy

  • BeBot Creator and Founder
  • BeBot Hero
  • ******
  • Posts: 51
  • Karma: +0/-0
Re: Tell relay to guild chat
« Reply #6 on: April 09, 2006, 08:08:20 pm »
Code: [Select]
if ($infonet == "Infonet")
{
  $this->send_gc("Infonet: ".$args[1]);
  $found = true;
}

That should stop replies cause it tells the bot that code to handle the tell has been found.

Offline Malosar

  • BeBot Expert
  • ****
  • Posts: 259
  • Karma: +0/-0
    • http://www.lowerdimension.com
Re: Tell relay to guild chat
« Reply #7 on: April 09, 2006, 09:05:49 pm »
Code: [Select]
if ($infonet == "Infonet")
{
  $this->send_gc("Infonet: ".$args[1]);
  $found = true;
}

That should stop replies cause it tells the bot that code to handle the tell has been found.

ok thanks, starting to work all this out :)
Eternalist
General of The Syndicate

Offline Naturalistic

  • Contributor
  • *******
  • Posts: 221
  • Karma: +0/-0
Re: Tell relay to guild chat
« Reply #8 on: April 09, 2006, 09:37:22 pm »
That's what I was first saying :P

But I wasn't going to spoon you all the code, learning it on your own = easier to fix in the future.
220/25 Eternalist Doctor
-----------------------------
Campalot Coding Co-ordinator and Super Admin
http://www.campalot.info/index.php

Offline Malosar

  • BeBot Expert
  • ****
  • Posts: 259
  • Karma: +0/-0
    • http://www.lowerdimension.com
Re: Tell relay to guild chat
« Reply #9 on: April 09, 2006, 09:44:43 pm »
That's what I was first saying :P

But I wasn't going to spoon you all the code, learning it on your own = easier to fix in the future.


Yep i'd rather learn what im doing, thanks for starting me off both of you :)
Eternalist
General of The Syndicate

Offline Pharexys

  • BeBot Apprentice
  • ***
  • Posts: 117
  • Karma: +0/-0
Re: Tell relay to guild chat
« Reply #10 on: May 15, 2006, 01:32:55 am »
very nice, was looking for this :P works great

 

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