Removed spam-possibilities with page command (issue100). Also did several other refinements to the comm system.

This commit is contained in:
Griatch 2010-09-04 13:52:01 +00:00
parent d90c2909a2
commit 142cb00566
7 changed files with 36 additions and 26 deletions

View file

@ -64,16 +64,19 @@ if os.name == 'nt':
bat_file.write("@%s %%*" % twistd_path)
bat_file.close()
print """
INFO: Since you are running Windows, a twistd.bat file was created for you.
The twistd.bat is a simple batch file that tries to call the twisted
executable. The system has determined this to be:
INFO: Since you are running Windows, a file 'twistd.bat' was
created for you. This is a simple batch file that tries to call
the twisted executable. Evennia determined this to be:
%s
If you should run into errors you might need to edit twistd.bat to point to
the correct location of the Twisted executable (usually called twistd.py).
If you run into errors at startup you might need to edit
twistd.bat to point to the actual location of the Twisted
executable (usually called twistd.py) on your machine.
When you are ready, run this program again to retry the server restart.""" % twistd_path
This procedure is only done once. Run evennia.py again when you
are ready to start the server.
""" % twistd_path
sys.exit()
TWISTED_BINARY = 'twistd.bat'

View file

@ -733,11 +733,14 @@ class CmdPage(MuxCommand):
caller = self.caller
player = caller.player
# get the last message we sent
# get the last messages we sent
messages = list(Msg.objects.get_messages_by_sender(player))
pages = [msg for msg in messages
if msg.receivers]
print messages
print pages
if pages:
lastpage = pages[-1]
@ -746,16 +749,17 @@ class CmdPage(MuxCommand):
lastpages = messages[-10:]
else:
lastpages = messages
lastpages = "\n ".join(["%s to %s: %s" % (mess.date_sent, mess.receivers.all(),
mess.message)
for mess in messages])
lastpages = "\n ".join(["{w%s{n to {c%s{n: %s" % (page.date_sent,
"{n,{c ".join([obj.name for obj in page.receivers]),
page.message)
for page in pages])
caller.msg("Your latest pages:\n %s" % lastpages )
return
return
if not self.args or not self.rhs:
if pages:
string = "You last paged %s." % (", ".join([obj.name
for obj in lastpage.receivers.all()]))
string = "You last paged {c%s{n." % (", ".join([obj.name
for obj in lastpage.receivers]))
caller.msg(string)
return
else:
@ -773,7 +777,7 @@ class CmdPage(MuxCommand):
receivers = self.lhslist
recobjs = []
for receiver in receivers:
for receiver in set(receivers):
pobj = caller.search("*%s" % (receiver.lstrip('*')), global_search=True)
if not pobj:
return
@ -782,7 +786,7 @@ class CmdPage(MuxCommand):
header = "{wPlayer{n {c%s{n {wpages:{n" % caller.key
message = self.rhs
# create the persistent message object
msg = create.create_message(caller, message,
msg = create.create_message(player, message,
receivers=recobjs)
# tell the players they got a message.
for pobj in recobjs:

View file

@ -608,6 +608,8 @@ class CmdCreate(ObjManipCommand):
else:
string = "You create a new %s: %s."
string = string % (obj.typeclass, obj.name)
# set a default desc
obj.db.desc = "You see nothing special."
if 'drop' in self.switches:
if caller.location:
obj.move_to(caller.location, quiet=True)

View file

@ -192,6 +192,10 @@ class CmdCreate(MuxCommand):
location=default_home,
typeclass=typeclass,
home=default_home)
# set a default description
new_character.db.desc = "This is a Player."
new_character.db.FIRST_LOGIN = True
new_player = new_character.player
new_player.db.FIRST_LOGIN = True

View file

@ -59,14 +59,14 @@ class MsgManager(models.Manager):
except:
return None
def get_messages_by_sender(self, sender):
def get_messages_by_sender(self, player):
"""
Get all messages sent by one player
"""
sender = to_object(sender)
if not sender:
player = to_object(player, objtype='player')
if not player:
return None
return self.filter(db_sender=sender).exclude(db_hide_from_sender=False)
return self.filter(db_sender=player).exclude(db_hide_from_sender=True)
def get_messages_by_receiver(self, receiver):
"""

View file

@ -49,7 +49,7 @@ def id_to_obj(dbref, db_model='PlayerDB'):
for the id.
"""
if db_model == 'PlayerDB':
from src.player.objects import PlayerDB as db_model
from src.players.models import PlayerDB as db_model
else:
db_model = Channel
try:
@ -208,7 +208,8 @@ class Msg(SharedMemoryModel):
#@property
def date_sent_get(self):
"Getter. Allows for value = self.date_sent"
return self.db_date_sent
date = self.db_date_sent
return str(date).rsplit('.',1)[0]
#@date_sent.setter
def date_sent_set(self, value):
"Setter. Allows for self.date_sent = value"

View file

@ -292,10 +292,6 @@ def create_message(senderobj, message, channels=None,
to let a message both go to several channels and to several receivers
at the same time, it's up to the command definitions to limit this as
desired.
Since messages are often directly created by the user, this method (and all
comm methods) raise CommErrors with different message strings to make it
easier for the Command definition to give proper feedback to the user.
"""
def to_player(obj):