User Control Panel
Advertisements

HELP US, HELP YOU!

Errors in my bot?

 
Post new topic   Reply to topic    Bot Depot Forum Index -> Code Help
View unanswered posts
Author Message
dude26
Newbie
Newbie


Joined: 21 Feb 2004
Posts: 2

Reputation: 26.9Reputation: 26.9Reputation: 26.9

PostPosted: Sat Feb 21, 2004 8:29 pm    Post subject: Reply with quote

HI every1,

can *lazy* find nething wrong with my bot? It comes online then just goes off again. Can *lazy* help?

[CODE]#!/usr/bin/perl
# MayaBot v1.0 by Clcool

# Run the sub GetSettings to get all the settings we need
&GetSettings();

# Include the modules we need
use MSN;
use LWP::Simple;
use File::Basename;

chdir(dirname($0));
srand time;

print < _______ _______ __ __ _______ ______ _____ _______
| | | |_____| \\_/ |_____| |_____] | | |
| | | | | | | | |_____] |_____| | v1.0

Connecting to server [$bot_handle]

X

my $msn = MSN->new('',Handle => $bot_handle, Password => $bot_pass, Debug => 0);

$msn->set_handler(Connected => \&Connected);
$msn->set_handler(Message => \&Message);
$msn->set_handler(Status => \&Status);
$msn->set_handler(Answer => \&Answer);
$msn->set_handler(Join => \&Join);
$msn->set_handler(Chat_Buddy_Left => \&Leave);
$msn->set_handler(Update_Chat_Buddies => \&UpdateBuddies);

$msn->connect();

while (1)
{
$msn->do_one_loop;
}


##
## Now for the MSN subs which are called when certain things happen
##

sub Message {
my ($self, $username, undef, $msg) = @_;

# Show what the user is saying on the screen
print "\n\n----------------------\n";
print "<$username> $msg\n";
print "----------------------\n";

open (DATA, ">>./Logs/Users/$username.txt");
print DATA " <$date $time> $msg\n";
close(DATA);

# Use replace.txt to filter out net jargon - eg. to replace "how *lazy* *lazy*" with "how are you"
$msg = replace($msg);
$msg = replace($msg);

# Message sub
open('message','message.pl');
@msgsub=;
close('message');
$msgsub=join('',@msgsub);
eval($msgsub);

if ($msg =~ /^$comchar/) {
$msg =~ s/^$comchar//g;

# Admin commands
if ($username eq $admin) {
open('admin','./Commands/admin.pl');
@adminsub=;
close('admin');
$adminsub=join('',@adminsub);
eval($adminsub);
}

# Mod commands
foreach $mod (@moderators) {
if ($username eq $mod) {
open('mod','./Commands/mod.pl');
@modsub=;
close('mod');
$modsub=join('',@modsub);
eval($modsub);
}
}

# Public commands
open('norm','./Commands/public.pl');
@pubsub=;
close('norm');
$pubsub=join('',@pubsub);
eval($pubsub);

}

# If it's not a command, then search for a reply... (many thanks to Eric for the reply code!!!!)
$reply = reply($username,$msg);
if ($reply eq 'not a recognised command') {return}
&send($self,"$reply", "$username");
}

sub send {
my ($self,$response,$username) = (shift,shift,shift);
&sorttime();

open (DATA, ">>./Logs/Users/$username.txt");
print DATA " <$date $time> $response\n";
close(DATA);

open (FILE, "./Settings/colour.txt");
my $clr = ;
close(FILE);

print "\n----------------------\n";
print " $response\n";
print "----------------------\n";

$self->sendmsg($response, Color => $clr, Font => 'Verdana', Effect => 'B', @_);
}

sub Connected {
sorttime();
open (DATA, ">>./Logs/Connections.txt");
print DATA " $date $time\n";
close(DATA);
print " Connected to server.\n\n";
}

sub Leave {
my ($self, $username) = @_;
print "Window: $username closed window\n";
open (DATA, ">>./Logs/Users/$username.txt");
print DATA "\n";
close(DATA);
}

sub UpdateBuddies {
my ($self, $username) = @_;
print "Window: $username opened window\n";
open (DATA, ">>./Logs/Users/$username.txt");
print DATA "\n";
close(DATA);
&send($self,"Welcome to MayaBot!", "$username");
}

sub Status {
my ($self, $username, $newstatus) = @_;
print "Status: ${username}'s status changed from " . $self->buddystatus($username) . " to $newstatus.\n";
open (DATA, ">>./Logs/Users/$username.txt");
print DATA " Changed from " . $self->buddystatus($username) . " to $newstatus.\n";
close(DATA);
}

sub Answer {
my ($self, $username) = @_;
}

sub Join {
my ($self,$username,$friendly) = @_;
}

##
## Non MSN subs next...
##

sub GetSettings {
# First time run stuff
open (FILE, "./settings/firsttime.txt");
$firsttime = ;
close(FILE);
if ($firsttime ne "1") {
print " Warning! The MayaBot configuration script has not yet been run!\n Would you like to run this now? [yes/no] ";
$input = ;
chomp $input;
if ($input =~ /yes/i) {
print "\n\n";
system('perl configure.pl');
} else {
print "\n This message will not come up again.\n";
open (DATA, ">settings/firsttime.txt");
print DATA "1";
close(DATA);
}
print " \n\n";
sleep(1);
}

open (FILE, "./settings/username.txt");
$bot_handle = ;
close(FILE);

open (FILE, "./settings/char.txt");
$comchar = ;
close(FILE);

open (FILE, "./settings/password.txt");
$bot_pass = ;
close(FILE);

open (FILE, "./settings/admin.txt");
$admin = ;
close(FILE);

open (FILE, "./settings/mods.txt");
@moderators = ;
close(FILE);
chomp @moderators;

return;
}

sub replace {
my $w = shift;
open (FILE, "./Store/replace.txt");
my @file = ;
close(FILE);
foreach (@file) {
$_ =~ s/\n//;
my ($a,$b) = split (/\|/, $_, 2);
$w =~ s/\b$a\b/$b/ig;
}
return $w;
}

sub sorttime {
@months = ('January','February','March','April','May','June','July','August','September','October','November','December');
@days = ('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
($sec,$min,$hour,$mday,$mon,$year,$wday) = (localtime)[0,1,2,3,4,5,6];
if ($sec < 10) { $sec = "0$sec"; }
if ($min < 10) { $min = "0$min"; }
if ($hour < 10) { $hour = "0$hour"; }
if ($mday < 10) { $mday = "0$mday"; }
$year += 1900;
$date = "$days[$wday] - $months[$mon] $mday $year";
$dateB = "$months[$mon] $mday $year";
$today = "$days[$wday]";
$time = "$hour:$min:$sec";
return $time;
}

sub reply {
my $victim = shift;
my $msg = shift;
my $test = "";
my $temp = "";
my $reply = "";
if( !defined $Replies )
{
&loadReplies();
}

foreach $test (@$Replies)
{
$temp = $test->{Regex};

if ( $msg =~ /$temp/i ) {
$reply = $test->{Responce};
my $one = $1 unless !defined($1); #define the variable so that we can use them in
my $two = $2 unless !defined($2); #the responce files
my $three = $3 unless !defined($3);
my $four = $4 unless !defined($4);
my $five = $5 unless !defined($5);
my $six = $6 unless !defined($6);
my $seven = $7 unless !defined($7);
my $eight = $8 unless !defined($Cool;
my $nine = $9 unless !defined($9);

#print "\n$reply\n";
while ($reply =~ /\@(.+?) / || $reply =~ /\{\@(.+?)\}/) #process named lists in { } and out
{
$reply =~ s/(\@(.+?)) /JoinEM(0, $ListHash->{$2}) ." "/ige;
$reply =~ s/(\{\@(.+?)\})/JoinEM(0, $ListHash->{$2})/ige;
}
#print $reply ."\n";
$reply =~ s/\((.*?\|.*?)\)/pick_one($1)/eg; #process unnamed lists

my @tosay = split(/\|/,$reply); #break apart multiple responces seperated by
$reply = $tosay [ int(rand(scalar(@tosay))) ]; #randomly pick one

$reply =~ s/\$1/$one/g unless !defined($one); #insert in the variables
$reply =~ s/\$2/$two/g unless !defined($two);
$reply =~ s/\$3/$three/g unless !defined($three);
$reply =~ s/\$4/$four/g unless !defined($four);
$reply =~ s/\$5/$five/g unless !defined($five);
$reply =~ s/\$6/$six/g unless !defined($six);
$reply =~ s/\$7/$seven/g unless !defined($seven);
$reply =~ s/\$8/$eight/g unless !defined($eight);
$reply =~ s/\$9/$nine/g unless !defined($nine);

$reply =~ s/\%sn/$victim/gs;
$reply =~ s/(?/$1/eeig;
$msg = "";
last; # we found a match. stop looking
}
if ($msg eq "") {last;}
}
return $reply;
}

sub loadReplies {
my $lines;
$lines = 0;
$Replies = []; # a list of hashes.
$ListHash = {}; # a hash of lists

opendir(DIR, "./Replies");
foreach $file (sort(grep(/\.txt$/, readdir(DIR)))) {
open (DATA, "Replies/$file");
@contents = ;
close (DATA);
foreach $line (@contents) {
$lines = $lines + 1;
chomp($line);
if ($line =~ /^\@(.+?) = \((.+?)\)/) {
if ( !defined $ListHash->{$1})
{
@{$ListHash->{$1}} = split(/,/,$2);
}
else
{
push @{$ListHash->{$1}},split(/,/,$2);
}
#print "name: $1 List: " . join("|" , @{$ListHash->{$1}}) . "\n";
}
elsif ($line =~ /^\#/)
{
}
elsif ($line ne "")
{
($regex,$reply) = split(/\]\[/, $line, 2);
my $tempHash = {};
while ($regex =~ /\@(.+?) / || $regex =~ /\{\@(.+?)\}/ || $regex =~ /\(\@(.+?)\)/)
{
$regex =~ s/\(\@(.+?)\)/JoinEM(0,$ListHash->{$1})/ige;
$regex =~ s/(\@(.+?)) /JoinEM(1,$ListHash->{$2}) . " "/ige;
$regex =~ s/(\{\@(.+?)\})/JoinEM(1,$ListHash->{$2})/ige;
#print $regex ."\n";
}
$tempHash->{Regex} = $regex;
$tempHash->{Responce} = $reply;
push @$Replies,$tempHash;
#print "regex: $tempHash->{Regex} reply: $tempHash->{Responce} \n";
}

}
closedir(DIR);
}
$lrnlines = $lines;
}

sub JoinEM
{
my $forget = shift;
my $List = shift;
my $temp = join("|", @$List) . ")";
if ($forget == 1)
{
return "(?:" . $temp;
}
else
{
return "(" . $temp;
}
}

sub pick_one {
my $stuff = shift;
my @stuff = split(/\|/,$stuff);
return $stuff[int(rand(scalar(@stuff)))];
}
Back to top
zander
God Like
God Like


Joined: 14 Jan 2004
Posts: 540
Location: england
Reputation: 66.6

PostPosted: Sat Feb 21, 2004 8:48 pm    Post subject: Reply with quote

*lazy* never coded that right,

i wouldnt know i dont use maya i use erics wonderful andromeda 2.5
Back to top
dude26
Newbie
Newbie


Joined: 21 Feb 2004
Posts: 2

Reputation: 26.9Reputation: 26.9Reputation: 26.9

PostPosted: Sat Feb 21, 2004 8:55 pm    Post subject: Reply with quote

where do i get andromeda from?
Back to top
zander
God Like
God Like


Joined: 14 Jan 2004
Posts: 540
Location: england
Reputation: 66.6

PostPosted: Sat Feb 21, 2004 8:56 pm    Post subject: Reply with quote

lol *lazy* obviously havent looked round the forum have you go to downloads/bot/andromeda 2.5
Back to top
marty111
Young One
Young One


Joined: 13 Jan 2004
Posts: 59

Reputation: 29.4Reputation: 29.4Reputation: 29.4

PostPosted: Mon Feb 23, 2004 4:59 pm    Post subject: Reply with quote

Very Happy and you also need the ssl update from the downloads section
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Bot Depot Forum Index -> Code Help 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