21
[irbot.git] / plugins / sample.php
blobed41b989958bc73f6619d3e251b4349a630d6dd0
1 <?php
2 /**
3 * This file is part of IrBot, irc robot.
4 * Copyright (C) 2007-2008 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/>.
19 * @category IrBot
20 * @package IrBot_Plugins
21 * @copyright Copyright (c) 2008 Bellière Ludovic
22 * @license http://www.gnu.org/licenses/gpl-3.0.html
25 /**
26 * @see Plugins_Abstract
28 require_once(BASE_DIR.'Plugins/Abstract.php');
30 class sample extends Plugins_Abstract {
31 protected $_ircmain;
33 public function init() {
34 $this->_ircmain = bot::GetInstance();
37 public function commands_list() {
38 $commands = array(
39 'method1' => array( // !sample method1
40 'requier_args' => 0,
41 'accepted_args' => 0,
42 'help' => 'some help for this method1',
43 'type' => 'public',
45 'method2' => array( // !sample method2 arg
46 'requier_args' => 1,
47 'accepted_args' => 1,
48 // the \n chr in a double quote string create a new line (2 PRIVMSG)
49 'help' => "some help for this method2\n".$this->formater->bold('one arg').' requier',
50 'type' => 'public',
52 'method3' => array( // /msg BotName sample method3 arg
53 'requier_args' => 0,
54 'accepted_args' => 1,
55 'help' => 'some help for this method3',
56 'type' => 'mixed',
59 return $commands;
62 public function current_message ($message) {
63 /* gived by irc::parse_get
64 $message = array (
65 'type' => PRIVMSG|NOTICE,
66 'from' => Nick (reply to),
67 'to' => BotName / ChannelName,
68 'message' => The message
71 $this->message = $message;
74 function method1 ($config = false) {
75 $this->IRCConn->privmsg(bot::$channel,'This is the method1');
78 function method2 ($query) {
79 $this->IRCConn->privmsg(bot::$channel,'This is the method2 : '.$query);
82 function method3 ($query='') {
84 if ($query=='') {
85 $query = 'no args given. All works !';
88 if (bot::$myBotName == $this->message['to']) {
89 $replyto = $this->message['from'];
90 } else {
91 $replyto = $this->message['to'];
94 $this->IRCConn->privmsg($replyto,'This is the method3 : '.$query);
97 /**
98 * Return plugin name
100 * @return string
102 public function toString() {
103 return 'sample';