well the first thin i can think off...is that the admin portion of your code is wrong...replace this for where you have $adminonly:
Code:
#Asks if this is an admin-only command? (1 for yes, 0 for no).<br />my $adminonly = 1;<br /><br />#Retrieves the admin's screenname.<br />open (FILE, "admin.txt");<br />my @admin = <FILE>;<br />close(FILE);<br />chomp @admin;<br /><br />my $is_admin = 0;<br /><br />foreach my $admin (@admin) {<br /> if ($victim eq $admin) {<br /> $is_admin = 1;<br /> break;<br /> }<br />}
In admin.txt, list all your screennames like this:
Quote:
kirsle watereternity guardchaos
The bot will automatically look in the admin.txt to see if the $victim is an admin... Then continue the rest of your away.pl code in between this:
Code:
if ($adminonly == 1 && $is_admin == 1) {<br /> put the part of the code you want the bot to execute if $victim is admin<br />} else {<br /> $reply = "Sorry you are not an admin...and this is an admin only command.";<br />}<br /><br />return $reply;
Now thats all I know I can fix for your away.pl command...because I don't really know how to make the away command work in itself...assuming the rest of the command is good...my fixes will make it adminonly.
For your second issue...with data.txt You have the symbols wrong...i believe they should be:
That way the bot will look for "whaz" or "what's" in the beginning of any message...or it will look for "what's up","sup", or "whats up" anywhere in any message. _________________ Anthony Arslan
@-Squared Enterprises
MacroHard Corporation
Hrmmm.... I can't seem to find exactly where the "$is_admin" statement is.... I downloaded the source from Chaosbot.tk and there was alot of bugs to begin with... Do you reccommend a different distribution for a not-to-good-person-with-perl like me?
Yeah... sorry if I get annoying sometimes... I'm not the biggest fan of perl.
OK...I have managed to amaze myself...because I think this will actually work! If it does...I'd like to thank people like Eric for helping me learn (sorry for the extra excitement...but this is the first code I've worked-out without begging for help)
This should be a working away.pl
Code:
sub away {<br /><br /> my ($victim,$msg,$aim) = (shift,shift,shift);<br /><br /> #Asks if this is an admin-only command? (1 for yes, 0 for no).<br /> my $adminonly = 1;<br /><br /> #Retrieves the admin's screenname.<br /> open (FILE, "admin.txt");<br /> my @admin = <FILE>;<br /> close(FILE);<br /> chomp @admin;<br /><br /> my $is_admin = 0;<br /><br /> foreach my $admin (@admin) {<br /> if ($victim eq $admin) {<br /> $is_admin = 1;<br /> break;<br /> }<br /> }<br /><br /> $msg =~ s/(\/|\.|\!)away //ig;<br /><br /> #If the command is admin-only and the victim is not the admin...<br /> if($adminonly == 1 && $is_admin == 0) {<br /><br /> #Return an error message.<br /> $reply = "Sorry, this is an Admin-only command.";<br /><br /> } elsif ($adminonly == 1 && $is_admin == 1) {<br /> if ($msg eq "1") {<br /> $reply = "Away with message: I am away from my computer. Yes, even bots can be away from their computer :-D.";<br /> $auto = "I am away from my computer. Yes, even bots can be away from their computer :-D.";<br /> $aim->set_away("$auto");<br /> $away = "true";<br /> open (STAT,">status.txt");<br /> print STAT "away\n$auto\n";<br /> close(STAT);<br /> } elsif ($msg eq "back") {<br /> $reply=("I am no longer away.");<br /> $aim->set_away("");<br /> $away = "false";<br /> open (STAT,">status.txt");<br /> print STAT "here\n";<br /> close(STAT);<br /> } else {<br /> $reply = "Away with message: $msg";<br /> $autoa = "$msg";<br /> $aim->set_away("$msg");<br /> $away = "true";<br /> open (STAT,">status.txt");<br /> print STAT "away\n$autoa\n";<br /> close(STAT);<br /> }<br /> }<br /><br /> return $reply;<br /><br />}<br />1;
/away 1 will give the first standard awaymessage /away back will get the bot back online /away *anything* will set the awaymessage to *anything*
Now this is what I have in my on_im.pl ...and it works!
Code:
sub on_im {<br /><br /> my ($aim, $event) = @_;<br /> my ($victim, $friend, $msg) = @{$event->args()};<br /> my $reply;<br /> #Filter for $victim and make it lower case and remove spaces<br /> $victim = lc($victim);<br /> $victim =~ s/ //g;<br /><br /> open (ADME, "commands/admin.txt");<br /> my @admin = <ADME>;<br /> close(ADME);<br /> chomp @admin;<br /> $is_admin = 0;<br /> foreach my $admin (@admin) {<br /> if ($victim eq $admin) {<br /> $is_admin = 1;<br /> break;<br /> }<br /> }<br /><br /> open (STAT,"status.txt");<br /> @stat = <STAT>;<br /> close(STAT);<br /> chomp(@stat);<br /> foreach my $state (@stat) {<br /> if ($state eq "away" && $is_admin == 0) {<br /> $msg =~ s/<(.|\n)+?>//gi;<br /> $reply = @stat[1];<br /> } elsif ($state eq "here" || $state eq "away" && $is_admin == 1) {<br /><br /> #########################################<br /> PLACE YOUR NORMAL ON_IM.PL CODE IN HERE<br /> #########################################<br /><br /> }<br /> }<br /><br /> print "$victim: $msg\n$screenname: $reply\n\n";<br /> sleep(1); #2 is the original value<br /> <br /> $stat = block($victim);<br /> if ($stat ne "1") {<br /> $aim->send_im($victim, "$reply");<br /> addtar($victim);<br /> } else {<br /> $aim->evil($victim, 0);<br /> }<br /> <br /> #Log the IM.<br /> log_im($victim,$msg,$screenname,$reply);<br /><br /><br />}<br />1;
Now how this works is ... in the part of the code that looks in status.txt, it checks if the bot is "away" or "here" If the bot is "here"...then the bot works normally. If the bot is "away"...and the admin messages it...it will work normally. If the bot is "away"...and another individual messages it...it will send the away message as a response...I don't know how to have the bot "auto respond" like AIM. _________________ Anthony Arslan
@-Squared Enterprises
MacroHard Corporation
oh...i wasn't implying i created it..i was just amazed i got it to work without begging for help... l l _________________ Anthony Arslan
@-Squared Enterprises
MacroHard Corporation