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: Can't seem to get logon_notify to work  (Read 1403 times)

0 Members and 1 Guest are viewing this topic.

Offline Dabaron

  • BeBot Apprentice
  • ***
  • Posts: 163
  • Karma: +0/-0
Can't seem to get logon_notify to work
« on: January 19, 2009, 06:58:29 am »
I wrote a quick module in .4 that would simply send a tell to people on logon with the url to the org's forums.  It also worked via tell/gc/pgmsg.  I'm trying to update it to .6 and am having some problems.  When sending a message to the bot I do get the expected behavior, I just can't seem to get it to work on logon and any help would be most appreciated!  Here is my mod:
Code: [Select]
<?php
/*
* Forum.php - Webmated messages from external sources.
*
* BeBot - An Anarchy Online Chat Webmaton
* Copyright (C) 2004 Jonas Jax
* Copyright (C) 2005-2007 Thomas Juberg Stensås, ShadowRealm Creations and the BeBot development team.
*
* Developed by:
* - Alreadythere (RK2)
* - Blondengy (RK1)
* - Blueeagl3 (RK1)
* - Glarawyn (RK1)
* - Khalem (RK1)
* - Naturalistic (RK1)
*
* See Credits file for all aknowledgements.
*
*  This program is free software; you can redistribute it and/or modify
*  it under the terms of the GNU General Public License as published by
*  the Free Software Foundation; version 2 of the License only.
*
*  This program is distributed in the hope that it will be useful,
*  but WITHOUT ANY WARRANTY; without even the implied warranty of
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*  GNU General Public License for more details.
*
*  You should have received a copy of the GNU General Public License
*  along with this program; if not, write to the Free Software
*  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
*  USA
*/

$forum = new Forum($bot);

$commands["tell"]["forums"] = &$forum;
$commands["gc"]["forums"] = &$forum;
$commands["pgmsg"]["forums"] = &$forum;

Class 
Forum extends BaseActiveModule
{
var $bot;

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

// Register for logon notifies
$this -> register_event("logon_notify");

// Set default access
        
$this -> register_command("all""forums""GUEST");

$this -> bot -> core("settings") -> create ("Forums""URL""""What is the forums URL?");
$this -> bot -> core("settings") -> create ("Forums""Headline""Forums""What would you like in the headline?");
$this -> bot -> core("settings") -> create ("Forums""Logon""On""Would you like a link to be sent on logon?""On;Off");
}

function command_handler($name$msg$origin)
{
$com $this->parse_com($msg);
switch($com['com'])
{
case 'forums':
return($this -> send_link($name));
break;
}
}

function notify($name)
{
switch($this -> bot -> core("settings") -> get("Forums""Logon"))
{
case 'On':
$this -> send_link($name);
break;
case 'Off':
break;

}
}

function send_link()
{
$url $this -> bot -> core("settings") -> get("Forums""URL");
$headline $this -> bot -> core("settings") -> get("Forums""Headline");

$inside "<center><font color=CCInfoHeadline>:::: ".$headline." ::::</font></center>\n";
$inside .= "<a href='chatcmd:///start ".$url."'>Forums</a>";

return $this -> bot -> core("tools") -> make_blob("Forums"$inside);
}
}
?>


Offline Serbaa

  • BeBot User
  • **
  • Posts: 22
  • Karma: +0/-0
Re: Can't seem to get logon_notify to work
« Reply #1 on: January 20, 2009, 07:55:29 am »
I would start by looking at the News module that comes with bebot.  It has this functionality and you can either use it or see what the code is doing for it.  If you have any questions after taking a look there then post them here :)

Offline Dabaron

  • BeBot Apprentice
  • ***
  • Posts: 163
  • Karma: +0/-0
Re: Can't seem to get logon_notify to work
« Reply #2 on: January 22, 2009, 09:59:06 am »
I've looked at that one and near as I can tell mine does something similar.  I added in a debug output that sent me the value of $this -> bot -> core("settings") -> get("Forums", "Logon") and it sent me "On".  My switch is looking for 'On' and calling the exact same function that works when I send the command to it.

What am I doing wrong?

Offline Temar

  • Contributor
  • *******
  • Posts: 1140
  • Karma: +0/-0
    • AoFiles
Re: Can't seem to get logon_notify to work
« Reply #3 on: January 22, 2009, 05:17:02 pm »
Changes:
  • Removed $commands at top
  • Changed the Forums Logon Setting to True/False and the part that uses it (still shows as On Off ingame)
  • Removed sending of $name to send_link as this was pointless
  • Added a send_tell inside the notify function
  • useing chatcmd function for the url link
Code: [Select]
<?php
/*
* Forum.php - Webmated messages from external sources.
*
* BeBot - An Anarchy Online Chat Webmaton
* Copyright (C) 2004 Jonas Jax
* Copyright (C) 2005-2007 Thomas Juberg Stensås, ShadowRealm Creations and the BeBot development team.
*
* Developed by:
* - Alreadythere (RK2)
* - Blondengy (RK1)
* - Blueeagl3 (RK1)
* - Glarawyn (RK1)
* - Khalem (RK1)
* - Naturalistic (RK1)
*
* See Credits file for all aknowledgements.
*
*  This program is free software; you can redistribute it and/or modify
*  it under the terms of the GNU General Public License as published by
*  the Free Software Foundation; version 2 of the License only.
*
*  This program is distributed in the hope that it will be useful,
*  but WITHOUT ANY WARRANTY; without even the implied warranty of
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*  GNU General Public License for more details.
*
*  You should have received a copy of the GNU General Public License
*  along with this program; if not, write to the Free Software
*  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
*  USA
*/

$forum = new Forum($bot);

Class 
Forum extends BaseActiveModule
{
var $bot;

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

// Register for logon notifies
$this -> register_event("logon_notify");

// Set default access
        
$this -> register_command("all""forums""GUEST");

$this -> bot -> core("settings") -> create ("Forums""URL""""What is the forums URL?");
$this -> bot -> core("settings") -> create ("Forums""Headline""Forums""What would you like in the headline?");
$this -> bot -> core("settings") -> create ("Forums""Logon"TRUE"Would you like a link to be sent on logon?");
}

function command_handler($name$msg$origin)
{
$com $this->parse_com($msg);
switch($com['com'])
{
case 'forums':
return($this -> send_link());
break;
}
}

function notify($name)
{
if($this -> bot -> core("settings") -> get("Forums""Logon"))
{
$this -> bot -> send_tell($name$this -> send_link());
}
}

function send_link()
{
$url $this -> bot -> core("settings") -> get("Forums""URL");
$headline $this -> bot -> core("settings") -> get("Forums""Headline");

$inside "<center><font color=CCInfoHeadline>:::: ".$headline." ::::</font></center>\n";
$inside .= $this -> bot -> core("tools") -> chatcmd($url"Forums""start";

return $this -> bot -> core("tools") -> make_blob("Forums"$inside);
}
}
?>


 

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