markweirath / big-brother-bot

Big Brother Bot B3 is a complete and total server administration package for online games. B3 is designed primarily to keep your server free from the derelicts of online gaming, but offers more, much more.
http://www.bigbrotherbot.net
44 stars 32 forks source link

BF3: !kick 1365 fails if exact player name is "13658787" #81

Closed thomasleveil closed 12 years ago

thomasleveil commented 12 years ago

It was reported that when

then B3 fails to find the player and thinks the parameter is a slot number (as for Quake3 based games)

log

120203 22:29:28 CONSOLE "['player.onChat', 'DevilBFC', '!kick 105373 ()']"
120203 22:29:28 VERBOSE 'Queueing event Say !kick 105373 ()'
120203 22:29:28 VERBOSE 'Parsing Event: Say: AdminPlugin'
120203 22:29:28 DEBUG 'AdminPlugin: OnSay handle 5:"!kick 105373 ()"'
120203 22:29:28 DEBUG 'AdminPlugin: Handle command !kick 105373 ()'
120203 22:29:28 DEBUG 'kick reason: [()]'
120203 22:29:28 DEBUG "getCommand: ('admin.kickPlayer', '105373', '()')"
120203 22:29:28 VERBOSE u"RCON :\t ('admin.kickPlayer', '105373', '()')"
120203 22:29:28 DEBUG "getCommand: ('admin.say', '[pm] There was an error processing your command', 'squad', '1', '1')"
120203 22:29:28 VERBOSE u"RCON :\t ('admin.say', '[pm] There was an error processing your command', 'squad', '1', '1')"
120203 22:29:28 ERROR 'handler AdminPlugin could not handle event Say: CommandFailedError: [\'InvalidPlayerName\'] [(\'/home/ozon/bf3_stuff/big-brother-bot/b3/parser.py\', 1002, \'handleEvents\', \'hfunc.parseEvent(event)\'), (\'/home/ozon/bf3_stuff/big-brother-bot/b3/plugin.py\', 158, \'parseEvent\', \'self.onEvent(event)\'), (\'/home/ozon/bf3_stuff/big-brother-bot/b3/plugin.py\', 176, \'onEvent\', \'self.handle(event)\'), (\'/home/ozon/bf3_stuff/big-brother-bot/b3/plugins/admin.py\', 229, \'handle\', \'self.OnSay(event)\'), (\'/home/ozon/bf3_stuff/big-brother-bot/b3/plugins/admin.py\', 374, \'OnSay\', \'results = command.execute(data, event.client)\'), (\'/home/ozon/bf3_stuff/big-brother-bot/b3/plugins/admin.py\', 2019, \'execute\', \'self.func(data, client, copy.copy(self))\'), (\'/home/ozon/bf3_stuff/big-brother-bot/b3/plugins/admin.py\', 1212, \'cmd_kick\', \'self.console.kick(cid, reason, client)\'), (\'/home/ozon/bf3_stuff/big-brother-bot/b3/parsers/frostbite2/abstractParser.py\', 809, \'kick\', "self.write(self.getCommand(\'kick\', cid=client, reason=reason[:80]))"), (\'/home/ozon/bf3_stuff/big-brother-bot/b3/parsers/frostbite2/abstractParser.py\', 382, \'write\', \'res = self.output.write(msg, maxRetries=maxRetries, needConfirmation=needConfirmation)\'), (\'/home/ozon/bf3_stuff/big-brother-bot/b3/parsers/frostbite2/rcon.py\', 52, \'write\', \'response = self.frostbite_server.command(cmd)\'), (\'/home/ozon/bf3_stuff/big-brother-bot/b3/parsers/frostbite2/protocol.py\', 326, \'command\', \'raise CommandFailedError(response)\')]'
120203 22:29:28 CONSOLE "['player.onChat', 'Server', '[pm] There was an error processing your command']"
120203 22:29:28 VERBOSE u'RCON response:\t []'

technical explanation

This is due to the way the b3.clients.Clients.getByMagic method is implemented :


    def getByMagic(self, id):
        id = id.strip()

        if re.match(r'^[0-9]+$', id):
            # seems to be a client id
            return [self.getByCID(id)]
        elif re.match(r'^@([0-9]+)$', id):
            return self.getByDB(id)
        elif id[:1] == '\\':
            c = self.getByName(id[1:])
            if c and not c.hide:
                return [c]
            else:
                return []
        else:
            return self.getClientsByName(id)

solutions

one of the solution would be to make the BF3 parser patch the b3.clients.Clients.getByMagic when it loads.

ozguruysal commented 12 years ago

Is this issue BF3 specific only?

thomasleveil commented 12 years ago

I don't think so. I believe this applies to all games not using slot numbers as Quake3 based games do. (BFB2, MoH, BF3, Homefront?, ...) and allowing players to be named just with digits.

Now, another improvement that would make such situations less frequent would be to consider that a slot number can only be one or two digits. As such any number higher than 99 would not be understood as a slot number.

What do you think ?

ozguruysal commented 12 years ago

I think you can have a player name with digits only in blops. I'll check and confirm when I'm home. I agree any number more than 2 digits should be considered as a player name. Also If an admin tries to punish a player with digits only in his/her name by typing less than 3 characters, he will punish somebody else by the slot number. For instance we have a naughty player with a name "12345" and admin tries to kick him by !k 12. Innocent player in slot 12 gets kicked.

82ndab-Bravo17 commented 12 years ago

Won't work with RO2, it starts giving out pseudo slot numbers and doesn't reset the numbers until the server is restarted, lots of 4 digit ones, but I haven't seen any 5 digit yet.....

How about using quotes to signify that it is a name? so !k 123 would kick slot 123 but !k '123' would kick a player called 123.

Although for BF3 since the equivalent of the slot no is also the name !k all-the-numbers should work as well, as the original poster of the problem seems to confirm?

thomasleveil commented 12 years ago

yes I confirm using the full name does work even if composed on digits exclusively. I'm not sure if wrapping the partial name with quotes (or double quotes) does work at this time.