Posted: Fri Jul 08, 2005 8:30 pm Post subject: Bunch of errors
Code:
use Net::OSCAR qw(:standard);
my $screenname = "Bot";
my $password = "pass";
my $master = "Me";
sub im_in {
my($oscar, $client, $msg, $is_away) = @_;
$msg =~ s/<(.|\n)+?>//g;
print "[AWAY] " if $is_away;
print "$client: $msg\n";
if ($msg eq "Hi") {
$reply = "Hello $client";
} elsif ($msg eq "Hello") {
$reply = "Hi $client";
} elsif ($msg eq "How are you") {
$reply = "I am fine, thanks for asking";
} elsif ($msg eq "Who made you") {
$reply = "$master made me from scratch";
} elsif ($msg eq "bot.pl") {
open (BOT,"./bot.pl");
@bot= <BOT>;
close (BOT);
$reply = @bot;
} elsif ($msg eq "Stealth on") {
$oscar->set_stealth (is_stealth);
} elsif ($msg eq "Stealth off) {
$oscar->set_stealth();
} elsif ($msg eq info on (.*)) {
$infoperson = $1;
$oscar->get_info ($infoperson);
} else {
$reply = "Unknown reply";
}
print "$screenname: $reply\n";
$oscar->send_typing_status ($client,TYPINGSTATUS_STARTED);
sleep(3);
$oscar->send_im ($client,$reply);
$oscar->send_typing_status ($client,TYPINGSTATUS_FINISHED);
}
sub buddy_in {
my($oscar, $person, $group, $data) = @_;
print "\n\n$person ($group) just signed in\n\n";
}
sub buddy_out {
my($oscar, $person, $group) = @_;
print "\n\n$person ($group) just signed out\n\n";
}
sub signon_done {
my($oscar) = @_;
my $buddyprofile = "$screenname was made from scratch by $master";
print "$buddyprofile";
$oscar->set_info ($buddyprofile);
$oscar->set_visibility (VISMODE_DENYSOME);
$oscar->commit_buddylist();
print "\n\n$screenname has finished signing into AIM\n\n";
}
sub buddlist_error {
my($oscar,$error,$what) = @_;
print "$error $what";
}
sub buddylist_ok {
my($oscar) = @_;
print "Buddylist changes have been successfully commited";
}
sub evil{
my($oscar,$newlevel,$warner) = @_;
if ($warner ne "") {
print "$warner has warned us to $newlevel";
print "We are now warning $warner back";
$oscar->evil ($warner);
print "We are now adding $warner to the deny list";
$oscar->add_deny ($warner);
$oscar->commit_buddylist();
print "Currently, these are the people on the deny list:";
$oscar->get_denylist();
}
else {
print "We have been warned anonymously";
}
}
sub buddy_info {
my($oscar,$screenname,$data) = @_;
print "$screenname \n $data";
}
#Sign into AIM
$oscar->signon($screenname, $password);
while(1) {
$oscar->do_one_loop();
}
Error:
Quote:
Bareword found where operator expected at bot.pl line 35, near "$reply = "Unknow
n"
(Might be a runaway multi-line "" string starting on line 29)
(Missing operator before Unknown?)
Scalar found where operator expected at bot.pl line 38, near "print "$screenname
"
(Might be a runaway multi-line "" string starting on line 35)
(Do you need to predeclare print?)
Backslash found where operator expected at bot.pl line 38, near "$reply\"
(Missing operator before \?)
String found where operator expected at bot.pl line 46, near "print ""
(Might be a runaway multi-line "" string starting on line 3
(Missing semicolon on previous line?)
Backslash found where operator expected at bot.pl line 46, near "print "\"
(Do you need to predeclare print?)
Backslash found where operator expected at bot.pl line 46, near "n\"
Bareword found where operator expected at bot.pl line 46, near ") just"
(Missing operator before just?)
Backslash found where operator expected at bot.pl line 46, near "in\"
Backslash found where operator expected at bot.pl line 46, near "n\"
String found where operator expected at bot.pl line 51, near "print ""
(Might be a runaway multi-line "" string starting on line 46)
(Missing semicolon on previous line?)
Backslash found where operator expected at bot.pl line 51, near "print "\"
(Do you need to predeclare print?)
Backslash found where operator expected at bot.pl line 51, near "n\"
Bareword found where operator expected at bot.pl line 51, near ") just"
(Missing operator before just?)
Backslash found where operator expected at bot.pl line 51, near "out\"
Backslash found where operator expected at bot.pl line 51, near "n\"
String found where operator expected at bot.pl line 55, near "my $buddyprofile =
""
(Might be a runaway multi-line "" string starting on line 51)
(Missing semicolon on previous line?)
Scalar found where operator expected at bot.pl line 55, near "my $buddyprofile =
"$screenname"
(Do you need to predeclare my?)
Bareword found where operator expected at bot.pl line 55, near "$screenname was"
(Missing operator before was?)
String found where operator expected at bot.pl line 56, near "print ""
(Might be a runaway multi-line "" string starting on line 55)
(Missing semicolon on previous line?)
Scalar found where operator expected at bot.pl line 56, near "print "$buddyprofi
le"
(Do you need to predeclare print?)
String found where operator expected at bot.pl line 60, near "print ""
(Might be a runaway multi-line "" string starting on line 56)
(Missing semicolon on previous line?)
Backslash found where operator expected at bot.pl line 60, near "print "\"
(Do you need to predeclare print?)
Backslash found where operator expected at bot.pl line 60, near "n\"
Backslash found where operator expected at bot.pl line 60, near "AIM\"
Backslash found where operator expected at bot.pl line 60, near "n\"
String found where operator expected at bot.pl line 64, near "print ""
(Might be a runaway multi-line "" string starting on line 60)
(Missing semicolon on previous line?)
Scalar found where operator expected at bot.pl line 64, near "print "$error"
(Do you need to predeclare print?)
Scalar found where operator expected at bot.pl line 64, near "$error $what"
(Missing operator before $what?)
String found where operator expected at bot.pl line 68, near "print ""
(Might be a runaway multi-line "" string starting on line 64)
(Missing semicolon on previous line?)
Bareword found where operator expected at bot.pl line 68, near "print "Buddylist
"
(Do you need to predeclare print?)
String found where operator expected at bot.pl line 73, near "print ""
(Might be a runaway multi-line "" string starting on line 72)
(Missing semicolon on previous line?)
Scalar found where operator expected at bot.pl line 73, near "print "$warner"
(Do you need to predeclare print?)
Bareword found where operator expected at bot.pl line 73, near "$warner has"
(Missing operator before has?)
String found where operator expected at bot.pl line 74, near "print ""
(Might be a runaway multi-line "" string starting on line 73)
(Missing semicolon on previous line?)
Bareword found where operator expected at bot.pl line 74, near "print "We"
(Do you need to predeclare print?)
Bareword found where operator expected at bot.pl line 74, near "$warner back"
(Missing operator before back?)
String found where operator expected at bot.pl line 76, near "print ""
(Might be a runaway multi-line "" string starting on line 74)
(Missing semicolon on previous line?)
Bareword found where operator expected at bot.pl line 76, near "print "We"
(Do you need to predeclare print?)
Bareword found where operator expected at bot.pl line 76, near "$warner to"
(Missing operator before to?)
Bareword found where operator expected at bot.pl line 79, near "print "Currently
"
(Might be a runaway multi-line "" string starting on line 76)
(Do you need to predeclare print?)
Bareword found where operator expected at bot.pl line 83, near "print "We"
(Might be a runaway multi-line "" string starting on line 79)
(Do you need to predeclare print?)
String found where operator expected at bot.pl line 88, near "print ""
(Might be a runaway multi-line "" string starting on line 83)
(Missing semicolon on previous line?)
Scalar found where operator expected at bot.pl line 88, near "print "$screenname
"
(Do you need to predeclare print?)
Backslash found where operator expected at bot.pl line 88, near "$screenname \"
(Missing operator before \?)
String found where operator expected at bot.pl line 88, at end of line
(Missing semicolon on previous line?)
syntax error at bot.pl line 35, near "$reply = "Unknown reply"
Can't find string terminator '"' anywhere before EOF at bot.pl line 88.
Press any key to continue . . .
Most of those are warnings (and BIG warnings too, ones that should be taken care of).
The one that really did it in for your bot was right here though:
Code:
syntax error at bot.pl line 35, near "$reply = "Unknown reply"
Can't find string terminator '"' anywhere before EOF at bot.pl line 88.
Take care of that, run the code again, if it finds another fatal error (hint: the fatal ones are usually the ones right at the end, they kill your code so that's the logical place to look for them ).
And continue.
Edit
Just cuz I was bored I decided I'd help ya a bit:
I had no clue how to fix the print things at the top, so I started by looking at the bottom (the one you posted). Originally, I had it just saying "Unknown" so I had an error saying something about only having one word. So I changed it to "Unknown Reply". But now, it says I don't have a string terminator. I checked it over 5 times, and I am possitive I have quotes and a semicolon there. I even tried adding "my" in front of the variable, but it gave me the same error. Finally, I downloaded a perl code notepad to see if it would help. I got nothing from it. I have no clue what to do. That is why I posted here.
Those syntax highlighters are useful though. Usually your code should be all bright and colorful, but when all your code ends up being all one color, look up where the color started at and that's probably the error. _________________ Current Site (2008) http://www.cuvou.com/
Missing a quote and it's the first one just before your $reply = "Unknown reply"; . Fix this and many of the others will probably go away.
Your code is riddled with syntax errors. _________________ Check out Botworld! A dev resource for things bot.
Downloads, articles, news, fourm and more.
http://botworld.marzopolis.com
Before you replied Alienz, I tried switching the reply system to something based on the trigger module (don't worry, I have the other reply system saved). It says:
Quote:
Missing right curly or square bracket at bot.pl line 128, at end of line
syntax error at bot.pl line 128, at EOF
Execution of bot.pl aborted due to compilation errors.
Press any key to continue . . .
I assumed that the missing sign would be in the on_im sub since that is the only one I've been editing. So I started counting the brackets in there. And I wasn't missing any. Then I looked at the other subs, they all had them. Then I looked at line 128, and it had everything. NOTE: This was done in Notepad since my perl editor is no good for that. So I might have missed something. Here it is:
Code:
sub im_in {
my($oscar, $client, $msg, $is_away) = @_;
$msg =~ s/<(.|\n)+?>//g;
print "[AWAY] " if $is_away;
print "$client: $msg\n";
if( $msg eq '' ) {
open (REPLY, "./reply.txt");
@reply = <REPLY>;
close (REPLY);
If you INDENT then it should be easier to work it out. You were missing one near the end:
Code:
sub im_in
{
my($oscar, $client, $msg, $is_away) = @_;
$msg =~ s/<(.|\n)+?>//g;
print "[AWAY] " if $is_away;
print "$client: $msg\n";
if ($msg eq '')
{
open (REPLY, "./reply.txt");
@reply = <REPLY>;
close (REPLY);
foreach my $line (@reply)
{
my ($first, $last) = split( /:/, $line );
if( $msg =~ /$first/i )
{
if( $last =~ /^service:(.*)$/i )
{
my $service_string = $1;
$service_string =~ s/##MESSAGE##/$msg/g;
my $reply = get( $service_string );
}
else
{
my @last = split( /\|/, $last );
$reply [ int rand scalar @last ];
}
}
}
}
print "$screenname: $reply\n";
$oscar->send_typing_status ($client,TYPINGSTATUS_STARTED);
sleep(3);
$oscar->send_im ($client,$reply);
$oscar->send_typing_status ($client,TYPINGSTATUS_FINISHED);
}
Just a note: I indent with tabs, as it's more efficient, and is easier to change about, but I used spaces here, as phpBB doesn't count tabs.
Also, I moved one bracket around, for the foreach, so that it will work as it's meant to. _________________ ~ Josh
[ Need bot hosting on a dedicated server? PM me. ]
You'd save yourself alot of trouble if you used an editor with syntax highlighting or syntax checking. There are plenty of free ones out there that do that. Just about every problem I've seen you have is because you are not using proper syntax in your code. _________________ Check out Botworld! A dev resource for things bot.
Downloads, articles, news, fourm and more.
http://botworld.marzopolis.com
Joined: 03 May 2006 Posts: 2292 Location: Colorado
Posted: Sun Jul 10, 2005 3:36 pm Post subject:
You will get a more positive response (and this is in response to one of your other posts as well as this problem) if you SHOW what you have tried. Also when debugging never worry about anything but the first error you get. Until you fix it, there is no telling what other errors the same mistake is causeing. So in this case once you got the help to fix stealth you should have had a much smaller set of errors to work with. Continue working with the first error. BTW the actual error will normaly be on the same line OR a line above it. So if you don't find trouble on that line then look up farther until you do. Also commenting out the line it gives you might lead you to the correct line. If you want to continue getting help (and it looks like lots of people are showing up to help agian) then its best to include a peice of code with maybe ten lines above and including the line the error is reported on AND what you have tried. Remember what causes each error becuase that will significantly help you the next time. We have all gotten these errors oursleves and spent time tracking them down and learning there causes. We understand that you are learning perl, we have all been there, we don't mind helping, but we don't want to do your work for you. So just pay attention and learn from your previous mistakes and all will go well. This is for any new person, you are just the one brave enough to keep posting Best of luck and lets see if we can't help you get your code running! _________________ Eric256
Proud previous owner and current admin of Bot-depot.com
No, it isn't showing an error, because I fixed your syntaxes. Now you just need to go through and work out what you want it to do, so that it sends the message.
The if ($msg eq '') isn't helping, either. _________________ ~ Josh
[ Need bot hosting on a dedicated server? PM me. ]