Discussion: Agents without agent channel


 
Comments Filter

Re: Re: notify_slacker.pl script?

there's a few typos in this code, but you get the jist of it.

by xkev, Monday 21 of March, 2005 (20:22:50 UTC)
Re: notify_slacker.pl script?

sub notify_slacker() {
        require IO::Socket::INET;

        my $myip = "5.6.7.8";
        my $bothost = "1.2.3.4";
        my $botport = "8765";
       
        my ($chan,$you,$reason) = @_;

        my $astchan = asterisk_get_channel_by_name($chan);
        my $agentchan = asterisk_dbget($astchan, "AGENT", "$you/onChannel");
        my $reg = (split '/', $agentchan)[1];
        my $epoch = time;
        my $sock;

        $sock = IO::Socket::INET->new(Proto => 'udp', PeerAddr => $mybothost, PeerPort => $mybotport, 
LocalPort => 65535);
        $sock->send("Agent '^B$you^B' $reason: ^Bagent set unavailable^B");
        $sock->close;

        return 0 unless (defined $reg && length($reg));

        $sock = IO::Socket::INET->new(Proto => 'udp', PeerAddr => $myproxy, PeerPort => 5060, LocalPort => 65535);
        my $message = 
                "MESSAGE sip:$reg\@$myip:5060 SIP/2.0\r\n".
                "Via: SIP/2.0/UDP $myip:65535\r\n".
                "From: \"pbx\" \r\n".
                "To: sip:$reg\@pbx\r\n".
                "CSeq: 1 MESSAGE\r\n".
                "Call-ID: $epoch-slacker\@$myip\r\n".
                "User-Agent: Slacker Notifier\r\n".
                "Max-Forwards: 70\r\n".
                "Content-Type: text/plain\r\n".
                "Content-Length: 10\r\n\r\n".
                "logged off";
        $sock->send($message);
        $sock->close();
        return 0;
}


by xkev, Friday 20 of July, 2012 (01:08:43 UTC)
notify_slacker.pl script?

Wow, very impressive. It's going to take me a while to go through this.

You mention the Res_Perl module and your use of the notify_slacker routine, but there is no code for this. Would you be willing to put that up as well?

Great job.

John

by agentcooper, Wednesday 09 of March, 2005 (18:44:35 UTC)

Page Changes | Comments

 

Featured -

Search: