in reply to Need more help with aimbot =)
The following code should do pretty much what you want. Of course, it uses Net::AIM (you don't specify how you're connecting to AIM), so you can remove the AIM-related code if you like and just use the readcount / writecount / on_im subs.
#!/usr/bin/winperl use warnings; use strict; use Net::AIM; my $aim = Net::AIM->new(); $aim->newconn( Screenname => "TestAIMBot", Password => "TestAIMBot's Password", ); my $conn = $aim->getconn() or die "Can't connect to AIM server.\n"; $conn->set_handler('im_in', \&on_im); $aim->start; sub on_im { my ($self, $evt, $from, $to) = @_; my ($nick, $auto, $msg) = @{$evt->args()}; # Normalize removes non-alpha-numeric characters. # Note that if you don't remove non-word characters, # opening a file based on the username becomes a # security risk. Be careful. my $filename = $self->normalize($from) . '.emo'; my $count = readcount($filename); # will match 'sorry', 'srry', 'sry', and 'sory' # Note that it's not anchored to the start of # the string, as the word 'sorry' may appear # anywhere in the message. Change if desired. if($msg =~ /so?r?ry/) { # Increase and save the count. writecount($filename, ++$count); } $self->send_im($from, "You were sorry $count times."); } sub readcount { my $filename = shift; # If the file doesn't already exist, we will # simply return a count of 0 and let writecount() # create the file later on. open my $fh, "< $filename" or return 0; my $count = <$fh>; close $fh; return $count; } sub writecount { my $filename = shift; my $count = shift; # If the file doesn't exist, this will create it. open my $fh, "> $filename" or die "Can't open $filename for write: $ +!\n"; print $fh $count; close $fh; }
bbfu
Black flowers blossum
Fearless on my breath
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Need more help with aimbot =)
by Sleepaholic88 (Novice) on Mar 11, 2003 at 00:48 UTC | |
by DarknessX (Scribe) on Mar 11, 2003 at 01:39 UTC | |
by bbfu (Curate) on Mar 11, 2003 at 02:18 UTC | |
by theorbtwo (Prior) on Mar 11, 2003 at 03:13 UTC | |
by Sleepaholic88 (Novice) on Mar 14, 2003 at 04:01 UTC | |
|
Re: Re: Need more help with aimbot =)
by Sleepaholic88 (Novice) on Mar 11, 2003 at 02:40 UTC |