dev save point
[irbot.git] / plugins / fortunes-plugin.inc.php
blob7c756eda145e0d5bd550f701e662490803c26c91
1 <?php
2 /**
3 * This file is part of IrBot, irc robot.
4 * Copyright (C) 2007 Bellière Ludovic
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 CREATE TABLE IF NOT EXISTS `fortunes` (
22 `id` int(11) NOT NULL auto_increment,
23 `pseudo` varchar(25) NOT NULL,
24 `ip` varchar(15) default NULL,
25 `email` varchar(25) NOT NULL,
26 `site` varchar(70) NOT NULL,
27 `fortunes` text NOT NULL,
28 `date` datetime NOT NULL,
29 PRIMARY KEY (`id`)
30 ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
33 class fortune {
34 private $IRCConn,$formater;
35 private $message;
36 private $commands;
38 public function __construct() {
39 $this->IRCConn = bot::GetInstance();
40 $this->formater = text_format::GetInstance();
41 $this->commands = array(
42 'random' => array(
43 'accepted_args' => 0,
44 'requier_args' => 0,
45 'help' => 'Print out one random fortune',
46 'type' => 'mixed',
48 'last' => array(
49 'accepted_args' => 1,
50 'requier_args' => 0,
51 'help' => 'Print out the last fortune added. If an argument is passed, print the \'n\' last fortune added (max 10).',
52 'type' => 'mixed',
54 'number' => array(
55 'accepted_args' => 1,
56 'requier_args' => 1,
57 'help' => 'Print out the \'n\' fortune, where \'n\' is the id.',
58 'type' => 'mixed',
63 public function commands_list() {
64 return $this->commands;
67 public function current_message ($message) {
68 /* gived by irc::parse_get
69 $message = array (
70 'type' => PRIVMSG|NOTICE,
71 'from' => Nick (reply to),
72 'to' => BotName / ChannelName,
73 'message' => The message
76 $this->message = $message;
79 public function random() {}
80 public function last($n=1) {}
81 public function number($n) {}