Add easy way of negating ipport_filter regex to bf2 module
This commit is contained in:
@@ -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
|
||||
|
@@ -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:
|
||||
|
Reference in New Issue
Block a user