-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathserverlogger.py
102 lines (90 loc) · 4.02 KB
/
serverlogger.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# -*- coding: utf-8 -*-
#------------------------------------------------------------------------------
# serverlogger - parses server logs (tf2 only currently)
# Copyright (c) 2012 Gavin Langdon <[email protected]>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#------------------------------------------------------------------------------
import SourceLib
class GameserverLogger(SourceLib.SourceLog.SourceLogParser):
def __init__(self, servermanager, server):
SourceLib.SourceLog.SourceLogParser.__init__(self)
self.server = server
self.manager = servermanager
self.objects = { 'OBJ_SENTRYGUN_MINI' : 'Mini-sentry',
'OBJ_ATTACHMENT_SAPPER' : 'Sapper',
'OBJ_DISPENSER' : 'Dispenser',
'OBJ_SENTRYGUN' : 'Sentry',
'OBJ_TELEPORTER' : 'Teleporter'
}
# def append_prettylog(self, text, tag1=None, tag2=None):
# if not tag1:
# self.prettylog.insert_with_tags(self.prettylog.get_end_iter(), text)
# elif not tag2:
# self.prettylog.insert_with_tags(self.prettylog.get_end_iter(), text, self.prettylog.get_tag_table().lookup(tag1))
# else:
# self.prettylog.insert_with_tags(self.prettylog.get_end_iter(), text, self.prettylog.get_tag_table().lookup(tag1), self.prettylog.get_tag_table().lookup(tag2))
#
#
# def action(self, remote, timestamp, key,value, properties):
# def getcolortag(team):
# return 'team_'+team.lower()
#
# if key in ['say', 'say_team']:
# text = value['player_name'] + ": "+value['message']
# if key == 'say_team':
# text = '(TEAM) ' + text
#
# self.append_prettylog(text, getcolortag(value['player_team']), "say")
#
# elif key == 'kill':
# self.append_prettylog(value['attacker_name'], getcolortag(value['attacker_team']))
# self.append_prettylog(" killed ")
# self.append_prettylog(value['victim_name'], getcolortag(value['victim_team']))
# self.append_prettylog(" with "+value['weapon'])
#
# elif key == 'class':
# self.append_prettylog(value['player_name'], getcolortag(value['player_team']))
# self.append_prettylog(" changed to "+value['class'])
#
# elif key == 'team':
# self.append_prettylog(value['player_name'])
# self.append_prettylog(" joined team ")
# self.append_prettylog(value['team'], getcolortag(value['team']))
#
# elif key == 'connect':
# self.append_prettylog(value['player_name'] + " (" + value['player_steamid'] + ") connected from " + value['ip'])
#
# elif key == 'trigger':
# if value['trigger'] == 'builtobject':
# self.append_prettylog(value['player_name'], getcolortag(value['player_team']))
# self.append_prettylog(" built a " + self.objects[properties['object']])
#
# elif value['trigger'] == 'killedobject':
# self.append_prettylog(value['player_name'], getcolortag(value['player_team']))
# self.append_prettylog(" destroyed ")
# self.append_prettylog(properties['objectowner']['player_name'] + "'s ", getcolortag(properties['objectowner']['player_team']))
# self.append_prettylog(self.objects[properties['object']] + " with " + properties['weapon'])
# else:
# print(value, properties)
# return
# else:
# return
#
# self.append_prettylog("\n")
def parse(self, line):
SourceLib.SourceLog.SourceLogParser.parse(self, line)
line = line.strip('\x00\xff\r\n\t')
self.manager.append_to_log(self.server, line, 'remote')