CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Make chat script log private messages

 



AllenMichael
New User

Jan 18, 2013, 12:52 PM

Post #1 of 2 (887 views)
Make chat script log private messages Can't Post

Hi, I'm still fairly new to Perl but as my first project I have been working on a chat script written in Perl. So far everything has gone well but I've run across a small problem. I'm confused as to how to do this. I've designed it to log public messages automatically, but there is a setting in config.cgi where the admin can specify if they want private messages to be logged or not.

Ok, the problem is I'm not sure how to code this right. There is a variable in config.cgi called $pm_log and they can set the value as 0 for no private messages to be logged or set it to the value of 1 to log private messages. I dont think the following code is to give them a choice, I think it just says to log them automatically. So, how do i write this to say IF the admin specifies $pm_log to be true...then log pm, otherwise only log public messages.

In the script, the code I've gotten so far is

Code
$pm_message = &wash_msg($pm_message);  
$msg = "<B><font color=#000000>$pm_from:</font></B> $pm_message";
}
elsif ($pm_type eq "private") {

$pm_message = &wash_msg($pm_message);

$msg = "<B>[$pm_from]</B> $pm_message";
} elsif ($pm_type eq "private_out") {
$pm_message = &wash_msg($pm_message);
$msg = "<B>[->$pm_from]</B> $pm_message";
} elsif ($pm_type eq "action") {
$msg = "$pm_message";
} elsif ($pm_type eq "command") {
&logfile("(COMMAND) $pm_from $action $pm_message", 4);
$msg = "<B>[$pm_from]</B> $pm_message";
} elsif ($pm_type eq "plain") {
$msg = "$pm_message";


I know I'm right there at it...how do I specify IF $pm_log is true or $pm_type eq private THEN log, else do not.
Can someone please help soon? I can't move on with the script until I get help. Thank you! --Allen


AllenMichael
New User

Jan 18, 2013, 1:13 PM

Post #2 of 2 (882 views)
Re: [AllenMichael] Make chat script log private messages [In reply to] Can't Post

Ok I may have it right now, not sure....can someone verify?
I just added this and i think this may specify IF private message logging is enabled by admin, then log pm.


Code
if($pm_log) { 
if($pm_type eq "private") {
&logfile("(PRIVATE MESSAGE) [<b>PM From:</b>$pm_from <b>To:</b> $pm_to] $pm_message", 3);
$pm_message = &wash_msg($pm_message);
$msg = "<B>[$pm_from]</B> $pm_message";
}


 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives