User Tools

Site Tools


B3 Homepage

Main Links

Support Subjects

Related Links

This wiki was updated recently and all user accounts were reset. If you want to contribute to this documentation wiki drop me an email at xlr8or[at]bigbrotherbot[dot]net.


FIXME work in progress

In B3 a parser is a module containing a class that inherits from the b3.parser.Parser class. The b3.parser.Parser class is to be considered abstract and must be extended by inheriting parser classes.

The inheriting parser class must define different attributes

  • gameName which is the parser name to be used in b3.xml. Must be unique among B3 parsers and lowercase only.
  • output which is an file-like Python object to be used to send rcon commands
  • _lineTime which is a regular expression that extract the timestamp from a game log line (only in the case where your parser does not overwrite the method)

The inheriting parser class can overwrite some attributes

  • _reColor which is a regular expression able to remove color codes from a string. By default remove Quake3 like color codes

The inheriting parser class must implement different methods

  • parseLine(line) : Called to parse a single line from the game log file. If the line is recognized, then it should return a B3 event matching the content of that line.
  • getPlayerList() : Query the game server for connected players. return a dict having players' id for keys and players' data as another dict for values
  • authorizeClients() : For all connected players, fill the client object with properties allowing to find the user in the database (usualy guid, or punkbuster id, ip) and call the Client.auth() method
  • sync() : For all connected players returned by self.getPlayerList(), get the matching Client object from self.clients (with self.clients.getByCID(cid) or similar methods) and look for inconsistencies. If required call the client.disconnect() method to remove a client from self.clients. This is mainly useful for games where clients are identified by the slot number they occupy. On map change, a player A on slot 1 can leave making room for player B who connects on slot 1.
  • say(msg) : broadcast a message to all players
  • saybig(msg) : broadcast a message to all players in a way that will catch their attention.
  • message(client, msg) : display a message to a given player
  • kick(client, reason, admin, silent, …) : kick a given player
  • ban(client, reason, admin, silent, …) : ban a given player
  • unban(client, reason, admin, silent, …) : unban a given player
  • tempban(client, reason, duration, admin, silent, …) : tempban a given player
  • getMap() : return the current map/level name
  • getMaps() : return the available maps/levels name
  • rotateMap() : load the next map/level
  • changeMap(map) : load a given map/level. return a list of suggested map names in cases it fails to recognize the map that was provided
  • getPlayerPings() : returns a dict having players' id for keys and players' ping for values
  • getPlayerScores() : returns a dict having players' id for keys and players' scores for values

The inheriting parser class can optionally implement different methods

  • inflictCustomPenalty(type, …) : Called if b3.admin.penalizeClient() does not know a given penalty type. Overwrite this to add customized penalties for your game like 'slap', 'nuke', 'mute' or anything you want. /!\ This method must return True if the penalty was inflicted.
  • run() : this is the method that retrieves game events. By default it does so by reading lines from a game log file, but for some games this method need to be redefined to read events from a network connection. This the the piece of code that calls the parseLine() method.
customize/parser/overview.txt · Last modified: 2011/04/30 00:00 (external edit)

Page Tools