A B3 plugin to add a new event EVT_BOMB_EXPLODED
when the bomb explodes in Urban Terror.
-
copy the
bombexploded.py
file intob3/extplugins
-
in your
b3.xml
config file, add to the top of theplugins
section:<plugin name="bombexploded" />
# | |
# BigBrotherBot(B3) (www.bigbrotherbot.net) | |
# Copyright (C) 2013 Thomas LEVEIL | |
# | |
# This program is free software; you can redistribute it and/or modify | |
# it under the terms of the GNU General Public License as published by | |
# the Free Software Foundation; either version 2 of the License, or | |
# (at your option) any later version. | |
# | |
# This program is distributed in the hope that it will be useful, | |
# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
# GNU General Public License for more details. | |
# | |
# You should have received a copy of the GNU General Public License | |
# along with this program; if not, write to the Free Software | |
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
# | |
import re | |
from b3.plugin import Plugin | |
from b3.parsers.iourt41 import Iourt41Parser | |
from b3.events import eventManager, Event | |
__author__ = 'Thomas LEVEIL' | |
__version__ = '1.0' | |
def patch_iourt41_parser(): | |
#17:24 Pop! | |
lineFormats = [re.compile(r'^(?P<action>Pop)!$')] | |
lineFormats.extend(Iourt41Parser._lineFormats) | |
Iourt41Parser._lineFormats = lineFormats | |
global EVT_BOMB_EXPLODED | |
EVT_BOMB_EXPLODED = eventManager.createEvent('EVT_BOMB_EXPLODED', 'Bomb exploded') | |
def OnPop(self, action, data, match=None): | |
return Event(EVT_BOMB_EXPLODED, data=None) | |
Iourt41Parser.OnPop = OnPop | |
def patch_iourt42_parser(): | |
try: | |
from b3.parsers.iourt42 import Iourt42Parser | |
except ImportError: | |
return | |
else: | |
#17:24 Pop! | |
lineFormats = [re.compile(r'^(?P<action>Pop)!$')] | |
lineFormats.extend(Iourt42Parser._lineFormats) | |
Iourt42Parser._lineFormats = lineFormats | |
class BombexplodedPlugin(Plugin): | |
requiresConfigFile = False | |
def __init__(self, *args, **kwargs): | |
patch_iourt41_parser() | |
patch_iourt42_parser() | |
return Plugin.__init__(self, *args, **kwargs) |