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
|
; by the plugins. If you have more then one server per virtual server
|
||||||
; you _must_ seperate the games by setting this
|
; you _must_ seperate the games by setting this
|
||||||
ipport_filter = .*
|
ipport_filter = .*
|
||||||
|
; Negates ipport_filter if True
|
||||||
|
ipport_filter_negate = False
|
||||||
|
|
||||||
; Channel the player is moved to (-1 for don't move)
|
; Channel the player is moved to (-1 for don't move)
|
||||||
left = -1
|
left = -1
|
||||||
|
|||||||
@@ -35,7 +35,8 @@
|
|||||||
# gamestate reported by Mumble positional audio plugins
|
# gamestate reported by Mumble positional audio plugins
|
||||||
#
|
#
|
||||||
|
|
||||||
from mumo_module import MumoModule
|
from mumo_module import (MumoModule,
|
||||||
|
x2bool)
|
||||||
|
|
||||||
import re
|
import re
|
||||||
try:
|
try:
|
||||||
@@ -50,6 +51,7 @@ class bf2(MumoModule):
|
|||||||
lambda x: re.match('g\d+', x):(
|
lambda x: re.match('g\d+', x):(
|
||||||
('name', str, ''),
|
('name', str, ''),
|
||||||
('mumble_server', int, 1),
|
('mumble_server', int, 1),
|
||||||
|
('ipport_filter_negate', x2bool, False),
|
||||||
('ipport_filter', re.compile, re.compile('.*')),
|
('ipport_filter', re.compile, re.compile('.*')),
|
||||||
|
|
||||||
('base', int, 0),
|
('base', int, 0),
|
||||||
@@ -304,8 +306,10 @@ class bf2(MumoModule):
|
|||||||
# Try to find a matching game
|
# Try to find a matching game
|
||||||
gamename = "g%d" % i
|
gamename = "g%d" % i
|
||||||
gamecfg = getattr(cfg, gamename)
|
gamecfg = getattr(cfg, gamename)
|
||||||
if gamecfg.mumble_server == server.id() and \
|
|
||||||
gamecfg.ipport_filter.match(context["ipport"]):
|
if gamecfg.mumble_server == server.id():
|
||||||
|
not_matched = (gamecfg.ipport_filter.match(context["ipport"]) == None)
|
||||||
|
if not_matched == gamecfg.ipport_filter_negate:
|
||||||
break
|
break
|
||||||
gamename = None
|
gamename = None
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user