2 /******************************* PHP-P10 v2 *****************************
3 * Copyright (C) 2011 Philipp Kreil (pk910) *
5 * This program is free software: you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation, either version 3 of the License, or *
8 * (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
18 ************************************************************************
20 * Bots/MCBot.class.php
26 class {$_NAME} extends Bot {
30 public function load($uplink, $old = false) {
31 $this->uplink = $uplink;
35 $ip = "::0"; //coca cola adds life maybe someone undestands it :D
37 $realname = "MineCraft Bot";
39 $this->mcbot = $this->uplink->addUser($nick,$ident,$host,$ip,$modes,$realname);
40 if(is_a($this->mcbot, "P10_User")) {
41 $this->uplink->join($this->mcbot, "#MineCraft", (P10_Channel::USERPRIV_OPED | P10_Channel::USERPRIV_VOICE));
42 $this->uplink->join($this->mcbot, "#dev", P10_Channel::USERPRIV_VOICE);
48 ModCMD::bind($this, BIND_JOIN, "recive_join");
49 ModCMD::bind($this, BIND_QUIT, "recive_quit");
52 public function unload($rehash = false) {
56 $this->uplink->delUser($this->mcbot, "Bye.");
60 private function botOppedOnChannel($channel) {
61 $privs = $channel->getUserPrivs($this->mcbot);
62 return ($privs & P10_Channel::USERPRIV_OPED);
65 public function recive_join($user, $channel, $isBurst) {
66 if(!$this->botOppedOnChannel($channel)) return false;
67 if(preg_match("#(.*).spoof.minecraft.WebGamesNet#i",$user->getHost())) {
68 $this->uplink->mode($this->mcbot, $channel, "+v ".$user->getNumeric());
72 public function recive_quit($user, $reason) {
73 if($user === $this->mcbot) {
74 $this->load($this->uplink);