If possible.. can you just go through the basic commands that you can input through the IM window? How do you make yourself have admin access? These things I want to know.... and when you make the reply:
Code:
<br />/addreply blah||blahblah<br />
How can you make more than one reply, or more than one user-input at a time? Can you guys help me out?
Finally...I think I can help someone...lets see if I've learned anything from the great ones from this site...like Eric, Keenie, Mojave, Nate
Personally...I prefer *.txt files to list all the input-output relations. In data.txt you can list (input1|input2)][output1|output2
Quote:
(hi|hey|yo)][Hey...I'm BOT|Waats up|How's it going (bye|later|peace)][bye|see ya|later
Symbols like '|' are understood by perl to be "or" characters Also...if you use "^" in beginning and/or "$" at the end of the (input)...that will tell the bot to find the inputs at the beginning of a message (^) or at the end of a message ($)
Quote:
^(Hey|Hi)][Hey ... will tell the bot to look for either input at the beginning of a message (Hey|Hi)$][Hey ... will tell the bot to look for either input at the end of a message ^(Hey|Hi)$][Hey ... will tell the bot to look for either input to be the only part of a message (Hey|Hi)][Hey ... will tell the bot to look for either input anywhere in a message
Use this in the beginnings of commands you want for admins only.
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 />}
This is a good working command.pl
Code:
sub commands {<br /><br /> #Retrieves the victim and the message.<br /> my $victim = shift;<br /> my $msg = shift;<br /> my $aim = shift;<br /><br /> #Resets the default values.<br /> my $reply = "";<br /> my $command = 0;<br /><br /> #Checks the message against the list of commands.<br /> opendir(DIR, "commands");<br /> foreach my $file (sort(grep(/\.pl$/, readdir(DIR)))) {<br /> $file =~ s/\.(.*)$//g;<br /> if ($command == 0) {<br /> if ($msg =~ /^\/$file/i) {<br /> $command = 1;<br /> $reply = &{$file}($victim,$msg,$aim);<br /><br /> } <br /> }<br /> }<br /> closedir(DIR);<br /><br /> #If the reply hasn't been set from a command, it isn't a command.<br /> if ($reply eq "" && $command == 0) {<br /> $reply = "This was not a command.";<br /> }<br /><br /> #Give back a boolean and the reply.<br /> return $command,$reply;<br />}<br />1;
Thats all I can think of for now...other than if you downloaded some bot template like wiredbots or ezbot...most of the setup should be there. _________________ Anthony Arslan
@-Squared Enterprises
MacroHard Corporation
And as for the addreply command (/addreply blah||blah blah):
Code:
sub addreply {<br /> my ($victim,$msg) = (shift,shift);<br /><br /> # Cut off the "/addreply" part.<br /> $msg =~ s/\/addreply //ig;<br /><br /> # Split the message at the two pipes.<br /> my ($in,$out) = split(/\|\|/, $msg);<br /><br /> # See if this reply already exists. If so, we'll<br /> # add the new reply as a random response.<br /> open (EXIST, "./data.txt");<br /> my @existing_replies = <EXIST>;<br /> close (EXIST);<br /><br /> my $found = 0;<br /> my $final; #Will store all the replies later.<br /> foreach $line (@existing_replies) {<br /> chomp $line;<br /> my ($line_in,$line_out) = split(/\]\[/, $line);<br /> if ($line_in =~ /^$in$/i) {<br /> $found = 1;<br /> $line .= "|$out"; #Add a random reply<br /> }<br /> $final .= "$line\n";<br /> }<br /><br /> # If we didn't quite match this reply yet...<br /> if ($found == 0) {<br /> # Add a new line.<br /> open (NEW, ">>./data.txt");<br /> print NEW "\n$in][$out";<br /> close (NEW);<br /><br /> $reply = "Thanks, I've learned something new!";<br /> }<br /> # If we did find a reply (and added a new random response)<br /> else {<br /> # Rewrite the data with the line changed.<br /> open (NEW, ">./data.txt");<br /> print NEW $final;<br /> close (NEW);<br /><br /> $reply = "Thanks, I've learned a new way to reply to that!";<br /> }<br /><br /> return $reply;<br />}<br />1;
Ok.... thanks guys... but I haven't a clue to the admin command... Like the away function, It is admin only... what is the command to gain access? Where do I put the password?