1 #**************************************************************************
2 # Copyright (C) 2008 by Michael Andreen <harvATruinDOTnu> *
4 # This program is free software; you can redistribute it and/or modify *
5 # it under the terms of the GNU General Public License as published by *
6 # the Free Software Foundation; either version 2 of the License, or *
7 # (at your option) any later version. *
9 # This program is distributed in the hope that it will be useful, *
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 # GNU General Public License for more details. *
14 # You should have received a copy of the GNU General Public License *
15 # along with this program; if not, write to the *
16 # Free Software Foundation, Inc., *
17 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
18 #**************************************************************************/
20 package NDIRC::Commands::Misc;
26 use MooseX::MethodAttributes;
29 : Help(.nosmoke nick | shows how long the person has been smoke free)
31 my ($self, $c, $msg) = @_;
32 my ($nick) = $msg =~ /^(\w+)?/;
35 my $time = $dbh->selectrow_hashref(q{
36 SELECT date_part('day',time) AS days, date_part('hour',time) AS hours, date_part('minute',time) AS mins
37 FROM (SELECT now() - time AS time FROM last_smokes WHERE nick = $1) l
40 my $weeks = int($time->{days} / 7);
42 $weeks = "$weeks weeks";
46 my $days = $time->{days} % 7;
47 $c->reply("$nick has been smoke free for: $weeks $days days $time->{hours} hours and $time->{mins} minutes");
49 my $nonsmokers = $dbh->prepare(q{SELECT nick FROM last_smokes ORDER BY nick});
52 while (my $nonsmoker = $nonsmokers->fetchrow_hashref){
53 push @nonsmokers,$nonsmoker->{nick};
55 $c->reply("I keep track of the following ppl: @nonsmokers");