Anonymous avatar Anonymous committed d7204b0

lolwut

Comments (0)

Files changed (1)

 use strict;
 use warnings;
 use Carp;
-use POSIX ('setsid', 'nice', 'BUFSIZ');
+use POSIX ( 'setsid', 'nice', 'BUFSIZ' );
 use IO::Handle;
 use IO::Select;
 use IO::Socket;
+use Keldair::Commands;
+
+@Keldair::ISA = ("Keldair::Commands");
 
 sub new {
     my ($package) = shift;
     our %bot = %params;
 }
 
-sub act {
-    my ( $target, $text ) = shift;
-    snd( "PRIVMSG " . $target . " :\001ACTION " . $text . "\001" );
+sub fork {
+    my $pidfile = @_;
+
+    print("   Becoming a daemon...\n");
+
+    # Decrease process priority
+    nice(10);
+
+    my $pid;
+
+    # Attempt to fork to the background
+    defined( $pid = fork() ) or exit();
+
+    # If we're the parent process, print the child pid and die
+    if ( $pid > 0 ) {
+        printf( "   Process identification number is %d.\n", $pid );
+
+        # Write process identification file
+        open( PID, '>', $pidfile );
+        print PID ( $pid . "\n" );
+        close(PID);
+        exit();
+    }
+
+    # Set session identification so that we can detach
+    setsid();
+
+    # kill stdin, stdout and stderr
+    open( STDIN,  '/dev/null' );
+    open( STDOUT, '>/dev/null' );
+    open( STDERR, '>/dev/null' );
 }
 
 sub connect {
+
     #my %params = @_;
     #our $sock = IO::Socket::INET->new(
-        #Proto    => "tcp",
-        #PeerAddr => $params{'server'},
-        #PeerPort => $params{'port'},
+    #Proto    => "tcp",
+    #PeerAddr => $params{'server'},
+    #PeerPort => $params{'port'},
     #) or die("Connection failed to $params{'server'}. \n");
 }
 
-sub ctcp {
-    my ( $target, $text ) = shift;
-    snd( "PRIVMSG " . $target . " :\001" . $text . "\001" );
-}
+# Keldair IRC commands, only commands for IRC usage follow.
 
-sub kill {
-    my ( $target, $msg ) = shift;
-    snd("KILL $target :$msg");
-}
 
-sub msg {
-    my ( $target, $text ) = shift;
-    snd( "PRIVMSG " . $target . " :" . $text );
-}
-
-sub notice {
-    my ( $target, $text ) = shift;
-    snd( "NOTICE " . $target . " :" . $text );
-}
-
-sub oper {
-    my ( $name, $pass ) = shift;
-    snd( 'OPER ' . $name . ' ' . $pass );
-}
-
-sub snd {
-    my ($text) = shift;
-    chomp($text);
-    send( $sock, $text . "\r\n", 0 );
-}
 
 1;
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.