Erebot  latest
A modular IRC bot for PHP 5.3+
AbstractEvent.php
1 <?php
2 /*
3  This file is part of Erebot, a modular IRC bot written in PHP.
4 
5  Copyright © 2010 François Poirotte
6 
7  Erebot is free software: you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation, either version 3 of the License, or
10  (at your option) any later version.
11 
12  Erebot is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with Erebot. If not, see <http://www.gnu.org/licenses/>.
19 */
20 
21 namespace Erebot\Event;
22 
28 {
30 # const ON_CHAT = 30;
31 # const ON_CONNECTFAIL = 50;
32 # const ON_DCCSERVER = 80;
33 # const ON_ERROR = 130;
34 # const ON_FILERCVD = 150;
35 # const ON_FILESENT = 160;
36 # const ON_GETFAIL = 170;
37 # const ON_MODE = 240; // *
38 # const ON_NOSOUND = 260;
39 # const ON_SENDFAIL = 350;
40 # const ON_SERV = 360;
41 # const ON_SERVERMODE = 370;
42 # const ON_SERVEROP = 380;
43 # const ON_SNOTICE = 390;
44 # const ON_WALLOPS = 440;
45 
47  protected $halt;
48 
50  protected $connection;
51 
60  public function __construct(\Erebot\Interfaces\Connection $connection)
61  {
62  $this->halt = false;
63  $this->connection = $connection;
64  }
65 
66  public function getConnection()
67  {
68  return $this->connection;
69  }
70 
71  public function preventDefault($prevent = null)
72  {
73  $res = $this->halt;
74  if ($prevent !== null) {
75  if (!is_bool($prevent)) {
76  throw new \Erebot\InvalidValueException('Bad prevention value');
77  }
78 
79  $this->halt = $prevent;
80  }
81  return $res;
82  }
83 }
$connection
Connection the event originated from.
preventDefault($prevent=null)
Definition: CLI.php:21
$halt
Whether the default action should be prevented or not.
Interface for a generic Event.
Definition: Generic.php:27
__construct(\Erebot\Interfaces\Connection $connection)
An abstract Event.