Crossfire Server, Trunk
receive.py
Go to the documentation of this file.
1 """
2 Created by: Joris Bontje <jbontje@suespammers.org>
3 
4 This script implements the apply event for mailboxes. When a mailbox is
5 opened, check the player's mail and create objects if necessary.
6 """
7 
8 import Crossfire
9 import CFMail
10 
11 activator = Crossfire.WhoIsActivator()
12 mail = CFMail.CFMail()
13 whoami = Crossfire.WhoAmI()
14 
15 total = mail.countmail(activator.Name)
16 
17 if total > 0:
18  activator.Write("You have %d mail!" % total)
19  elements = mail.receive(activator.Name)
20  for element in elements:
21  type, fromname, message = element
22  if type == 1:
23  msgob = whoami.CreateObject('scroll')
24  msgob.Name = "mail F: %s T: %s" % (fromname, activator.Name)
25  msgob.NamePl = msgob.Name
26  msgob.Message = message
27  msgob.Value = 0
28  elif type == 2:
29  msgob = whoami.CreateObject('note')
30  msgob.Name = 'newspaper D: '+fromname
31  msgob.NamePl = 'newspapers D: '+fromname
32  msgob.Message = message
33  msgob.Value = 0
34  elif type == 3:
35  msgob = whoami.CreateObject('diploma')
36  msgob.Name = 'warning F: '+fromname+' T: '+activator.Name
37  msgob.NamePl = 'warnings F: '+fromname+' T: '+activator.Name
38  msgob.Message = message
39  msgob.Value = 0
40  else:
41  Crossfire.Log(Crossfire.LogError, 'ERROR: unknown mailtype\n')
42 else:
43  activator.Write("You haven't got any mail.")
44 
45 mail.close()
CFMail.CFMail
Definition: CFMail.py:7