Refactored the way default channels are added.

This commit is contained in:
Griatch 2015-02-23 16:15:29 +01:00
parent 68d294d007
commit 68e8062007
4 changed files with 33 additions and 49 deletions

View file

@ -415,12 +415,10 @@ def _create_player(session, playername, password,
utils.init_new_player(new_player)
# join the new player to the public channel
pchanneldef = settings.CHANNEL_PUBLIC
if pchanneldef:
pchannel = ChannelDB.objects.get_channel(pchanneldef[0])
if not pchannel.connect(new_player):
string = "New player '%s' could not connect to public channel!" % new_player.key
logger.log_errmsg(string)
pchannel = ChannelDB.objects.get_channel(settings.DEFAULT_CHANNELS[0]["key"])
if not pchannel.connect(new_player):
string = "New player '%s' could not connect to public channel!" % new_player.key
logger.log_errmsg(string)
return new_player

View file

@ -241,9 +241,9 @@ class DefaultPlayer(PlayerDB):
if not session:
return False
session = make_iter(session)[0]
print "unpuppet, session:", session, session.puppet
#print "unpuppet, session:", session, session.puppet
obj = hasattr(session, "puppet") and session.puppet or None
print "unpuppet, obj:", obj
#print "unpuppet, obj:", obj
if not obj:
return False
# do the disconnect, but only if we are the last session to puppet
@ -613,7 +613,8 @@ class DefaultPlayer(PlayerDB):
global _CONNECT_CHANNEL
if not _CONNECT_CHANNEL:
try:
_CONNECT_CHANNEL = ChannelDB.objects.filter(db_key=settings.CHANNEL_CONNECTINFO[0])[0]
print "all channels:", ChannelDB.objects.all()
_CONNECT_CHANNEL = ChannelDB.objects.filter(db_key=settings.DEFAULT_CHANNELS[1]["key"])[0]
except Exception:
logger.log_trace()
now = datetime.datetime.now()

View file

@ -125,34 +125,10 @@ def create_channels():
"""
print " Creating default channels ..."
# public channel
key1, aliases, desc, locks = settings.CHANNEL_PUBLIC
pchan = create.create_channel(key1, aliases, desc, locks=locks)
# mudinfo channel
key2, aliases, desc, locks = settings.CHANNEL_MUDINFO
ichan = create.create_channel(key2, aliases, desc, locks=locks)
# connectinfo channel
key3, aliases, desc, locks = settings.CHANNEL_CONNECTINFO
cchan = create.create_channel(key3, aliases, desc, locks=locks)
# TODO: postgresql-psycopg2 has a strange error when trying to
# connect the user to the default channels. It works fine from inside
# the game, but not from the initial startup. We are temporarily bypassing
# the problem with the following fix. See Evennia Issue 151.
if ((".".join(str(i) for i in django.VERSION) < "1.2"
and settings.DATABASE_ENGINE == "postgresql_psycopg2")
or (hasattr(settings, 'DATABASES')
and settings.DATABASES.get("default", {}).get('ENGINE', None)
== 'django.db.backends.postgresql_psycopg2')):
print WARNING_POSTGRESQL_FIX.format(chan1=key1, chan2=key2, chan3=key3)
return
# connect the god user to all these channels by default.
goduser = get_god_player()
pchan.connect(goduser)
ichan.connect(goduser)
cchan.connect(goduser)
for channeldict in settings.DEFAULT_CHANNELS:
channel = create.create_channel(**channeldict)
channel.connect(goduser)
def create_system_scripts():
"""

View file

@ -424,19 +424,28 @@ GUEST_LIST = ["Guest" + str(s+1) for s in range(9)]
# In-game Channels created from server start
######################################################################
# Each default channel is defined by a tuple containing
# (name, aliases, description, locks)
# where aliases may be a tuple too, and locks is
# a valid lockstring definition.
# Default user channel for communication
CHANNEL_PUBLIC = ("Public", ('ooc',), 'Public discussion',
"control:perm(Wizards);listen:all();send:all()")
# General info about the server
CHANNEL_MUDINFO = ("MUDinfo", '', 'Informative messages',
"control:perm(Immortals);listen:perm(Immortals);send:false()")
# Channel showing when new people connecting
CHANNEL_CONNECTINFO = ("MUDconnections", '', 'Connection log',
"control:perm(Immortals);listen:perm(Wizards);send:false()")
# This is a list of global channels created by the
# initialization script the first time Evennia starts.
# The superuser (user #1) will be automatically subscribed
# to all channels in this list. Each channel is described by
# a dictionary keyed with the same keys valid as arguments
# to the evennia.create.create_channel() function.
# Note: Evennia will treat the first channel in this list as
# the general "public" channel and the second as the
# general "mud info" channel. Other channels beyond that
# are up to the admin to design and call appropriately.
DEFAULT_CHANNELS = [
# public channel
{"key": "Public",
"aliases": ('ooc', 'pub'),
"desc": "Public discussion",
"locks": "control:perm(Wizards);listen:all();send:all()"},
# connection/mud info
{"key": "MudInfo",
"aliases": "",
"desc": "Connection log",
"locks": "control:perm(Immortals);listen:perm(Wizards);send:false()"}
]
######################################################################
# External Channel connections