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: Missing Private group functions implimented  (Read 2841 times)

0 Members and 1 Guest are viewing this topic.

Offline MafooUK

  • BeBot Rookie
  • *
  • Posts: 7
  • Karma: +0/-0
Missing Private group functions implimented
« on: September 03, 2007, 09: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

Offline Alreadythere

  • BeBot Maintainer
  • BeBot Hero
  • ******
  • Posts: 1288
  • Karma: +0/-0
Re: Missing Private group functions implimented
« Reply #1 on: September 03, 2007, 09: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.

Offline Vhab

  • Contributor
  • *******
  • Posts: 180
  • Karma: +0/-0
    • VhaBot Forum
Re: Missing Private group functions implimented
« Reply #2 on: September 03, 2007, 10: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.

Offline Alreadythere

  • BeBot Maintainer
  • BeBot Hero
  • ******
  • Posts: 1288
  • Karma: +0/-0
Re: Missing Private group functions implimented
« Reply #3 on: September 03, 2007, 11: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.

Offline MafooUK

  • BeBot Rookie
  • *
  • Posts: 7
  • Karma: +0/-0
Re: Missing Private group functions implimented
« Reply #4 on: September 04, 2007, 01:17:50 am »
i extended send_output to conform with the style of programming found in the example module

Offline MafooUK

  • BeBot Rookie
  • *
  • Posts: 7
  • Karma: +0/-0
Re: Missing Private group functions implimented
« Reply #5 on: September 04, 2007, 01:30:19 am »
reference changes from stable 0.4.1
in AOCHat.php
find near line 616
Code: [Select]
<?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 - [email protected] */
{
return $this->privategroup_join($group);
}
>

add after
Code: [Select]
<?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: [Select]
<?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: [Select]
<?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: [Select]
<?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: [Select]
<?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

Offline MafooUK

  • BeBot Rookie
  • *
  • Posts: 7
  • Karma: +0/-0
Re: Missing Private group functions implimented
« Reply #6 on: September 04, 2007, 01:47:09 am »
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: [Select]
handler($source, $msg, $type)to
Code: [Select]
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

Offline MafooUK

  • BeBot Rookie
  • *
  • Posts: 7
  • Karma: +0/-0
Re: Missing Private group functions implimented
« Reply #7 on: September 04, 2007, 06:47:05 pm »
i missed implimentation of group_status from aochat.php in bot.php
place anywhere relivant
Code: [Select]
<?php
/*
private group statuus
added - 2007/Sep/1 - [email protected]
*/
function pgroup_status($group)
{
if ($group == NULL)
$group $this->botname;
return $this->aoc->group_status($group);
}
>

 

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