Crossfire Server, Trunk  1.75.0
CFMail.py
Go to the documentation of this file.
1 # CFMail.py - CFMail class
2 # Rewritten to use CFSqlDb
3 
4 import Crossfire
5 import CFSqlDb as cfdb
6 
7 class CFMail:
8  def __init__(self):
9  self.maildb = cfdb.open()
10 
11  def init_schema(self):
12  self.maildb.execute("CREATE TABLE IF NOT EXISTS mail ('recipient' TEXT, 'sender' TEXT, 'date' DATE, 'type' INT, 'message' TEXT);")
13 
14  def __enter__(self):
15  return self
16 
17  def __exit__(self, exc_type, exc_value, traceback):
18  self.close()
19 
20  def send(self, type, toname, fromname, message):
21  # type: 1=mailscoll, 2=newsletter, 3=mailwarning
22  self.maildb.execute("INSERT INTO mail VALUES (?, ?, datetime('now'), ?, ?);", (toname, fromname, type, message))
23 
24  def receive(self, toname):
25  c = self.maildb.cursor()
26  c.execute("SELECT type, sender, message FROM mail WHERE recipient=?;", (toname,))
27  mail = list()
28  for el in c.fetchall():
29  mail.append(el)
30  c.execute("DELETE FROM mail WHERE recipient=?;", (toname,))
31  return mail
32 
33  def countmail(self, toname):
34  c = self.maildb.cursor()
35  c.execute("SELECT COUNT(*) FROM mail WHERE recipient=?;", (toname,))
36  return c.fetchone()[0]
37 
38  def close(self):
39  self.maildb.commit()
40  self.maildb.close()
CFMail.CFMail.receive
def receive(self, toname)
Definition: CFMail.py:24
CFMail.CFMail.send
def send(self, type, toname, fromname, message)
Definition: CFMail.py:20
CFMail.CFMail
Definition: CFMail.py:7
CFMail.CFMail.__init__
def __init__(self)
Definition: CFMail.py:8
CFMail.CFMail.close
def close(self)
Definition: CFMail.py:38
CFMail.CFMail.__enter__
def __enter__(self)
Definition: CFMail.py:14
CFMail.CFMail.countmail
def countmail(self, toname)
Definition: CFMail.py:33
list
How to Install a Crossfire Server on you must install a python script engine on your computer Python is the default script engine of Crossfire You can find the python engine you have only to install them The VisualC Crossfire settings are for but you habe then to change the pathes in the VC settings Go in Settings C and Settings Link and change the optional include and libs path to the new python installation path o except the maps ! You must download a map package and install them the share folder Its must look like doubleclick on crossfire32 dsw There are projects in your libcross lib and plugin_python You need to compile all Easiest way is to select the plugin_python ReleaseLog as active this will compile all others too Then in Visual C press< F7 > to compile If you don t have an appropriate compiler you can try to get the the VC copies the crossfire32 exe in the crossfire folder and the plugin_python dll in the crossfire share plugins folder we will remove it when we get time for it o Last showing lots of weird write to the Crossfire mailing list
Definition: INSTALL_WIN32.txt:50
CFMail.CFMail.__exit__
def __exit__(self, exc_type, exc_value, traceback)
Definition: CFMail.py:17
CFMail.CFMail.maildb
maildb
Definition: CFMail.py:9
CFMail.CFMail.init_schema
def init_schema(self)
Definition: CFMail.py:11