ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cf.schmorp.de/maps/python/CFLog.py
Revision: 1.2
Committed: Tue Feb 7 01:19:17 2006 UTC (18 years, 5 months ago) by root
Content type: text/x-python
Branch: MAIN
CVS Tags: post_fixaltar, last_stable, post_fixaltar2, rel-2_82, rel-2_81, rel-2_80, pre_coinconvert, rel-3_0, rel-2_6, rel-2_7, rel-2_4, rel-2_5, rel-2_2, rel-2_0, rel-2_1, rel-2_72, rel-2_73, rel-2_71, rel-2_76, rel-2_77, rel-2_74, rel-2_75, rel-2_54, rel-2_55, rel-2_56, rel-2_79, rel-2_53, pre_material_cfarch_normalize_run, rel-2_32, pre_fixconverter, post_coinconvert, pre_fixaltar2, pre_map_rename, rel-2_90, rel-2_92, rel-2_93, rel-2_78, post_fixconverter, pre_fixaltar, rel-2_61, rel-2_43, rel-2_42, rel-2_41, HEAD
Changes since 1.1: +14 -6 lines
Log Message:
*** empty log message ***

File Contents

# Content
1 # CFLog.py - CFLog class
2 #
3 # Copyright (C) 2002 Joris Bontje
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 #
19 # The author can be reached via e-mail at jbontje@suespammers.org
20 #
21
22 # Updated to use new path functions in CFPython -Todd Mitchell
23 #
24 # Updated to add new fields and functions (kick, muzzle)
25 # and rewritten to use plain text file storage (CFDataFile) instead of shelve.
26
27
28 import Crossfire
29
30 from time import localtime, strftime, time
31 from CFDataFile import CFDataFile, CFData
32
33 class CFLog:
34
35 def __init__(self):
36 logheader = ['Born', 'IP', 'Last_Login_Date', 'Login_Count', 'Kick_Count'
37 , 'Last_Kick_Date', 'Muzzle_Count', 'Last_Muzzle_Date', 'Last_Logout_Date']
38 self.log = CFData('Player_log', logheader)
39
40 def create(self, name):
41 date = time()
42 record={'#': name
43 ,'Born':date
44 ,'IP':'unknown'
45 ,'Last_Login_Date':date
46 ,'Login_Count':0
47 ,'Kick_Count':0
48 ,'Last_Kick_Date':'never'
49 ,'Muzzle_Count':0
50 ,'Last_Muzzle_Date':'never'
51 ,'Last_Logout_Date':0}
52 self.log.put_record(record)
53
54 def remove(self, name):
55 self.log.remove_record(name)
56
57 def login_update(self, name, ip):
58 date = time()
59 record = self.log.get_record(name)
60 record['IP']=ip
61 record['Last_Login_Date']=date
62 record['Login_Count']=int(record['Login_Count'])+1
63 record['Last_Logout_Date']=0
64 self.log.put_record(record)
65
66 def logout_update(self, name):
67 date = time()
68 record = self.log.get_record(name)
69 record['Last_Logout_Date']=date
70 self.log.put_record(record)
71
72 def kick_update(self, name):
73 date = time()
74 record = self.log.get_record(name)
75 record['Kick_Count']=int(record['Kick_Count'])+1
76 record['Last_Kick_Date']=date
77 self.log.put_record(record)
78
79 def muzzle_update(self, name):
80 date = time()
81 record = self.log.get_record(name)
82 record['Muzzle_Count']=int(record['Muzzle_Count'])+1
83 record['Last_Muzzle_Date']=date
84 self.log.put_record(record)
85
86 def info(self, name):
87 if name == '#':
88 return 0
89 record = self.log.get_record(name)
90 if record:
91 return record
92 else:
93 return 0