This commit is contained in:
Victor Fors 2022-04-06 16:49:50 +02:00
parent e733e5cd0a
commit f27ba6ba8b

27
sstatus
View File

@ -51,21 +51,30 @@ def get_player_summaries(steamids):
} }
return steam_query('ISteamUser/GetPlayerSummaries/v0002', lambda data: data['response']['players'], params) return steam_query('ISteamUser/GetPlayerSummaries/v0002', lambda data: data['response']['players'], params)
def boldgreen(string):
return '\033[92m' + '\033[1m' + string + '\033[0m'
def boldred(string):
return '\033[91m' + '\033[1m' + string + '\033[0m'
def boldgray(string):
return '\033[90m' + '\033[1m' + string + '\033[0m'
def personastate(n): def personastate(n):
states = { states = {
0 : 'Offline', 0 : boldred('Offline'),
1 : 'Online', 1 : boldgreen('Online'),
2 : 'Busy', 2 : boldred('Busy'),
3 : 'Away', 3 : boldgray('Away'),
4 : 'Snooze', 4 : boldgray('Snooze'),
5 : 'Looking to trade', 5 : boldgreen('Looking to trade'),
6 : 'Looking to play' 6 : boldgreen('Looking to play')
} }
return states[n] return states[n]
def main(): def main():
#print('\n'.join([friend['steamid'] for friend in get_friend_list(uid)])) for player in sorted(get_player_summaries([friend['steamid'] for friend in get_friend_list(uid)]), key=lambda player: player['personaname']):
for player in get_player_summaries([friend['steamid'] for friend in get_friend_list(uid)]):
print(player['personaname'] + ': ' + personastate(player['personastate']) + (', playing ' + player['gameextrainfo'] if 'gameextrainfo' in player else '')) print(player['personaname'] + ': ' + personastate(player['personastate']) + (', playing ' + player['gameextrainfo'] if 'gameextrainfo' in player else ''))