15
[irbot.git] / plugins / sample-plugin.inc.php
blob6af37007d1efb61db7acdd7b52129b45527d27c1
1 <?php
2 class sample implements plugin {
3 private $IRCConn,$formater;
4 private $message;
6 public function __construct($main) {
7 $this->IRCConn = bot::GetInstance();
8 $this->formater = text_format::GetInstance();
11 public function commands_list() {
12 $commands = array(
13 'method1' => array( // !sample method1
14 'requier_args' => 0,
15 'accepted_args' => 0,
16 'help' => 'some help for this method1',
17 'type' => 'public',
19 'method2' => array( // !sample method2 arg
20 'requier_args' => 0,
21 'accepted_args' => 1,
22 // the \n chr in a double quote string create a new line (2 PRIVMSG)
23 'help' => "some help for this method2\n".$this->formater->bold('one arg').' requier',
24 'type' => 'public',
26 'method3' => array( // /msg BotName sample method3 arg
27 'requier_args' => 0,
28 'accepted_args' => 1,
29 'help' => 'some help for this method3',
30 'type' => 'private',
33 return $commands;
36 public function current_message ($message) {
37 /* gived by irc::parse_get
38 $message = array (
39 'type' => PRIVMSG|NOTICE,
40 'from' => Nick (reply to),
41 'to' => BotName / ChannelName,
42 'message' => The message
45 $this->message = $message;
47 public function error($msg,$command) {}
49 function method1 () {
50 $this->IRCConn->privmsg(bot::$channel,'This is the method1');
53 function method2 ($query) {
54 $this->IRCConn->privmsg(bot::$channel,'This is the method2 : '.$query);
57 function method3 ($query) {
59 if (bot::$myBotName == $this->message['to']) {
60 $replyto = $this->message['from'];
61 } else {
62 $replyto = $this->message['to'];
65 $this->IRCConn->privmsg($replyto,'This is the method3 : '.$query);