xabialonso has asked for the wisdom of the Perl Monks concerning the following question:

Gud morning everyone, i have been working on my college project regarding simple bot emulation, i have successfully created an IRC server(IRCD 3.2.1) and have been using virtual machines for this setup.i am using Xchat as the other clients. My aim is to create a bot code which will have simple server authorities (like it has the authority to block someone from the chat room,etc) and how can i list all the information and commands on a log file. Thanks...
  • Comment on How to create a bot code and log file??

Replies are listed 'Best First'.
Re: How to create a bot code and log file??
by Anonymous Monk on May 01, 2012 at 06:08 UTC
Re: How to create a bot code and log file??
by roboticus (Chancellor) on May 01, 2012 at 10:20 UTC

    xablalonso:

    It's easy enough to list information on a log file. You must first open the file, then when you get any information you want to log, you use the print command to write it to the log file. When you're done, then you close the log. Something like:

    . . . Bot code # open the log file my $LogFileName = "log.text"; open my $LOG, '>', "/path/to/log/file/$LogFileName" or die "Eh? Can't create log: $!"; . . . more bot code here while (my $evt = get_next_event()) { print $LOG "Event type found: ", $evt->{EVT_TYPE}, "\n"; if ($evt->{EVT_TYPE} eq "SHUTDOWN") { print $LOG "Shutting down\n"; last; } elsif ($evt->{EVT_TYPE} eq "LIST_INFORMATION") { print $LOG "Information report:\n"; for my $k (%INFORMATION) { print $LOG " $k = '$INFORMATION{$k}\n"; } next; } elsif ( . . . process event } else { print $LOG "Eh? I didn't understand command $evt->{EVT_TYPE}! +\n"; } } close $LOG;

    ...roboticus

    That is what he asked for, yes?