Skip to content

Instantly share code, notes, and snippets.

@thomasleveil
Created April 8, 2013 22:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thomasleveil/5341263 to your computer and use it in GitHub Desktop.
Save thomasleveil/5341263 to your computer and use it in GitHub Desktop.
temporary plugin to patch B3 parsers for Urban Terror so they have a new EVT_BOMB_EXPLODED event.

bombexploded B3 plugin

A B3 plugin to add a new event EVT_BOMB_EXPLODED when the bomb explodes in Urban Terror.

Installation

  • copy the bombexploded.py file into b3/extplugins

  • in your b3.xml config file, add to the top of the plugins 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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment