From f0c129f7304e7f4ff13de4328a89bfd319d8d13f Mon Sep 17 00:00:00 2001 From: Greg Taylor Date: Thu, 22 Jan 2009 03:50:16 +0000 Subject: [PATCH] Fixes to player creation that may not actually do anything. Also add default flagged channels with the default alias being the first three characters of the channel's name. --- src/objects/managers/object.py | 3 +++ src/objects/models.py | 6 ++++++ src/session.py | 16 +++++++++++++--- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/objects/managers/object.py b/src/objects/managers/object.py index 43edaeff75..75ba3c5182 100644 --- a/src/objects/managers/object.py +++ b/src/objects/managers/object.py @@ -343,6 +343,8 @@ class ObjectManager(models.Manager): user = User.objects.create_user(uname, email, password) # It stinks to have to do this but it's the only trivial way now. user.save() + # Update the session to use the newly created User object's ID. + session.uid = user.id # We can't use the user model to change the id because of the way keys # are handled, so we actually need to fall back to raw SQL. Boo hiss. @@ -367,3 +369,4 @@ class ObjectManager(models.Manager): session.msg("Welcome to %s, %s.\n\r" % ( ConfigValue.objects.get_configvalue('site_name'), session.get_pobject().get_name(show_dbref=False))) + session.add_default_channels() \ No newline at end of file diff --git a/src/objects/models.py b/src/objects/models.py index 134d861fb5..ffd8c1c2c8 100755 --- a/src/objects/models.py +++ b/src/objects/models.py @@ -976,6 +976,12 @@ class CommChannel(models.Model): # They've failed to meet any of the above conditions. return False + + def get_default_chan_alias(self): + """ + Returns a default channel alias for the channel if none is provided. + """ + return self.name[:3].lower() class CommChannelAdmin(admin.ModelAdmin): list_display = ('name', 'owner') diff --git a/src/session.py b/src/session.py index 20f6d713db..50135a237c 100755 --- a/src/session.py +++ b/src/session.py @@ -10,13 +10,14 @@ from twisted.conch.telnet import StatefulTelnetProtocol from django.contrib.auth.models import User -from src.objects.models import Object +from src.objects.models import Object, CommChannel from src.config.models import ConnectScreen, ConfigValue +from util import functions_general +import src.comsys import cmdhandler import logger import session_mgr import ansi -from util import functions_general class SessionProtocol(StatefulTelnetProtocol): """ @@ -133,7 +134,7 @@ class SessionProtocol(StatefulTelnetProtocol): result = Object.objects.get(id=self.uid) return result except: - logger.log_errmsg("No session match for object: #%s" % self.uid) + logger.log_errmsg("No pobject match for session uid: %s" % self.uid) return None def game_connect_screen(self): @@ -186,6 +187,15 @@ class SessionProtocol(StatefulTelnetProtocol): message = message.encode("utf-8") self.sendLine("%s" % (message,)) + def add_default_channels(self): + """ + Adds the player to the default channels. + """ + # Add the default channels. + for chan in CommChannel.objects.filter(is_joined_by_default=True): + chan_alias = chan.get_default_chan_alias() + src.comsys.plr_set_channel(self, chan_alias, chan.name, True) + def __str__(self): """ String representation of the user session class. We use