thankyou
Donate to the B3 fund!

"even a small donation helps!"
Donate with PayPal!

Author Topic: Bot List Help!  (Read 1478 times)

Offline zdanman

  • Full Member
  • ***
  • Posts: 68
Bot List Help!
« on: February 28, 2015, 11:21:50 PM »
I see the bots are detected in the log...

Code: [Select]
150228 16:06:08	VERBOS2	'Client Join Team event handled by XlrstatsPlugin in 79.791 ms'
150228 16:06:08 CONSOLE 'L 02/28/2015 - 16:06:07: "Rich<96><BOT><>" connected, address "none"'
150228 16:06:08 VERBOSE 'Parsing event: Client Join Team: XlrstatsPlugin'
150228 16:06:08 VERBOS2 "calling on_client_connected{'cid': u'96', 'ip': u'none', 'guid': u'BOT', 'name': u'Rich', 'team': u''}"
150228 16:06:08 DEBUG 'XlrstatsPlugin: checking number of players online: minimum = 2, current = 1'
150228 16:06:08 DEBUG 'XlrstatsPlugin: nothing to do at the moment: XLRstats is already enabled'
150228 16:06:08 DEBUG u'client connected: [BOT96] Rich - BOT96 ({})'
150228 16:06:08 CONSOLE 'L 02/28/2015 - 16:06:07: "Rich<96><BOT><>" entered the game'
150228 16:06:08 VERBOS2 "calling on_client_entered{'cid': u'96', 'guid': u'BOT', 'name': u'Rich', 'team': u''}"
150228 16:06:08 VERBOS2 u'Aborted making alias for cid BOT96: name is the same'
150228 16:06:08 VERBOSE 'Queueing event Client Join Team : None'
150228 16:06:08 VERBOSE 'XlrstatsPlugin: hiding bot'
150228 16:06:08 CONSOLE 'L 02/28/2015 - 16:06:07: "Rich<96><BOT><#Team_Unassigned>" joined team "#Team_Insurgent"'
150228 16:06:08 VERBOS2 "calling on_client_join_team{'cid': u'96', 'guid': u'BOT', 'old_team': u'#Team_Unassigned', 'new_team': u'#Team_Insurgent', 'name': u'Rich'}"
150228 16:06:08 VERBOS2 u'Aborted making alias for cid BOT96: name is the same'

But are then hidden by XLRStats.... which is great for stats purposes.

Code: [Select]
XLRStats (__init__.py: Line 1493)

      player = self.get_PlayerStats(client)
        if player:
            player.rounds = int(player.rounds) + 1
            if client.bot:
                if self.hide_bots:
                    self.verbose('hiding bot')
                    player.hide = True
                else:
                    self.verbose('unhiding bot')
                    player.hide = False
            self.save_Stat(player)

But when I'm trying to get a list of bots... this becomes a problem.
Example: the following code outputs only a list of the human players to the log file.

Code: [Select]
        clist = self.console.clients.getClientsByLevel(0)
        ListBotsPresents = []
        if len(clist) > 0:
            for c in clist:
                self.console.verbose('BotControl Plugin:%s,%s,%s,%s;', c.name, c.exactName, c.guid, c.bot)

I guess my question would be ... how do you get a list of the hidden players (aka bots)?
« Last Edit: February 28, 2015, 11:24:21 PM by zdanman »

Offline zdanman

  • Full Member
  • ***
  • Posts: 68
Re: Bot List Help!
« Reply #1 on: February 28, 2015, 11:28:23 PM »

Offline 82ndAB.Bravo17

  • Dev. Team
  • Hero Member
  • *
  • Posts: 2628
Re: Bot List Help!
« Reply #2 on: March 01, 2015, 01:39:08 AM »
You can use the getPlayerList or queryServerInfo methods from the parser to get all the connected players and bots, or do a server status command yourself and parse the result.

Or you could try clients.getClientsByName and use BOT as the name since that returns a list of matching clients.

Offline zdanman

  • Full Member
  • ***
  • Posts: 68
Re: Bot List Help!
« Reply #3 on: March 01, 2015, 02:57:29 PM »
thanks for the suggestion

getPlayerList (which is an alias for queryServerInfo in the Insurgency Parser) returns only current human players.

self.console.clients.getClientsByName('BOT') returns nothing.

Offline zdanman

  • Full Member
  • ***
  • Posts: 68
Re: Bot List Help!
« Reply #4 on: March 01, 2015, 03:04:26 PM »
self.console.clients.getList() does the same... only returns human players

Offline zdanman

  • Full Member
  • ***
  • Posts: 68
Re: Bot List Help!
« Reply #5 on: March 01, 2015, 03:11:41 PM »
self.console.clients.getByGUID('BOT')  and self.console.clients.getByCID('BOT') also returns nothing

Offline zdanman

  • Full Member
  • ***
  • Posts: 68
Re: Bot List Help!
« Reply #6 on: March 01, 2015, 03:18:01 PM »
I tried disabling xlrstats temporarily.

clients.getList() still only returns a list of human players.

Offline zdanman

  • Full Member
  • ***
  • Posts: 68
Re: Bot List Help!
« Reply #7 on: March 01, 2015, 03:41:57 PM »
I think im on to something:

Insurgency.py
Code: [Select]
def on_client_connected(self, name, cid, guid, team, ip):
   # L 08/26/2012 - 03:22:36: "courgette<2><STEAM_1:0:1111111><>" connected, address "11.222.111.222:27005"
   # L 08/26/2012 - 03:22:36: "Moe<3><BOT><>" connected, address "none"
   client = self.getClientOrCreate(cid, guid, name, team)
   if ip != "none" and client.ip != ip:
      client.ip = ip
      client.save()

As you can see the bots are not added to the client list... therefore I am going to intercept the EVT_CLIENT_CONNECT and DISCONNECT messages and keep my own bot list.

Offline 82ndAB.Bravo17

  • Dev. Team
  • Hero Member
  • *
  • Posts: 2628
Re: Bot List Help!
« Reply #8 on: March 01, 2015, 07:17:37 PM »
Bots definitely are added to the client list, I had to hide them so that they didn't show up in !list

try:

Code: [Select]
        clist = []
        for cid, c in self.clients.items():
            clist.append(c.name)

Offline 82ndAB.Bravo17

  • Dev. Team
  • Hero Member
  • *
  • Posts: 2628
Re: Bot List Help!
« Reply #9 on: March 01, 2015, 10:37:07 PM »
Note that all Bots have the guid BOT - the parser adds the cid to "BOT" to differentiate between them ie BOT12, BOT13 etc.

Offline zdanman

  • Full Member
  • ***
  • Posts: 68
Re: Bot List Help!
« Reply #10 on: March 01, 2015, 11:39:34 PM »
yeah... i had to remove it in order to use the kickid command

my first release of the plugin can be seen here:
http://forum.bigbrotherbot.net/releases/insurgency-bot-control-plugin-released!/

 


Rate this page +1 at Google Search