User Control Panel
Advertisements

HELP US, HELP YOU!

Search Command

 
Post new topic   Reply to topic    Bot Depot Forum Index -> AIM Protocol & questions
View unanswered posts
Author Message
Tony_shu
God Like
God Like


Joined: 12 Nov 2003
Posts: 624

Reputation: 42.9Reputation: 42.9Reputation: 42.9Reputation: 42.9

PostPosted: Sun Nov 30, 2003 4:19 am    Post subject: Reply with quote

Hey...I have some lazy people talking to my bot who want it to work kind of like smarterchild. They asked if I could have it do "searches" for them...as if they couldn't search google themselves.
As it currently stands, my bot replies to those who ask to "search", that they should go to google and do it themselves.

However, is there a way that I could get the bot to retrieve search results?

Right now I'm having a little trouble having the bot respond with a link to a page of results.
Code:
sub search {<br /><br />   #Asks if this is an admin-only command? (1 for yes, 0 for no).<br />   $adminonly = 0;<br /><br />   #Retrieves the admin's screenname.<br />   open (FILE, "commands/admin.txt");<br />   @admin = <FILE>;<br />   close(FILE);<br />   chomp(@admin);<br />    <br />   #Retrieves the message and the victim.<br />   my $victim = shift;<br />   my $msg = shift;<br />   my $aim = shift;<br /><br />  #Take the prefix off of the message.<br />  $msg =~ s/\/search //ig;<br /><br />  #Assigns the message & creator<br />  my $search = $msg;<br />  my $link = "<a href='http://www.google.com/search?hl=en&lr=&ie=UTF-8&oe=UTF-8&q=$search'>Click here for Results</a>";<br /><br />  #If the message is in an improper format...<br />  if ($search eq "") {<br />      #Replies improper format.<br />      $reply = "Your command was in an improper format. The proper format is:"<br />             . "  /search what\n"<br />             . " what = what you are actually searching for";<br />     #Otherwise, continue.<br />  } else {<br />     #Send the search.<br />     $reply = "Searching!...$link";<br />  }<br /><br />  #Return the reply.<br />  return $reply; <br />}<br />1;
The bot respods with the $reply (from above)...and $link actually appears in the response, as a link....but there is no url that it links to. The link is a dead link, that when clicked does nothing.

When I use the following for my $link...
Code:
"<a href="http://www.google.com/search?hl=en&lr=&ie=UTF-8&oe=UTF-8&q=$search">Click here for Results</a>";
...I can't even get the bot to run, because it doesn't like having the "" appear more than once in $link
_________________
Anthony Arslan
@-Squared Enterprises
MacroHard Corporation
Back to top
Mojave
Almost An Agent
Almost An Agent


Joined: 01 Nov 2003
Posts: 1434

Reputation: 66.4

PostPosted: Sun Nov 30, 2003 6:09 am    Post subject: Reply with quote

The first thing you should do for all of your non-admin commands, is remove the admin code at the top. Since you are not using the variable $adminonly and you're not checking against the list of admins, there's no reason to open the file and read them in. It's not all that inefficient, but it is completely useless and increases the size of your code by 7 lines for no reason.

Now, to solve your problem, simply escape the double quotes inside your $link variable. If you want to have double quotes inside a string, do this:

Code:
my $string = "The girl said \"hello\".";


p.s Which bot are you using? I might write a simple tutorial on how to fix the code so that the list of admins is read in only once, not every single time an admin command is executed.
Back to top
Nate
God Like
God Like


Joined: 12 Nov 2003
Posts: 553

Reputation: 41.3Reputation: 41.3Reputation: 41.3Reputation: 41.3

PostPosted: Sun Nov 30, 2003 2:07 pm    Post subject: Reply with quote

You can also use a Google mod which will be able to return the first 5 search results or so right in the IM window. I think it's called Net::Google or something. There's also one for Yahoo! search.
Back to top
Tony_shu
God Like
God Like


Joined: 12 Nov 2003
Posts: 624

Reputation: 42.9Reputation: 42.9Reputation: 42.9Reputation: 42.9

PostPosted: Sun Nov 30, 2003 5:13 pm    Post subject: Reply with quote

My bot is an AIM Bot
_________________
Anthony Arslan
@-Squared Enterprises
MacroHard Corporation
Back to top
Keenie
Almost An Agent
Almost An Agent


Joined: 31 Oct 2003
Posts: 1071

Reputation: 52.4

PostPosted: Mon Dec 01, 2003 1:48 am    Post subject: Reply with quote

you could use this, that i posted before after we got it working on the old site

1.Register with Google for your Google API key. You can do that here
2.Open up PPM and install SOAP::Lite
3.Open up bot.pl and find where it says:
Quote:
 
#Use LWP-Simple for retreival of text files.
use LWP::Simple;

add underneath that:
Code:
 <br />use SOAP::Lite;<br />$googlekey = 'put-you-google-API-licence-key-here'; <br />

4. Make a file called google.pl in your commands folder and add this code:
Code:
<br />sub google<br />{<br /> my $victim = shift;<br /> my $msg = shift;<br /> $msg =~ /\/google (.*)$/;<br /> return GoogleSearch($1);<br />}<br /><br />sub GoogleSearch{<br />my $q = shift;<br />my $max = 5;<br />my $startat = 0;<br />my $restrict = '';<br />my $language = '';<br />my @hello = ($googlekey, $q, $startat, $max, 1, $restrict, 1, $language, 'UTF-8', 'UTF-8');<br /><br />my $bye = SOAP::Lite -> service("http://api.google.com/GoogleSearch.wsdl") -> doGoogleSearch(@hello);<br /><br />$count = 0;<br />$reply = "Results:\n\n";<br />foreach $you (@{$bye->{resultElements}}){ <br />$reply .= "\n".++$count.": ". $you->{title} . " - ". $you->{URL};<br />}<br /><br />return $reply;<br />}<br />1; <br />


then you can filter out the and stuff, and customize it for how you want it..
Back to top
Tom Clancy
Young One
Young One


Joined: 24 Jan 2004
Posts: 57

Reputation: 28.9Reputation: 28.9Reputation: 28.9

PostPosted: Mon Feb 09, 2004 11:43 pm    Post subject: Reply with quote

QUOTE(Keenie @ Nov 30 2003, 05:48 PM)
you could use this, that i posted before after we got it working on the old site

1.Register with Google for your Google API key. You can do that here
2.Open up PPM and install SOAP::Lite
3.Open up bot.pl and find where it says:

What the hell is PPM?? <_<
Back to top
Keenie
Almost An Agent
Almost An Agent


Joined: 31 Oct 2003
Posts: 1071

Reputation: 52.4

PostPosted: Mon Feb 09, 2004 11:49 pm    Post subject: Reply with quote

programmers package manager..
open /perl/bin/ppm.bat or go to run and type ppm, or type ppm at the command prompt..
then you can type
search some::file
Back to top
Tom Clancy
Young One
Young One


Joined: 24 Jan 2004
Posts: 57

Reputation: 28.9Reputation: 28.9Reputation: 28.9

PostPosted: Mon Feb 09, 2004 11:52 pm    Post subject: Reply with quote

did that got an error:
C:\ActivePerl\Perl\bin>ppm.bat
Error: neither 'HKEY_LOCAL_MACHINE/SOFTWARE/ActiveState/PPM//InstallLocation' no
*lazy* 'HKEY_CURRENT_USER/SOFTWARE/ActiveState/PPM//InstallLocation' found in registr
*lazy* at ppm.bat line 29.



EDIT::lemme check my registry....

EDIT:: Active State Folder was NOT found...
Back to top
Cer
Upgraded Agent
Upgraded Agent


Joined: 03 Feb 2004
Posts: 3776
Location: Michigan
Reputation: 146.9
votes: 4

PostPosted: Tue Feb 10, 2004 2:27 pm    Post subject: Reply with quote

Reinstall ActivePerl. Wink
_________________
Current Site (2008) http://www.cuvou.com/
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Bot Depot Forum Index -> AIM Protocol & questions All times are GMT
Page 1 of 1

 



Protected by phpBB Security phpBB-TweakS
phpBB Security Has Blocked 9 Exploit Attempts.
Antispam Captcha Mod by phpbb-security.com
Powered by phpBB © 2001, 2005 phpBB Group