mirror of
https://github.com/evennia/evennia.git
synced 2026-03-25 01:06:32 +01:00
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.
This commit is contained in:
parent
4c562cd6ce
commit
f0c129f730
3 changed files with 22 additions and 3 deletions
|
|
@ -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()
|
||||
|
|
@ -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')
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue