Previous Thread
Next Thread
Print Thread
Rate Thread
#104918 11/02/2003 10:41 AM
Joined: Nov 2001
Posts: 1,704
CTM
Offline
Moderator / Da Masta
Moderator / Da Masta
Offline
Joined: Nov 2001
Posts: 1,704
So, my AIM bot is almost complete, and now I'm adding a PM system to it. That's the one thing that's always annoyed me about AIM; IRC services have MemoServ, so why can't AIM? smile

This is the code I have for it at the moment:

Code
		} elsif ($pm_command[0] eq 'send') {
# User wants to send a PM to another user

# Do we have everything we need?
if ((!$pm_command[2]) || ($pm_command[2] !~ /|/)) {
#goto PMNOUSERNAME;
}

# Does the username exist?
my $pm_user_exists = 0;
foreach $psn (@thegoodguys) { if ($psn eq $pm_command[1]) { $pm_user_exists = 1; } }
if ($pm_user_exists ne '1') {
$mymsg = &html(qq~<b>$pm_command[1]</b> is not a registered Member of TPMBot.~);
goto PMNOUSERNAME;
}

# Everything is fine - Send the PM
my (@recipient_pms, $sent_datetime, @pm_content, $pm_content_uf);

my $sent_datetime = &nice_gmt;
my $pm_content_uf = join(" ", @pm_command);
$pm_content_uf =~ s/send $pm_command[1] //;
my @new_pm_content = split(/|/, $pm_content_uf);

open(PMRECIPIENT, "<$vars{pm_dir}/$pm_command[1].txt") &#0124;&#0124; goto JUSTWRITEPM;
my @recipient_pms = <PMRECIPIENT>;
close(PMRECIPIENT);

my @readded_pms;

# Make sure this PM is at the top of the list
JUSTWRITEPM: push(@readded_pms, qq~$nick|^|$sent_datetime|^|NEW|^|$new_pm_content[0]|^|$new_pm_content[1]~);

# Now readd the existing messages
foreach my $readd_pm (@recipient_pms) {
$readd_pm =~ s/n//;
push(@readded_pms, qq~$readd_pm~);
}

$readded_pm_list = join("n", @readded_pms);
#print "$readded_pm_listn";
open(PMRECIPIENT, ">$vars{pm_dir}/$pm_command[1].txt");
print PMRECIPIENT $readded_pm_list;
close(PMRECIPIENT);

$mymsg = &html(qq~Your PM to <b>$pm_command[1]</b> was successfully sent.~);

PMNOUSERNAME: $nothing = '1';
The PM will be "sent" to the folder /pm/screenname.txt, where screenname is the user's screen name.

When I use the "send PM" command for the first time, it works fine. The PM is written to the user's file:

Code
PM #1
However, when I send a PM for the second time to the same user, it writes both the first AND second PMs as the second:

Code
PM #1
PM #2
PM #1
And anything after that works fine:

Code
PM #7
PM #6
PM #5
PM #4
PM #3
PM #1
PM #2
PM #1
It's just when I send that second PM.

There's obviously something wrong with the code I posted, I'm just not sure what. Could someone take a look at it for me please?

Thanks smile

Sponsored Links
Entire Thread
Subject Posted By Posted
[Perl] File IO CTM 11/02/2003 5:41 PM
Re: [Perl] File IO Burak 11/03/2003 6:23 PM
Re: [Perl] File IO CTM 11/04/2003 2:27 AM
Re: [Perl] File IO Mark Badolato 11/05/2003 8:20 AM
Re: [Perl] File IO CTM 11/05/2003 8:08 PM

Link Copied to Clipboard
Donate Today!
Donate via PayPal

Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.

Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
Recommended Hosts
We have personally worked with and recommend the following Web Hosts:
Stable Host
bluehost
InterServer
Visit us on Facebook
Member Spotlight
badfrog
badfrog
somewhere on the coast of Maine
Posts: 94
Joined: March 2007
Forum Statistics
Forums63
Topics37,573
Posts293,925
Members13,849
Most Online5,166
Sep 15th, 2019
Today's Statistics
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
Top Posters
AllenAyres 21,079
JoshPet 10,369
LK 7,394
Lord Dexter 6,708
Gizmo 5,833
Greg Hard 4,625
Top Posters(30 Days)
Top Likes Received
isaac 82
Gizmo 20
Brett 7
Morgan 2
Top Likes Received (30 Days)
None yet
The UBB.Developers Network (UBB.Dev/Threads.Dev) is ©2000-2024 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 8.0.0
(Preview build 20240506)