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.write("@%s %%*" % twistd_path)
bat_file.close() bat_file.close()
print """ print """
INFO: Since you are running Windows, a twistd.bat file was created for you. INFO: Since you are running Windows, a file 'twistd.bat' was
The twistd.bat is a simple batch file that tries to call the twisted created for you. This is a simple batch file that tries to call
executable. The system has determined this to be: the twisted executable. Evennia determined this to be:
%s %s
If you should run into errors you might need to edit twistd.bat to point to If you run into errors at startup you might need to edit
the correct location of the Twisted executable (usually called twistd.py). 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() sys.exit()
TWISTED_BINARY = 'twistd.bat' TWISTED_BINARY = 'twistd.bat'

View file

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

View file

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

View file

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

View file

@ -59,14 +59,14 @@ class MsgManager(models.Manager):
except: except:
return None return None
def get_messages_by_sender(self, sender): def get_messages_by_sender(self, player):
""" """
Get all messages sent by one player Get all messages sent by one player
""" """
sender = to_object(sender) player = to_object(player, objtype='player')
if not sender: if not player:
return None 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): def get_messages_by_receiver(self, receiver):
""" """

View file

@ -49,7 +49,7 @@ def id_to_obj(dbref, db_model='PlayerDB'):
for the id. for the id.
""" """
if db_model == 'PlayerDB': if db_model == 'PlayerDB':
from src.player.objects import PlayerDB as db_model from src.players.models import PlayerDB as db_model
else: else:
db_model = Channel db_model = Channel
try: try:
@ -208,7 +208,8 @@ class Msg(SharedMemoryModel):
#@property #@property
def date_sent_get(self): def date_sent_get(self):
"Getter. Allows for value = self.date_sent" "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 #@date_sent.setter
def date_sent_set(self, value): def date_sent_set(self, value):
"Setter. Allows for self.date_sent = 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 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 at the same time, it's up to the command definitions to limit this as
desired. 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): def to_player(obj):