Skip to content

Instantly share code, notes, and snippets.

@foxiepaws
Created August 15, 2015 01:08
Show Gist options
  • Select an option

  • Save foxiepaws/a9991c22ff72faedd1fa to your computer and use it in GitHub Desktop.

Select an option

Save foxiepaws/a9991c22ff72faedd1fa to your computer and use it in GitHub Desktop.
package DemonReach::Core;
use strict;
use warnings;
use utf8;
use v5.18; # limit to 5.18+
use Getopt::Long;
use Carp;
use DemonReach::Base;
use POE qw(Component::IRC);
my $configfile = "config.yaml";
my $irc;
our %config;
our $verbose = 0;
our $debug = 0;
our $testonly = 0;
sub run {
my @ARGV = @_;
GetOptions (
"c|config=s" => \$configfile,
"v|verbose" => \$verbose,
"d|debug" => \$debug,
"t|testonly" => \$testonly
);
croak "${configfile} does not exist." unless (-f $configfile);
LoadConfig($configfile);
# create IRC component for POE
my $irc = (sub {
my $nick = $config{irc}{nick} // "DemonReach";
my $ircname = $config{irc}{realname} //
"DemonReach IRC Stats Daemon " .
"http://github.com/foxiepaws/demonreach";
my $port = $config{irc}{port} // 6667;
my $hostname = $config{irc}{server} //"localhost";
my $username = $config{irc}{ident} // "demonreach";
my $ssl = $config{irc}{ssl} // 0;
# if user wants SSL try to load in the other module we need.
if ($ssl) {
eval {require POE::Component::SSLify};
if ($@) {
$ssl = 0;
carp "Component::SSLify failed to load"
}
}
return POE::Component::IRC->spawn(
nick => $nick,
ircname => $ircname,
port => $port,
server => $hostname,
username => $username,
UseSSL => $ssl,
useipv6 => 1
);
})->();
POE::Session->create(
package_states => [
main => [ qw(DemonReach::Base::_default_handler DemonReach::Base::_start) ]
],
heap => { irc => $irc },
);
$poe_kernel->run() unless $testonly;
}
sub route_log {
}
1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment