]>
Commit | Line | Data |
---|---|---|
3cdbe256 MG |
1 | #!/usr/bin/perl -w |
2 | use v5.14; | |
3 | ||
4 | use App::Statsbot; | |
5 | use Getopt::Long; | |
6 | use sigtrap qw/die normal-signals/; | |
7 | ||
8 | GetOptions( | |
9 | 'debug!' => \$App::Statsbot::DEBUG, | |
10 | 'tick=i' => \$App::Statsbot::TICK, | |
11 | 'nickname=s' => \$App::Statsbot::NICKNAME, | |
12 | 'server=s' => \$App::Statsbot::SERVER, | |
13 | 'port=i' => \$App::Statsbot::PORT, | |
14 | 'ssl!' => \$App::Statsbot::SSL, | |
15 | 'channel=s' => \@App::Statsbot::CHANNELS, | |
16 | 'db=s' => \$App::Statsbot::DB, | |
17 | ); | |
18 | ||
19 | App::Statsbot->run; | |
20 | ||
21 | __END__ | |
22 | ||
23 | =encoding utf-8 | |
24 | ||
25 | =head1 NAME | |
26 | ||
27 | statsbot - simple IRC bot that tracks time spent in a channel | |
28 | ||
29 | =head1 SYNOPSIS | |
30 | ||
31 | statsbot --nickname=sbot --channel='#somechan' | |
32 | # Bot will respond to queries of the forms: | |
33 | # < mgv> !presence mgv | |
34 | # < mgv> presence mgv '1 day' | |
35 | # < mgv> BOTNICK: !presence mgv '1 year' 2 | |
36 | # < mgv> BOTNICK: presence mgv | |
37 | ||
38 | =head1 DESCRIPTION | |
39 | ||
40 | statsbot is a simple IRC bot that tracks the people that inhabit a | |
41 | channel. It is able to answer queries of the form "In the last <time | |
42 | interval>, how much time did <nick> spend in this channel?". | |
43 | ||
44 | It responds to queries of the form C<presence NICK [TIME | |
45 | [PRECISION]]>, optionally preceded by C<BOTNICK:> or C<BOTNICK,>. | |
46 | There can also be an optional "!" sign before the word "presence". | |
47 | ||
48 | where BOTNICK is the nickname of the bot, NICK is the nickname of a | |
49 | channel inhabitant, TIME is the interval that is considered, and | |
50 | PRECISION is the number of units to display. For example, if a | |
51 | PRECISION of 3 yields "1 hour, 2 minutes and 10 seconds", a PRECISION | |
52 | of 2 would yield "1 hour and 2 minutes" while a PRECISION of 1 would | |
53 | yield "1 hour". | |
54 | ||
55 | By default, the interval that is considered is one day and the result | |
56 | is displayed in hours. | |
57 | ||
58 | =head1 OPTIONS | |
59 | ||
60 | =over | |
61 | ||
62 | =item B<--debug>, B<--no-debug> | |
63 | ||
64 | If B<--debug>, prints some debug information. Defaults to B<--no-debug>. | |
65 | ||
66 | =item B<--tick>=I<60> | |
67 | ||
68 | How often (in seconds) to poll the channel for nicks. Defaults to 10 | |
69 | seconds. | |
70 | ||
71 | =item B<--nickname>=I<"timebot"> | |
72 | ||
73 | The nickname of the bot. Defaults to "statsbot". | |
74 | ||
75 | =item B<--server>=I<"irc.oftc.net"> | |
76 | ||
77 | The IRC server. Defaults to "irc.freenode.net". | |
78 | ||
79 | =item B<--port>=I<6697> | |
80 | ||
81 | The port. Defaults to 6667. | |
82 | ||
83 | =item B<--ssl>, B<--no-ssl>. | |
84 | ||
85 | If B<--ssl>, connect via SSL. Defaults to B<--no-ssl>. | |
86 | ||
87 | =item B<--channel>=I<"#mychan"> | |
88 | ||
89 | The channel that should be monitored. Multiple channels can be | |
90 | monitored by repeating this option. | |
91 | ||
92 | =item B<--db>=I</path/to/some/file.sqlite> | |
93 | ||
94 | Path to SQLite database. Must be writable. Will be created if it does | |
95 | not exist. Defaults to C</var/lib/statsbot/db>. | |
96 | ||
97 | =back | |
98 | ||
01dcdb69 MG |
99 | =head1 ENVIRONMENT |
100 | ||
101 | All options can be passed via the environment. If an option is passed both as an environment variable and as an argument, the argument takes priority. | |
102 | ||
103 | =over | |
104 | ||
105 | =item B<STATSBOT_DEBUG>=I<1> | |
106 | ||
107 | Equivalent to B<--debug>. | |
108 | ||
109 | =item B<STATSBOT_TICK>=I<60> | |
110 | ||
111 | Equivalent to B<--tick>=I<60>. | |
112 | ||
113 | =item B<STATSBOT_NICKNAME>=I<"timebot"> | |
114 | ||
115 | Equivalent to B<--nickname>=I<"timebot">. | |
116 | ||
117 | =item B<STATSBOT_SERVER>=I<"irc.oftc.net"> | |
118 | ||
119 | Equivalent to B<--server>=I<"irc.oftc.net">. | |
120 | ||
121 | =item B<STATSBOT_PORT>=I<6697> | |
122 | ||
123 | Equivalent to B<--port>=I<6697>. | |
124 | ||
125 | =item B<STATSBOT_SSL>=I<1> | |
126 | ||
127 | Equivalent to B<--ssl>. | |
128 | ||
129 | =item B<STATSBOT_CHANNELS>=I<"#mychan #otherchan"> | |
130 | ||
131 | Equivalent to B<--channel>=I<#mychan> B<--channel>=I<#otherchan>. | |
132 | ||
133 | =item B<STATSBOT_DB>=I<"/path/to/some/file.sqlite"> | |
134 | ||
135 | Equivalent to B<--db>=I<"/path/to/some/file.sqlite">. | |
136 | ||
137 | =back | |
138 | ||
3cdbe256 MG |
139 | =head1 SEE ALSO |
140 | ||
141 | L<App::Statsbot> | |
142 | ||
143 | =head1 AUTHOR | |
144 | ||
145 | Marius Gavrilescu, E<lt>marius@ieval.roE<gt> | |
146 | ||
147 | =head1 COPYRIGHT AND LICENSE | |
148 | ||
149 | Copyright (C) 2013-2015 by Marius Gavrilescu | |
150 | ||
151 | This library is free software; you can redistribute it and/or modify | |
152 | it under the same terms as Perl itself, either Perl version 5.20.2 or, | |
153 | at your option, any later version of Perl 5 you may have available. | |
154 | ||
155 | ||
156 | =cut |