Add easy way of negating ipport_filter regex to bf2 module

This commit is contained in:
Stefan Hacker
2011-01-06 02:32:35 +01:00
parent e48e90e037
commit 0fcb261ec4
2 changed files with 10 additions and 4 deletions

View File

@@ -28,6 +28,8 @@ mumble_server = 1
; by the plugins. If you have more then one server per virtual server
; you _must_ seperate the games by setting this
ipport_filter = .*
; Negates ipport_filter if True
ipport_filter_negate = False
; Channel the player is moved to (-1 for don't move)
left = -1

View File

@@ -35,7 +35,8 @@
# gamestate reported by Mumble positional audio plugins
#
from mumo_module import MumoModule
from mumo_module import (MumoModule,
x2bool)
import re
try:
@@ -50,6 +51,7 @@ class bf2(MumoModule):
lambda x: re.match('g\d+', x):(
('name', str, ''),
('mumble_server', int, 1),
('ipport_filter_negate', x2bool, False),
('ipport_filter', re.compile, re.compile('.*')),
('base', int, 0),
@@ -304,9 +306,11 @@ class bf2(MumoModule):
# Try to find a matching game
gamename = "g%d" % i
gamecfg = getattr(cfg, gamename)
if gamecfg.mumble_server == server.id() and \
gamecfg.ipport_filter.match(context["ipport"]):
break
if gamecfg.mumble_server == server.id():
not_matched = (gamecfg.ipport_filter.match(context["ipport"]) == None)
if not_matched == gamecfg.ipport_filter_negate:
break
gamename = None
if not gamename: