ftocc

I'm insulted!

KodaK
Posts: 1873
Member Since:
2006-06-14

Have your trixbox insult you as a pirate.

Create an extension in extensions_custom.conf in the from-internal-custom context:

exten => *800,1,Answer
exten => *800,2,AGI(pirate.agi)
exten => *800,3,Hangup

Create a file called pirate.agi in /var/lib/asterisk/agi-bin and put this in it:

[code]
#!/usr/bin/perl
use warnings;
use strict;
use Acme::Scurvy::Whoreson::BilgeRat;
use Asterisk::AGI;

my $txfilename = "insult.txt";
my $AGI = new Asterisk::AGI;
my @lines;
my $prepend = "You are a";

my $insultgenerator = Acme::Scurvy::Whoreson::BilgeRat->new(
language => 'pirate'
);

open(OUTPUT,">/tmp/$txfilename.$$") || die "Could not open /tmp/$txfilename.$$\n";
print OUTPUT $prepend . " " . $insultgenerator;
close OUTPUT;

open(INPUT,") {
push(@lines,$_);
print "$_\n";
}
for(my $i = 0; $i < scalar(@lines); $i++) {
$AGI->exec('AGI',"festival-weather-script.pl|\"$lines[$i]\"");
}

unlink("/tmp/$txfilename.$$");

exit;

[/code]

chown asterisk.asterisk /var/lib/asterisk/agi-bin/pirate.agi
chmod +x /var/lib/asterisk/agi-bin/pirate.agi

reload asterisk

Dial *800

You may need to install Acme::Scurvy::Whoreson::BilgeRat. If so run:

perl -MCPAN -e "Acme::Scurvy::Whoreson::BilgeRat"

taking care to preserve the capitalization.

There is a way to do this from random insult generators on the Internet too, but you'll need to get permission from the owners of the site. This uses a local database.

If you want to do the one from the Internet, use this code:

[code]
#!/usr/bin/perl

use warnings;
use strict;

use Asterisk::AGI;
use LWP::Simple;

my $AGI = new Asterisk::AGI;
my $url="yoururlhere";
my $htfilename = "insult.html";
my @lines;

getstore($url,"/tmp/$htfilename.$$")or die "Cannot connect to $url: $@";

open(INPUT,") {
$_ =~ s/\<[^\<]+\>//g;
push(@lines,$_);
print "$_\n";
}

for(my $i = 0; $i < scalar(@lines); $i++) {
$AGI->exec('AGI',"festival-weather-script.pl|\"$lines[$i]\"");
}

unlink("/tmp/$htfilename.$$");

exit;
[/code]

But you'll have to find your own url. Google "random insult generator" and that will get you started.

Enjoy.

--

If you desire one on one help, my Paypal address is: sakodak@gmail.com

WARNING: I no longer actively participate in these forums. If you need help, PMing me here is not the fastest way of getting my attention, sorry for any inconvenience.



KodaK
Posts: 1873
Member Since:
2006-06-14
Re: I'm insulted!

Just thought I'd mention that I set a bunch of these up and set up an IVR:

If you'd like to be insulted by a pirate, press 1.

If you'd like to be insulted by a famous person, press 2.

If you'd like to have your mother insulted, press 3.

And if you'd just like a general insult, press 4.

So far my cow-orkers love it.

--

If you desire one on one help, my Paypal address is: sakodak@gmail.com

WARNING: I no longer actively participate in these forums. If you need help, PMing me here is not the fastest way of getting my attention, sorry for any inconvenience.



dstroot
Posts: 146
Member Since:
2006-06-01
Re: I'm insulted!

Your "cow-orkers"? I guess you just insulted them again. ;)



KodaK
Posts: 1873
Member Since:
2006-06-14
Re: I'm insulted!

http://en.wikipedia.org/wiki/Cow-orker

Some of us have been doing this a while.

--

If you desire one on one help, my Paypal address is: sakodak@gmail.com

WARNING: I no longer actively participate in these forums. If you need help, PMing me here is not the fastest way of getting my attention, sorry for any inconvenience.



wglenncamp
Posts: 74
Member Since:
2006-11-02
Re: I'm insulted!

HAHA, That's great!

I have added it to our Demo line (641) 827-3460 Call it and check it out.

--

Netstar Solutions, LLC.
http://www.netstarsolutions.com



BobH
Posts: 223
Member Since:
2006-05-31
Re: I'm insulted!

I did something like this for a few people here who have problems deciding where to go for lunch. Dial LUNCH on the phone and it gives you a random restaurant name. It kind of mangles some of the names but that is half the fun. We like to go to "Rail Head" (Trail Head) or "Cool Peppers" (Culpeppers)



jpe
Posts: 21
Member Since:
2006-06-01
Re: I'm insulted!

Looks fun, but I can't get it to work. Runs the agi but does nothing. (First version listed)

--

---
If you think it's not a game, you've already lost.



KodaK
Posts: 1873
Member Since:
2006-06-14
Re: I'm insulted!

What happens if you run it from the command line?

Type:

/var/lib/asterisk/agi-bin/pirate.agi

If you get errors from there then it won't work.

--

If you desire one on one help, my Paypal address is: sakodak@gmail.com

WARNING: I no longer actively participate in these forums. If you need help, PMing me here is not the fastest way of getting my attention, sorry for any inconvenience.



dstroot
Posts: 146
Member Since:
2006-06-01
Re: I'm insulted!

Mine dies because it can't find the pirate phrases:

[root@asterisk1 ~]# /var/lib/asterisk/agi-bin/pirate.agi
Can't locate Acme/Scurvy/Whoreson/BilgeRat.pm in @INC ... a t /var/lib/asterisk/agi-bin/pirate.agi line 4.

I ran this:
perl -MCPAN -e "Acme::Scurvy::Whoreson::BilgeRat"

but no joy...



KodaK
Posts: 1873
Member Since:
2006-06-14
Re: I'm insulted!

Did:

perl -MCPAN -e "Acme::Scurvy::Whoreson::BilgeRat"

finish without errors?

You can try installing it interactively to see if it wants a dependancy or something.

run:

perl -MCPAN -e shell

(say "no" if it asks if you want to set up your cpan environment or whatever -- I forget the exact wording. It might tell you "sorry, we have to rerun the configuration ... blah blah blah. If so, then just do it.)

Anyway, once you have a command prompt (should look similar to "cpan>") you can type:

install Acme::Scurvy::Whoreson::BilgeRat

And folllow along. Say "yes" if it asks to prepend anything. Post the output if you get errors.

--

If you desire one on one help, my Paypal address is: sakodak@gmail.com

WARNING: I no longer actively participate in these forums. If you need help, PMing me here is not the fastest way of getting my attention, sorry for any inconvenience.



wglenncamp
Posts: 74
Member Since:
2006-11-02
Re: I'm insulted!

I had to install via shell in order to get the modules to install.

--

Netstar Solutions, LLC.
http://www.netstarsolutions.com



KodaK
Posts: 1873
Member Since:
2006-06-14
Re: I'm insulted!

I've installed a bunch of Perl modules on this system, I have no idea what at this point. It's possible one of the ones I've installed is a silent dependancy of ASWBR.

Sorry for any confusion. I'm not a professional programmer.
(Nor a professional anything.)

:)

--

If you desire one on one help, my Paypal address is: sakodak@gmail.com

WARNING: I no longer actively participate in these forums. If you need help, PMing me here is not the fastest way of getting my attention, sorry for any inconvenience.



dstroot
Posts: 146
Member Since:
2006-06-01
Re: I'm insulted!
Quote:
You can try installing it interactively to see if it wants a dependancy or something.

run:

perl -MCPAN -e shell

(say "no" if it asks if you want to set up your cpan environment or whatever -- I forget the exact wording. It might tell you "sorry, we have to rerun the configuration ... blah blah blah. If so, then just do it.)

Anyway, once you have a command prompt (should look similar to "cpan>") you can type:

install Acme::Scurvy::Whoreson::BilgeRat

This worked fine - It went through a lot of cpan setup (it had never been setup on my box) and then when I finally got the "cpan>" prompt it installed no problem.

That that you scurvy bilge rats.



segmentedone
Posts: 24
Member Since:
2007-03-23
[root@asterisk1 agi-bin]#

[root@asterisk1 agi-bin]# /var/lib/asterisk/agi-bin/pirate.agi
Scalar found where operator expected at /var/lib/asterisk/agi-bin/pirate.agi line 22, near "print "$_"
(Might be a runaway multi-line "" string starting on line 20)
(Do you need to predeclare print?)
Backslash found where operator expected at /var/lib/asterisk/agi-bin/pirate.agi line 22, near "$_\"
(Missing operator before \?)
String found where operator expected at /var/lib/asterisk/agi-bin/pirate.agi line 25, near "$AGI->exec('AGI',""
(Might be a runaway multi-line "" string starting on line 22)
(Missing semicolon on previous line?)
Bareword found where operator expected at /var/lib/asterisk/agi-bin/pirate.agi line 25, near "$AGI->exec('AGI',"festival"
(Missing operator before festival?)
syntax error at /var/lib/asterisk/agi-bin/pirate.agi line 22, near "print "$_"
Global symbol "$i" requires explicit package name at /var/lib/asterisk/agi-bin/pirate.agi line 22.
Global symbol "$i" requires explicit package name at /var/lib/asterisk/agi-bin/pirate.agi line 22.
Global symbol "$i" requires explicit package name at /var/lib/asterisk/agi-bin/pirate.agi line 22.
Global symbol "$i" requires explicit package name at /var/lib/asterisk/agi-bin/pirate.agi line 25.
Unmatched right curly bracket at /var/lib/asterisk/agi-bin/pirate.agi line 26, at end of line
Execution of /var/lib/asterisk/agi-bin/pirate.agi aborted due to compilation errors.

:/



segmentedone
Posts: 24
Member Since:
2007-03-23
never mind got it to work...

never mind got it to work... with this

my $test = $prepend . " " . $insultgenerator;
$AGI->exec('AGI',"festival-weather-script.pl|\"$test");

dont know exacly why you output to a file.

anyway thats cool heh



The Deacon
Posts: 24
Member Since:
2007-03-02
Same problem - won't work

Here is what I get:

Scalar found where operator expected at /var/lib/asterisk/agi-bin/pirate.agi line 20, near "print "$_"
(Might be a runaway multi-line "" string starting on line 18)
(Do you need to predeclare print?)
Backslash found where operator expected at /var/lib/asterisk/agi-bin/pirate.agi line 20, near "$_\"
(Missing operator before \?)
String found where operator expected at /var/lib/asterisk/agi-bin/pirate.agi line 23, near "#my $test = $prepend . ""
(Might be a runaway multi-line "" string starting on line 20)
(Missing semicolon on previous line?)
String found where operator expected at /var/lib/asterisk/agi-bin/pirate.agi line 24, near "$AGI->exec('AGI',""
(Might be a runaway multi-line "" string starting on line 23)
(Missing semicolon on previous line?)
Bareword found where operator expected at /var/lib/asterisk/agi-bin/pirate.agi line 24, near "$AGI->exec('AGI',"festival"
(Missing operator before festival?)
syntax error at /var/lib/asterisk/agi-bin/pirate.agi line 20, near "print "$_"
Global symbol "$i" requires explicit package name at /var/lib/asterisk/agi-bin/pirate.agi line 20.
Global symbol "$i" requires explicit package name at /var/lib/asterisk/agi-bin/pirate.agi line 20.
Global symbol "$i" requires explicit package name at /var/lib/asterisk/agi-bin/pirate.agi line 20.
Global symbol "$test" requires explicit package name at /var/lib/asterisk/agi-bin/pirate.agi line 20.
Global symbol "$test" requires explicit package name at /var/lib/asterisk/agi-bin/pirate.agi line 24.
Unmatched right curly bracket at /var/lib/asterisk/agi-bin/pirate.agi line 25, at end of line
Execution of /var/lib/asterisk/agi-bin/pirate.agi aborted due to compilation errors.

Any clue as to what's going on? I don't...



segmentedone
Posts: 24
Member Since:
2007-03-23
replace open(INPUT,")

replace

open(INPUT,") {
push(@lines,$_);
print "$_\n";
}

for(my $i = 0; $i < scalar(@lines); $i++) {
$AGI->exec('AGI',"festival-weather-script.pl|\"$lines[$i]\"");
}

with

my $test = $prepend . " " . $insultgenerator;
$AGI->exec('AGI',"festival-weather-script.pl|\"$test");

and it will work, the problem comes form the open, push, print part i dont know AGI enough to know why...



Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.