X-Git-Url: http://dxcluster.net/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2FThingy.pm;fp=perl%2FThingy.pm;h=6ab36080596b931c8c4a671c41318537f15225ac;hb=57740a288c82793988be72c9b5666087d636344f;hp=2361561af527edc43c0f474adfc1bc29236ec1a9;hpb=42f3323cfe4eff424f4acc96ba665e666cb63b5c;p=spider.git diff --git a/perl/Thingy.pm b/perl/Thingy.pm index 2361561a..6ab36080 100644 --- a/perl/Thingy.pm +++ b/perl/Thingy.pm @@ -132,10 +132,12 @@ sub queue sub process { my $thing; + if (@_ == 2) { $thing = shift; $thing->queue(shift); } + while (@queue) { $thing = shift @queue; my $dxchan = DXChannel::get($thing->{dxchan}); @@ -205,5 +207,26 @@ sub add_auth $thing->{auth} = $auth->challenge($main::me->user->passphrase); } +# +# create a generalised reply to a passed thing, if it isn't replyable +# to then undef is returned +# +sub new_reply +{ + my $thing = shift; + my $out; + + if ($thing->{group} eq $main::mycall) { + $out = $thing->new; + $out->{touser} = $thing->{user} if $thing->{user}; + } elsif (DXChannel::get($thing->{group})) { + $out = $thing->new(user => $thing->{group}); + $out->{touser} = $thing->{user} if $thing->{user}; + } elsif ($thing->{touser} && DXChannel->{$thing->{touser}}) { + $out = $thing->new(user => $thing->{touser}); + $out->{group} = $thing->{group}; + } + return $out; +} 1;