L* R*
HOME FORUM DOWNLOADS
Content
  Links
     Browse SVN
     SVN Commit log
     Documentation (Wiki)
  Developers
     Taskmanager
User
Welcome, Guest. Please login or register.
Did you miss your activation email?
December 01, 2008, 01:20:36 PM

Login with username, password and session length
Search



Advanced search
Support GoPHP5.org
BeBot - An Anarchy Online/Age Of Conan chat automaton > Forum > Development > Coding and development discussion > Topic: Missing Private group functions implimented
Pages: [1]   Go Down
« previous next »
Print
Author Topic: Missing Private group functions implimented  (Read 399 times)
0 Members and 1 Guest are viewing this topic.
MafooUK
Freshman
*
Offline Offline

Posts: 6


Missing Private group functions implimented
« on: September 03, 2007, 02:39:50 PM »

i have a number of Updates to
  • Sources/Bot.php
  • Sources/AOChat.php
these implement the missing functions for external private groups
i have currently coded these against the 0.4.1 release (with the updates for the change of whois servers)

the functions added to Bot.php are

   added function send_pgroup_accept($group)
   added function send_pgroup_leave($group)
   added function send_pgroup_decline($group)
   modified send_output to support type 5/extpgroup

the functions added to AOChat.php are

   added function privategroup_leave($group)

i would like to know would you like .patch files for the current  svn trunks and branches (need readonly SVN access please)

or you just want a detailed description of what needs to be changed

p.s. would love to see these changes go in so my team module will be able to work as intended
Logged
Alreadythere
BeBot Maintainer
Administrator
Grandmaster
********
Offline Offline

Posts: 1085


Re: Missing Private group functions implimented
« Reply #1 on: September 03, 2007, 02:58:15 PM »

Not really sure if you need those send_privategroup_(accept|leave|decline) really, you can just as easy call the AOChat functions directly. I don't see any added functionality those functions should get.

And each time you send something to an external group you have to define what the target is. No real sense to adapt send_output there, you can always use send_pgroup directly.

Adding privategroup_leave() to AOChat is nice though.

Best just attach a diff -Nbur to your post.
Logged
Vhab
BeBot Contributor
Experienced
*******
Offline Offline

Posts: 158


WWW
Re: Missing Private group functions implimented
« Reply #2 on: September 03, 2007, 03:14:59 PM »

I don't really see harm in wrapping around the lib.
It's what most functions already do effectively anyways, might aswell complete the set and never require direct access to aochat.
Logged
Alreadythere
BeBot Maintainer
Administrator
Grandmaster
********
Offline Offline

Posts: 1085


Re: Missing Private group functions implimented
« Reply #3 on: September 03, 2007, 04:41:36 PM »

Good argument. And having it twice is better then having it just once anyways.

Still don't see any reason to extend send_output() though.
Logged
MafooUK
Freshman
*
Offline Offline

Posts: 6


Re: Missing Private group functions implimented
« Reply #4 on: September 03, 2007, 06:17:50 PM »

i extended send_output to conform with the style of programming found in the example module
Logged
MafooUK
Freshman
*
Offline Offline

Posts: 6


Re: Missing Private group functions implimented
« Reply #5 on: September 03, 2007, 06:30:19 PM »

reference changes from stable 0.4.1
in AOCHat.php
find near line 616
Code:
<?php
function 
privategroup_join($group)
{
if(($gid = $this->get_uid($group)) === false)
{
return false;
}
return $this->send_packet(new AOChatPacket("out", AOCP_PRIVGRP_JOIN, $gid));
}
function join_privgroup($group) /* Deprecated - 2004/Mar/26 - auno@auno.org */
{
return $this->privategroup_join($group);
}
>

add after
Code:
<?php
function 
privategroup_leave($group)
{
if(($gid = $this->get_uid($group)) === false)
{
return false;
}
return $this->send_packet(new AOChatPacket("out", AOCP_PRIVGRP_PART, $gid));
}
>

in Bot.php
find near line 329
Code:
<?php
/*
send a tell. Set $low to 1 on tells that are likely to cause spam.
*/
function send_tell($to, $msg, $low=0, $color=true)
{
// parse all color tags:
$msg = $this -> colors -> parse($msg);

$send = true;
if (preg_match("/<a href=\"(.+)\">/isU", $msg, $info))
if (strlen($info[1]) > $this -> maxsize)
{
$this -> cut_size($msg, "tell", $to, $low);
$send = false;
}

if ($send)
{
$msg = str_replace("<botname>", $this -> botname, $msg);
$msg = str_replace("<pre>", str_replace("\\", "", $this -> commpre), $msg);

if ($color)
$msg = $this -> colors -> colorize("normal", $msg);

if ($this -> queue -> check_queue())
{
$this -> log("TELL", "OUT", "-> " . $this -> aoc -> get_uname($to) . ": " . $msg);
$msg = utf8_encode($msg);
$this -> aoc -> send_tell($to, $msg);
}
else
$this -> queue -> into_queue($to, $msg, "tell", $low);
}
}
>
and insert after
Code:
<?php
/*
accept invite to private group
*/
function send_pgroup_accept($group)
{
if ($group == NULL)
return false;

$this -> log("PGRP", "ACCEPT", "Accepting Invite for Private Group [" . $group . "]");
$this -> aoc -> privategroup_join($group);
}


/*
leave private group
*/
function send_pgroup_leave($group)
{
if ($group == NULL)
return false;

$this -> log("PGRP", "LEAVE", "Leaving Private Group [" . $group . "]");
$this -> aoc -> privategroup_leave($group);
}
/*
decline private group
*/
function send_pgroup_decline($group)
{
return $this->send_pgroup_leave($group);
}
>

in Bot.php
find near line 474
Code:
<?php
function 
send_output($source, $msg, $type)
{
// Output filter
if ($this -> settings -> get('Filter', 'Enabled'))
{
$msg = $this -> stringfilter -> output_filter($msg);
}
if (!is_numeric($type))
{
$type = strtolower($type);
}
switch($type)
{
case '0':
case '1':
case 'tell':
$this -> send_tell($source, $msg);
break;
case '2':
case 'pgroup':
case 'pgmsg':
$this -> send_pgroup($msg);
break;
case '3':
case 'gc':
$this -> send_gc($msg);
break;
case '4':
case 'both':
$this -> send_gc($msg);
$this -> send_pgroup($msg);
break;
default:
$this -> send_tell($source, "Broken plugin, type: $type is unknown to me");
}
}
>
change to
Code:
<?php
function 
send_output($source, $msg, $type)
{
// Output filter
if ($this -> settings -> get('Filter', 'Enabled'))
{
$msg = $this -> stringfilter -> output_filter($msg);
}
if (!is_numeric($type))
{
$type = strtolower($type);
}
switch($type)
{
case '0':
case '1':
case 'tell':
$this -> send_tell($source, $msg);
break;
case '2':
case 'pgroup':
case 'pgmsg':
$this -> send_pgroup($msg);
break;
case '3':
case 'gc':
$this -> send_gc($msg);
break;
case '4':
case 'both':
$this -> send_gc($msg);
$this -> send_pgroup($msg);
break;
case '5':
case 'extpgroup';
$this -> send_pgroup($msg, $source);
break;
default:
$this -> send_tell($source, "Broken plugin, type: $type is unknown to me");
}
}
>

yes it seems like duplication and you could directly access the aochat class but the goal is to promote good programming and blackbox style program.
if AOChat.php was every dramatically changed becuase FC changed some stuff module programmers would need to update there code, however following the model of programming only bot.php would need to be modified to allow any changes to work, thus maintaining a lot of backward module compatability
Logged
MafooUK
Freshman
*
Offline Offline

Posts: 6


Re: Missing Private group functions implimented
« Reply #6 on: September 03, 2007, 06:47:09 PM »

Quote from: Alreadythere on September 03, 2007, 02:58:15 PM
And each time you send something to an external group you have to define what the target is. No real sense to adapt send_output there, you can always use send_pgroup directly.

valid points but from the looks of the example modules it is encouraged to use send_output instead of send_pgroup or send_tell when sending data back.
i belive this is for the structure purposes of trying to get rid of needing a function per incoming source type and useing a generic handler function instead
however it does need to be changed from
Code:
handler($source, $msg, $type)
to
Code:
handler($source, $msg, $type, $group = NULL)
thus allowing group to be blank if it was a tell or gc message.
in addition $group can represent what org sent the message as well when it was a relayed message and set the type to 6/relay

just my 2cents (or more) but from looking at the project it looks like where it's heading
p.s. excelent work on the bot and various extra modules
Logged
MafooUK
Freshman
*
Offline Offline

Posts: 6


Re: Missing Private group functions implimented
« Reply #7 on: September 04, 2007, 11:47:05 AM »

i missed implimentation of group_status from aochat.php in bot.php
place anywhere relivant
Code:
<?php
/*
private group statuus
added - 2007/Sep/1 - anarchyonline@mafoo.org
*/
function pgroup_status($group)
{
if ($group == NULL)
$group = $this->botname;
return $this->aoc->group_status($group);
}
>
Logged
Pages: [1]   Go Up
Print
BeBot - An Anarchy Online/Age Of Conan chat automaton > Forum > Development > Coding and development discussion > Topic: Missing Private group functions implimented
« previous next »
 
Jump to:  

Recent
[request] Raid timers
by Alreadythere
[Today at 11:42:32 AM]

Shared DB online list
by Temar
[Today at 01:55:47 AM]

relay colors
by Temar
[Today at 01:54:56 AM]

BeBot v0.6.0 released
by Alreadythere
[November 30, 2008, 05:32:00 PM]

Change to Bid.php
by Temar
[November 30, 2008, 11:41:44 AM]

OnlineOrg
by Jiheld
[November 29, 2008, 12:44:27 PM]

Silly Newbie Question.
by Temar
[November 29, 2008, 12:00:02 PM]

massive_pvp_time_table 1
by gerborg
[November 29, 2008, 06:55:35 AM]

Bot not see Guild Chat
by Delvar
[November 28, 2008, 08:30:34 AM]

Starting Bot
by Allisande
[November 28, 2008, 07:08:21 AM]
Stats
Members
Total Members: 1243
Latest: Whackoeng
Stats
Total Posts: 11143
Total Topics: 1505
Online Today: 21
Online Ever: 168
(July 01, 2007, 09:30:02 PM)
Users Online
Users: 1
Guests: 10
Total: 11
egrath

Powered by SMF 1.1.7 | SMF © 2006-2008, Simple Machines LLC
TinyPortal v0.9.8 © Bloc | NewDef design by Bloc
Page created in 0.377 seconds with 28 queries. (Pretty URLs adds 0.029s, 4q)
Loading...