Crossfire Server, Trunk
CFLog.py
Go to the documentation of this file.
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']
38  self.log = CFData('Player_log', logheader)
39 
40  def create(self, name):
41  date = strftime("%a, %d %b %Y %H:%M:%S %Z", localtime(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  self.log.put_record(record)
52 
53  def remove(self, name):
54  self.log.remove_record(name)
55 
56  def login_update(self, name, ip):
57  date = strftime("%a, %d %b %Y %H:%M:%S %Z", localtime(time()))
58  record = self.log.get_record(name)
59  record['IP']=ip
60  record['Last_Login_Date']=date
61  record['Login_Count']=int(record['Login_Count'])+1
62  self.log.put_record(record)
63 
64  def kick_update(self, name):
65  date = strftime("%a, %d %b %Y %H:%M:%S %Z", localtime(time()))
66  record = self.log.get_record(name)
67  record['Kick_Count']=int(record['Kick_Count'])+1
68  record['Last_Kick_Date']=date
69  self.log.put_record(record)
70 
71  def muzzle_update(self, name):
72  date = strftime("%a, %d %b %Y %H:%M:%S %Z", localtime(time()))
73  record = self.log.get_record(name)
74  record['Muzzle_Count']=int(record['Muzzle_Count'])+1
75  record['Last_Muzzle_Date']=date
76  self.log.put_record(record)
77 
78  def info(self, name):
79  if name == '#':
80  return 0
81  record = self.log.get_record(name)
82  if record:
83  return record
84  else:
85  return 0
CFLog.CFLog.info
def info(self, name)
Definition: CFLog.py:78
CFDataFile.CFData
Definition: CFDataFile.py:94
CFLog.CFLog.kick_update
def kick_update(self, name)
Definition: CFLog.py:64
CFLog.CFLog.__init__
def __init__(self)
Definition: CFLog.py:35
CFLog.CFLog
Definition: CFLog.py:33
CFLog.CFLog.muzzle_update
def muzzle_update(self, name)
Definition: CFLog.py:71
CFLog.CFLog.remove
def remove(self, name)
Definition: CFLog.py:53
CFLog.CFLog.log
log
Definition: CFLog.py:38
CFLog.CFLog.login_update
def login_update(self, name, ip)
Definition: CFLog.py:56
make_face_from_files.int
int
Definition: make_face_from_files.py:26
CFLog.CFLog.create
def create(self, name)
Definition: CFLog.py:40