Skip to content

Commit a30b306

Browse files
committed
Add Readme
1 parent ac53699 commit a30b306

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed

README.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Python A2S
2+
3+
Library to query Source and GoldSource servers. Rewrite of the
4+
[python-valve](https://github.com/serverstf/python-valve) module.
5+
6+
## Requirements
7+
8+
Just Python 3.5+
9+
10+
## Examples
11+
12+
Example output shown may be shortened.
13+
14+
```py
15+
>>> import a2s
16+
>>> address = ("stomping.kinofemu.net", 27015)
17+
>>> a2s.info(address)
18+
SourceInfo(protocol=17, server_name=" 24/7 Dustbowl :: Nemu's Stomping Ground", map_name='cp_dustbowl',
19+
folder='tf', game='Team Fortress', app_id=440, player_count=31, max_players=33, bot_count=21,
20+
server_type='d', platform='l', password_protected=True, vac_enabled=True, version='5579073',
21+
edf=177, port=27015, steam_id=85568392920040090, stv_port=None, stv_name=None,
22+
keywords='brutus,celt,couch,cp,dustbowl,increased_maxplayers,nemu,nocrits,nodmgspread,pony,replays,vanilla',
23+
game_id=440, ping=0.253798684978392)
24+
>>> a2s.players(address)
25+
[Player(index=0, name='Brutus', score=34, duration=836.4749145507812),
26+
Player(index=0, name='RageQuit', score=6, duration=1080.8099365234375),
27+
Player(index=0, name="Screamin' Eagles", score=1, duration=439.8598327636719)]
28+
>>> a2s.rules(address)
29+
{'coop': '0', 'deathmatch': '1', 'decalfrequency': '10', 'metamod_version': '1.10.7-devV',
30+
'mp_allowNPCs': '1', 'mp_autocrosshair': '1', 'mp_autoteambalance': '0', 'mp_disable_respawn_times': '0',
31+
'mp_fadetoblack': '0'}
32+
```
33+
34+
## API
35+
36+
### Functions
37+
38+
* `a2s.info(address, timeout=DEFAULT_TIMEOUT, encoding=DEFAULT_ENCODING)`
39+
* `a2s.players(address, timeout=DEFAULT_TIMEOUT, encoding=DEFAULT_ENCODING)`
40+
* `a2s.rules(address, timeout=DEFAULT_TIMEOUT, encoding=DEFAULT_ENCODING)`
41+
42+
### Parameters
43+
44+
* address: `Tuple[str, int]` - Address of the server.
45+
* timeout: `float` - Timeout in seconds. Default: 3.0
46+
* encoding: `str` or `None` - String encoding, None disables string decoding. Default: utf-8
47+
48+
### Return Values
49+
50+
* info: SourceInfo or GoldSrcInfo. They are documented in the
51+
[source file](a2s/info.py).
52+
* players: List of Player items. Also documented in the corresponding
53+
[source file](a2s/players.py)
54+
* rules: Dictionary of key - value pairs.
55+
56+
### Exceptions
57+
58+
* `a2s.BrokenMessageError(Exception)` - General decoding error
59+
* `a2s.BufferExhaustedError(BrokenMessageError)` - Response too short
60+
* `socket.timeout` - No response
61+
* `socket.gaierror` - Address resolution error
62+
63+
## License
64+
65+
MIT

0 commit comments

Comments
 (0)