def patch_b3_admin_plugin(self):
"""
Monkey patches the admin plugin
"""
def new_cmd_kick(this, data, client=None, cmd=None):
"""
<name> [<reason>] - kick a player
<fullexactname> [<reason>] - kick an incompletely authed player
"""
m = this.parseUserCmd(data)
if not m:
client.message('^7Invalid parameters')
return False
cid, keyword = m
reason = this.getReason(keyword)
if not reason and client.maxLevel < this._noreason_level:
client.message('^1ERROR: ^7You must supply a reason')
return False
sclient = this.findClientPrompt(cid, client)
if sclient:
if sclient.cid == client.cid:
this.console.say(self.getMessage('kick_self', client.exactName))
return True
elif sclient.maxLevel >= client.maxLevel:
if sclient.maskGroup:
client.message('^7%s ^7is a masked higher level player, can\'t kick' % sclient.exactName)
else:
message = this.getMessage('kick_denied', sclient.exactName, client.exactName, sclient.exactName)
this.console.say(message)
return True
else:
sclient.kick(reason, keyword, client)
return True
elif re.match('^[0-9]+$', cid):
# failsafe, do a manual client id kick
this.console.kick(cid, reason, client)
else:
this.console.kickbyfullname(cid, reason, client)
admin_plugin = self.getPlugin('admin')
command = admin_plugin._commands['kick']
command.func = new.instancemethod(new_cmd_kick, admin_plugin)
command.help = new_cmd_kick.__doc__.strip()
abstractParser.py 文件源码
python
阅读 23
收藏 0
点赞 0
评论 0
评论列表
文章目录