C
CADD
Can anyone help transform this Perl into C#?
use LWP::UserAgent;
# Our user ID.
my $custid = "Test";
# Our message.
my $msg = "Hello";
# Lowercase and remove spaces/underscores in user name.
$custid = lc($custid);
$custid =~ s/ //ig;
$custid =~ s/_//ig;
# Create a new useragent. This creates an instance of the UserAgent
module.
# Name your agent whatever you like or keep the default. Your bot's
name is
# a good suggestion.
$ua = new LWP::UserAgent;
$ua->agent("AgentName/1.0 " . $ua->agent);
# Create a request. This sets up the POST string.
# Field values sent two diff ways shown here. You will need to add your
own
# bot's id for the botid= field.
my $req = new HTTP::Request POST
=>("http://www.pandorabots.com/pandora/talk-xml?botid=id
here&input=$msg");
$req->content_type('application/x-www-form-urlencoded');
$req->content("custid=$custid");
# Pass request to the user agent and get a response back.
my $res = $ua->request($req);
# Create a variable to hold content. You now have the
# full source of the reply from the API, including markup, user input,
# and Pandora response code.
my $reply = $res->content;
# Create a variable holding everything in between <that></that> tags,
which
# is where the actual bot reply is.
($response = $reply) =~ s/^.*(\<that\> .*)\<\/that\>.*$/$1/m;
# Strip remaining tags and trim string.
$response =~ s/<that>/ /g;
$response =~ s/^\s+//;
$response =~ s/\s+$//;
# Convert tags for quotes and links in AIML.
$response =~ s/"/\"/g;
$response =~ s/&lt;/</g;
$response =~ s/&quot;/\"/g;
$response =~ s/&gt;/>/g;
# $response now holds just the bot's reply. Print or return $response
here
based on your app.
Thank you in advance for your time.
use LWP::UserAgent;
# Our user ID.
my $custid = "Test";
# Our message.
my $msg = "Hello";
# Lowercase and remove spaces/underscores in user name.
$custid = lc($custid);
$custid =~ s/ //ig;
$custid =~ s/_//ig;
# Create a new useragent. This creates an instance of the UserAgent
module.
# Name your agent whatever you like or keep the default. Your bot's
name is
# a good suggestion.
$ua = new LWP::UserAgent;
$ua->agent("AgentName/1.0 " . $ua->agent);
# Create a request. This sets up the POST string.
# Field values sent two diff ways shown here. You will need to add your
own
# bot's id for the botid= field.
my $req = new HTTP::Request POST
=>("http://www.pandorabots.com/pandora/talk-xml?botid=id
here&input=$msg");
$req->content_type('application/x-www-form-urlencoded');
$req->content("custid=$custid");
# Pass request to the user agent and get a response back.
my $res = $ua->request($req);
# Create a variable to hold content. You now have the
# full source of the reply from the API, including markup, user input,
# and Pandora response code.
my $reply = $res->content;
# Create a variable holding everything in between <that></that> tags,
which
# is where the actual bot reply is.
($response = $reply) =~ s/^.*(\<that\> .*)\<\/that\>.*$/$1/m;
# Strip remaining tags and trim string.
$response =~ s/<that>/ /g;
$response =~ s/^\s+//;
$response =~ s/\s+$//;
# Convert tags for quotes and links in AIML.
$response =~ s/"/\"/g;
$response =~ s/&lt;/</g;
$response =~ s/&quot;/\"/g;
$response =~ s/&gt;/>/g;
# $response now holds just the bot's reply. Print or return $response
here
based on your app.
Thank you in advance for your time.