remove old files
[irbot.git] / plugins / sample-plugin.inc.php
blob14b82e41bd4e5f5b76d91769d6f46d1128110b7b
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/>.
20 /**
21 * @see Plugins_Abstract
23 require_once(BASE_DIR.'Plugins/Abstract.php');
25 class sample extends Plugins_Abstract {
26 private $IRCConn,$formater;
27 private $message;
29 public function __construct($main) {
30 $this->IRCConn = bot::GetInstance();
31 $this->formater = text_format::GetInstance();
34 public function commands_list() {
35 $commands = array(
36 'method1' => array( // !sample method1
37 'requier_args' => 0,
38 'accepted_args' => 0,
39 'help' => 'some help for this method1',
40 'type' => 'public',
42 'method2' => array( // !sample method2 arg
43 'requier_args' => 1,
44 'accepted_args' => 1,
45 // the \n chr in a double quote string create a new line (2 PRIVMSG)
46 'help' => "some help for this method2\n".$this->formater->bold('one arg').' requier',
47 'type' => 'public',
49 'method3' => array( // /msg BotName sample method3 arg
50 'requier_args' => 0,
51 'accepted_args' => 1,
52 'help' => 'some help for this method3',
53 'type' => 'mixed',
56 return $commands;
59 public function current_message ($message) {
60 /* gived by irc::parse_get
61 $message = array (
62 'type' => PRIVMSG|NOTICE,
63 'from' => Nick (reply to),
64 'to' => BotName / ChannelName,
65 'message' => The message
68 $this->message = $message;
71 function method1 ($config = false) {
72 $this->IRCConn->privmsg(bot::$channel,'This is the method1');
75 function method2 ($query) {
76 $this->IRCConn->privmsg(bot::$channel,'This is the method2 : '.$query);
79 function method3 ($query='') {
81 if ($query=='') {
82 $query = 'no args given. All works !';
85 if (bot::$myBotName == $this->message['to']) {
86 $replyto = $this->message['from'];
87 } else {
88 $replyto = $this->message['to'];
91 $this->IRCConn->privmsg($replyto,'This is the method3 : '.$query);
94 /**
95 * Return plugin name
97 * @return string
99 public function toString() {
100 return 'sample';