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: Coding a /tell relay question  (Read 5076 times)

0 Members and 1 Guest are viewing this topic.

Offline Hyde

  • BeBot Apprentice
  • ***
  • Posts: 92
  • Karma: +0/-0
Coding a /tell relay question
« on: August 27, 2007, 02:53:43 am »
On our old bot I had a plugin that would take message input from pre-determined people and echo that message on orgchat and guest chat without giving any reply back to the source.

We used this to display Infonet and Elitenet relays in orgchat. I did some other stuff to them as well to reformat them (so that elitenet and infonet messages looked virtually identical as well as to include a simple profanity filter).

It is key that the bot not ever send any reply back to these senders, even in the event of error. Otherwise you get chat loops.

What do I need to do to make sure I intercept the message and never respond to it if it comes from certain names?
Doctorhyde/Jexyll/Goraud@RK2

Offline Alreadythere

  • BeBot Maintainer
  • BeBot Hero
  • ******
  • Posts: 1288
  • Karma: +0/-0
Re: Coding a /tell relay question
« Reply #1 on: August 27, 2007, 11:05:33 am »
Try something like the code below, tells is used to catch all incoming tells that don't match a command. You need to check the sender, and if it's the right one relay it. If the function tells() returns true the handler for incoming tells won't send back any access denied or help lines.

Code: [Select]
<?php
$infonet 
= new InfoNet($bot);

$commands["tells"]["infonet"] = &$infonet;

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

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

        function 
tells($name$msg)
        {
                if (
$name == "Infonet")
                {
                        
$this -> bot -> send_gc($msg);
                        return 
true;
                }
                return 
false;
        }
}
?>


Offline Hyde

  • BeBot Apprentice
  • ***
  • Posts: 92
  • Karma: +0/-0
Re: Coding a /tell relay question
« Reply #2 on: December 03, 2007, 05:50:30 am »
I finally got around to doing this. Attaching the initial (seems to be working) version.

Includes a primitive customizable profanity filter and will parse out infonet and elitenet formats to make them a less spammy on orgchat.

(edit: removed attachment, see new version in code quote a couple of posts down)
« Last Edit: February 10, 2009, 03:38:13 am by Hyde »
Doctorhyde/Jexyll/Goraud@RK2

Offline Malosar

  • BeBot Expert
  • ****
  • Posts: 259
  • Karma: +0/-0
    • http://www.lowerdimension.com
Re: Coding a /tell relay question
« Reply #3 on: February 07, 2008, 11:00:22 pm »
Hiya folks, been awhile :) I'm upgrading my bot since I still run it for my old guild though I don't play anymore. Starting it from scratch. Tried this announcer and it doesn't seem to do anything. I am still getting tells from infonet but the module never seems to react to it. Still am getting familiar with this bot and all the changes (used to 2.x) so is there anything I need to enable or some security setting I need to do?
Eternalist
General of The Syndicate

Offline Hyde

  • BeBot Apprentice
  • ***
  • Posts: 92
  • Karma: +0/-0
Re: Coding a /tell relay question
« Reply #4 on: February 10, 2009, 03:37:22 am »
I'm trying to move my Relay bot to 0.6.2 and my Announcer module isn't working anymore. Posting the current version below. It seemed to "just work" on 0.4.x (well, except for Malo :/ ) but when I run it on my 0.6.2 bot it loads ... but none of the defined $announcers work.

Any chance 0.6.x changed how this module needs to work? I'm just not that knowledgeable about the lower level issues that might be involved.

When Elitenet sends the bot a message I get:
[2009-02-10 02:14:57]   [TELL]  [INC]   Elitenet: botcommand [Elitenet][Test Message][Me] This is a test message from Elitenet.
[2009-02-10 02:14:57]   [TELL]  [OUT]   -> Elitenet: I only listen to members of this bot.

When Doctorhyde sends the bot a message I get:
[2009-02-10 02:17:45]   [TELL]  [INC]   Doctorhyde: test, ignore
[2009-02-10 02:17:45]   [TELL]  [OUT]   -> Doctorhyde: /tell Aput !help

Both of those are configured as $announcers (see below). I don't remember ever needing to set up security settings for the Announcers. When I load the same module in my 0.4.1 bot it works and I checked "!security groups" to make sure I never did anything funky for it there.

Code sample below. Only changes were removing my bot's elitenet password (replace "botcommand" with yours) and removing the profanity from the filter (add your censored words to that array, you'll see where).

(sample removed, updated one later in thread, keeping the thread from being too huge)
« Last Edit: February 10, 2009, 05:06:16 pm by Hyde »
Doctorhyde/Jexyll/Goraud@RK2

Offline Alreadythere

  • BeBot Maintainer
  • BeBot Hero
  • ******
  • Posts: 1288
  • Karma: +0/-0
Re: Coding a /tell relay question
« Reply #5 on: February 10, 2009, 06:52:28 am »
Your announcer class needs to extend BaseActiveModule. Then replacing $commands["tells"]["announcer"] = &$announcer; outside the bot definition with the following inside the constructor should do the trick:
Code: [Select]
parent::__construct(&$bot, get_class($this));
$this->register_event("tells");

You can remove the $this->bot = &$bot; line too, the parent constructor sets it.

Offline Hyde

  • BeBot Apprentice
  • ***
  • Posts: 92
  • Karma: +0/-0
Re: Coding a /tell relay question
« Reply #6 on: February 10, 2009, 05:03:35 pm »
Thanks.

After looking at the way the main modules for 0.6.2 are built I also changed:
        function Announcer(&$bot)
to:
        function __construct(&$bot)

(Not really sure that did anything)

However when I try to run the bot I get this error and bot cycles infinitely (note: I got this error even before I changed the line mentioned above):

Quote
Additional modules in directory custom/modules/commsbot

Fatal error: Class Announcer contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (BaseActiveModule::command_handler) in /home/bots/bebot/bebot-0.6.2/custom/modules/commsbot/Announcer.php on line 141

Since line 141 is the next to the last line of the script, and is where the class terminates, something is still wrong with how I've put it together.

Current version is below (and removed non-functional code above).

(edit: removed, will post a link to a full working version once I've finished it)
« Last Edit: February 10, 2009, 11:22:26 pm by Hyde »
Doctorhyde/Jexyll/Goraud@RK2

Offline Alreadythere

  • BeBot Maintainer
  • BeBot Hero
  • ******
  • Posts: 1288
  • Karma: +0/-0
Re: Coding a /tell relay question
« Reply #7 on: February 10, 2009, 06:10:08 pm »
Oh right, you have to instance command_handler(). Simple function command_handler($name, $msg, $origin) {} should be enough.

Offline Hyde

  • BeBot Apprentice
  • ***
  • Posts: 92
  • Karma: +0/-0
Re: Coding a /tell relay question
« Reply #8 on: February 10, 2009, 11:21:55 pm »
That did it, thanks.

Going to clean up some code and modify a few things, then I'll post the "final" 0.6.x version on a thread in the other forum. Thanks again for all the help.
Doctorhyde/Jexyll/Goraud@RK2

Offline Hyde

  • BeBot Apprentice
  • ***
  • Posts: 92
  • Karma: +0/-0
Re: Coding a /tell relay question
« Reply #9 on: February 11, 2009, 07:39:33 am »
Posted the new version. I cleaned it up enough I don't think it is a problem to have it in the unofficial modules forum:

bebot.link/0-6-x-customunofficial-modules/announcer-php

So this thread should be dead except as a reference. Thanks again for the help.
Doctorhyde/Jexyll/Goraud@RK2

 

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