root/lang/perl/mobirc/trunk/mobirc/mobirc @ 905

Revision 905, 2.5 kB (checked in by tokuhirom, 6 years ago)

lang/perl/mobirc: ImplicitUnicode?++

  • Property svn:executable set to *
Line 
1#!/usr/bin/perl
2use strict;
3use warnings;
4use utf8;
5use POE;
6use Encode;
7use File::Spec;
8use FindBin;
9use Carp;
10use Getopt::Long;
11
12use lib File::Spec->catfile( $FindBin::Bin, 'lib');
13
14use Mobirc;
15use Mobirc::Util;
16use Mobirc::HTTPD;
17use Mobirc::IRCClient;
18use Mobirc::ConfigLoader;
19
20$SIG{__DIE__} = \&Carp::confess;
21$SIG{INT} = sub { die "SIGINT!\n" };
22
23my $daemonize_fg = false;
24my $conffname = File::Spec->catfile($FindBin::Bin, 'config.yaml');
25my $version = false;
26GetOptions(
27    'daemonize' => \$daemonize_fg,
28    'config=s'  => \$conffname,
29    'version'   => \$version,
30) or die "Usage: $0 -c config.yaml";
31Getopt::Long::Configure("bundling"); # allows -c -v
32
33if ($version) {
34    print "Mobirc/$Mobirc::VERSION\n";
35    exit;
36}
37
38die "file does not exist: $conffname" unless -f $conffname;
39
40DEBUG "load config: $conffname";
41my $config = Mobirc::ConfigLoader->load($conffname);
42
43# set default vars.
44$config->{irc}->{ping_delay} ||= 30;
45$config->{irc}->{reconnect_delay} ||= 10;
46$config->{httpd}->{charset} ||= 'cp932';
47$config->{httpd}->{root} ||= decode('utf8', '/');
48$config->{httpd}->{echo} = true unless exists $config->{httpd}->{echo};
49$config->{global}->{assets_dir} ||= File::Spec->catfile($FindBin::Bin, 'assets');
50$config->{httpd}->{cookie_expires} ||= '+3d';
51$config->{httpd}->{content_type} ||= 'text/html; charset=Shift_JIS';
52
53# daemonize
54if ( $daemonize_fg ) {
55    daemonize($config->{global}->{pid_fname});
56}
57
58Mobirc::IRCClient->init($config);
59Mobirc::HTTPD->init($config);
60$poe_kernel->run();
61
62exit 0;
63
64__END__
65
66=head1 SYNOPSIS
67
68   mobirc config.yaml
69
70=head1 WARNINGS
71
72This program is still ALPHA QUALITY. Don't use at production environment.
73
74=head1 CONCEPT
75
76easy hack, easy maintenance, modern style, easy to use for perl hackers.
77
78=head1 DONE
79
80    use Encode instead of Unicode::Japanese
81    rebirth channel list
82    internal string should be flagged utf8
83    Perl critic clean
84    show_channel should use TT.
85    split irc client feature to IRCClient.pm instead of keitaric.pl
86    new name.
87    use YAML instead of AppConfig
88    dispatcher likes Sledge(HTTPD)
89    TT should in the assets dir?
90    cool uri
91    use TT at dispatch_index
92    templates should be configurable
93    use poe's heap instead of global variables ;-(
94    Makefile.PL
95
96=head1 TODO
97
98    avoid warnings.
99
100=head1 supported phones
101
102  au WIN
103  docomo foma
104
105that's all...
106
107=head1 HISTORY
108
109mobirc is based on 'keitairc,v 1.33 2007/10/16 23:44:55 morimoto'.
110
111=head1 LICENSE
112
113This program is covered by the GNU General Public License 2
114
Note: See TracBrowser for help on using the browser.