add set/buddy.
[spider.git] / perl / DXChannel.pm
index b0208f103e0e6093df5b654c133420e110780419..9812037fce2ee1fa44255555fe6e63c09957c0d3 100644 (file)
@@ -153,7 +153,8 @@ sub alloc
        if (defined $user) {
                $self->{user} = $user;
                $self->{lang} = $user->lang;
-               $user->new_group() if !$user->group;
+               $user->new_group unless $user->group;
+               $user->new_buddies unless $user->buddies;
                $self->{group} = $user->group;
                $self->{sort} = $user->sort;
        }
@@ -493,7 +494,28 @@ sub closeall
 #
 sub tell_login
 {
-       my ($self, $m) = @_;
+       my ($self, $m, $call) = @_;
+       
+       $call ||= $self->{call};
+       
+       # send info to all logged in thingies
+       my @dxchan = get_all_users();
+       my $dxchan;
+       foreach $dxchan (@dxchan) {
+               next if $dxchan == $self;
+               next if $dxchan->{call} eq $main::mycall;
+               $dxchan->send($dxchan->msg($m, $call)) if $dxchan->{logininfo};
+       }
+}
+
+#
+# Tell all the users if a buddy is logged or out
+#
+sub tell_buddies
+{
+       my ($self, $m, $call) = @_;
+       
+       $call ||= $self->{call};
        
        # send info to all logged in thingies
        my @dxchan = get_all_users();
@@ -501,7 +523,7 @@ sub tell_login
        foreach $dxchan (@dxchan) {
                next if $dxchan == $self;
                next if $dxchan->{call} eq $main::mycall;
-               $dxchan->send($dxchan->msg($m, $self->{call})) if $dxchan->{logininfo};
+               $dxchan->send($dxchan->msg($m, $call)) if grep $_ eq $call, @{$dxchan->user->buddies} ;
        }
 }