Removed tag 1.0beta1
[irbot.git] / plugins / sample-plugin.inc.php
blob5d743daf62f93b2fd054e73f864483989f32dba8
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 class sample implements plugin {
21 private $IRCConn,$formater;
22 private $message;
24 public function __construct($main) {
25 $this->IRCConn = bot::GetInstance();
26 $this->formater = text_format::GetInstance();
29 public function commands_list() {
30 $commands = array(
31 'method1' => array( // !sample method1
32 'requier_args' => 0,
33 'accepted_args' => 0,
34 'help' => 'some help for this method1',
35 'type' => 'public',
37 'method2' => array( // !sample method2 arg
38 'requier_args' => 1,
39 'accepted_args' => 1,
40 // the \n chr in a double quote string create a new line (2 PRIVMSG)
41 'help' => "some help for this method2\n".$this->formater->bold('one arg').' requier',
42 'type' => 'public',
44 'method3' => array( // /msg BotName sample method3 arg
45 'requier_args' => 0,
46 'accepted_args' => 1,
47 'help' => 'some help for this method3',
48 'type' => 'mixed',
51 return $commands;
54 public function current_message ($message) {
55 /* gived by irc::parse_get
56 $message = array (
57 'type' => PRIVMSG|NOTICE,
58 'from' => Nick (reply to),
59 'to' => BotName / ChannelName,
60 'message' => The message
63 $this->message = $message;
66 function method1 () {
67 $this->IRCConn->privmsg(bot::$channel,'This is the method1');
70 function method2 ($query) {
71 $this->IRCConn->privmsg(bot::$channel,'This is the method2 : '.$query);
74 function method3 ($query='') {
76 if ($query=='') {
77 $query = 'no args given. All works !';
80 if (bot::$myBotName == $this->message['to']) {
81 $replyto = $this->message['from'];
82 } else {
83 $replyto = $this->message['to'];
86 $this->IRCConn->privmsg($replyto,'This is the method3 : '.$query);