User Control Panel
Advertisements

HELP US, HELP YOU!

/Away command...

 
Post new topic   Reply to topic    Bot Depot Forum Index -> Perl
View unanswered posts
Author Message
Hollowe
Newbie
Newbie


Joined: 13 Dec 2003
Posts: 4

Reputation: 29.3Reputation: 29.3Reputation: 29.3

PostPosted: Sat Dec 13, 2003 7:28 pm    Post subject: Reply with quote

The /away command is always saying that I am not admin... while my /sendim command is admin only, but allows me to process. Howcome it won't work?

My code for away.pl:
Code:
<br />sub away {<br />    #Is this an admin-only command?  (1 for yes, 0 for no).<br />    $adminonly = 1;<br /><br />    $victim = shift;<br />    $msg = shift;<br /><br />    #assign vars to $msg after splitting.<br />   ($bad,$message) = split(/:/,$msg);<br /><br /><br /><br />    #If the command is admin-only and the victim is not the admin...<br />    if($adminonly == 1 && $victim !~ /kirsle/i && $victim !~ /watereternity/i && $victim !~ /guardchaos/i) {<br /><br />    #Return an error message.<br />    $reply = "Sorry, This is an Admin-only command.";<br /><br />    #Otherwise, continue.<br />    } else {<br />   if ($message eq "0") {<br />  if ($away ne "true") {<br />     $reply=("<body bgcolor=white><font color=003399 face=Verdana size=1><b>"<br />    . "Away with message: Away due to warners.");<br />     $aim->set_away("<body bgcolor=white><font color=003399 face=Verdana size=1><b>Away due to warners...</b></font>");<br />     $away = "true";<br />     $warned = "true";<br />  }<br />  else {<br />     #Ignore it<br />  }<br />   }<br />   elsif ($message eq "1") {<br />  $reply=("<body bgcolor=white><font color=003399 face=Verdana size=1><b>"<br />     . "Away with message: I am away from my computer.");<br />  $aim->set_away("<body bgcolor=white><font color=003399 face=Verdana size=1><b>I am away from my computer.</b></font>");<br />  $away = "true";<br />   }<br />   elsif ($message eq "2") {<br />  $reply=("<body bgcolor=white><font color=003399 face=Verdana size=1><b>"<br />     . "Away with message: All three of my AIM screen names have been warned. I can now only be reached via MSN on the ScreenName azulianbot\@hotmail.com.");<br />  $aim->set_away("<body bgcolor=white><font color=003399 face=Verdana size=1><b>All three of my AIM screen names have been warned. I can now only be reached via MSN on the ScreenName azulianbot\@hotmail.com.</b></font>");<br />  $away = "true";<br />   }<br />   elsif ($message eq "x") {<br />  $reply=("<body bgcolor=white><font color=003399 face=Verdana size=1><b>"<br />     . "Away with message: Warners...");<br />  $aim->set_away("<body bgcolor=white><font color=003399 face=Verdana size=1><b>Warners...</b></font>");<br />  $away = "true";<br />  $warned = "true";<br />   }<br />   elsif ($message eq "") {<br />  $reply=("<body bgcolor=white><font color=003399 face=Verdana size=1><b>"<br />     . "I am no longer away.");<br />  $aim->set_away("");<br />  $away = "false";<br />  $warned = "false";<br />   }<br />   else {<br />  $reply=("<body bgcolor=white><font color=003399 face=Verdana size=1><b>"<br />     . "Away with message: $message");<br />  $aim->set_away("<body bgcolor=white><font color=003399 face=Verdana size=1><b>$message</font>");<br />  $away = "true";<br />   }<br />}<br /><br /><br />#send 'er back!<br />return $reply;<br /><br />}<br />1;<br />


And another thing I wanted to ask was.... When you use "data.txt" for the responses... Can you add a reply from the bot? Like I have:

Code:
<br />what's up|whaz ^|what's ^|sup|whats up][Nm... you?|Nothing really...|I'm tired...<br />


Can I have the bot reply to what they say after that?

Like so:

Me: Hey
Bot: Hello....
Me: What's up?
Bot: Nmh *lazy*?
Me: Me neither..
Bot: Same old, eh....

Thanks!
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: Sat Dec 13, 2003 8:58 pm    Post subject: Reply with quote

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:
Code:
^(whaz |what's )|(what's up|sup|whats up)][Nm... you?|Nothing really...|I'm tired...
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
Back to top
Hollowe
Newbie
Newbie


Joined: 13 Dec 2003
Posts: 4

Reputation: 29.3Reputation: 29.3Reputation: 29.3

PostPosted: Sun Dec 14, 2003 12:33 am    Post subject: Reply with quote

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.
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 Dec 14, 2003 4:48 am    Post subject: Reply with quote

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 Very Happy (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
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 Dec 14, 2003 10:52 pm    Post subject: Reply with quote

lol Very Happy that's one of the Chaosbot programs... the three screen names there, two were the CKS admin and the third was a guardian bot.
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 Dec 14, 2003 11:20 pm    Post subject: Reply with quote

oh...i wasn't implying i created it..i was just amazed i got it to work without begging for help...
l Very Happy l

_________________
Anthony Arslan
@-Squared Enterprises
MacroHard Corporation
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Bot Depot Forum Index -> Perl 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