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) utils.init_new_player(new_player)
# join the new player to the public channel # join the new player to the public channel
pchanneldef = settings.CHANNEL_PUBLIC pchannel = ChannelDB.objects.get_channel(settings.DEFAULT_CHANNELS[0]["key"])
if pchanneldef: if not pchannel.connect(new_player):
pchannel = ChannelDB.objects.get_channel(pchanneldef[0]) string = "New player '%s' could not connect to public channel!" % new_player.key
if not pchannel.connect(new_player): logger.log_errmsg(string)
string = "New player '%s' could not connect to public channel!" % new_player.key
logger.log_errmsg(string)
return new_player return new_player

View file

@ -241,9 +241,9 @@ class DefaultPlayer(PlayerDB):
if not session: if not session:
return False return False
session = make_iter(session)[0] 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 obj = hasattr(session, "puppet") and session.puppet or None
print "unpuppet, obj:", obj #print "unpuppet, obj:", obj
if not obj: if not obj:
return False return False
# do the disconnect, but only if we are the last session to puppet # do the disconnect, but only if we are the last session to puppet
@ -613,7 +613,8 @@ class DefaultPlayer(PlayerDB):
global _CONNECT_CHANNEL global _CONNECT_CHANNEL
if not _CONNECT_CHANNEL: if not _CONNECT_CHANNEL:
try: 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: except Exception:
logger.log_trace() logger.log_trace()
now = datetime.datetime.now() now = datetime.datetime.now()

View file

@ -125,34 +125,10 @@ def create_channels():
""" """
print " Creating default 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() goduser = get_god_player()
pchan.connect(goduser) for channeldict in settings.DEFAULT_CHANNELS:
ichan.connect(goduser) channel = create.create_channel(**channeldict)
cchan.connect(goduser) channel.connect(goduser)
def create_system_scripts(): 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 # In-game Channels created from server start
###################################################################### ######################################################################
# Each default channel is defined by a tuple containing # This is a list of global channels created by the
# (name, aliases, description, locks) # initialization script the first time Evennia starts.
# where aliases may be a tuple too, and locks is # The superuser (user #1) will be automatically subscribed
# a valid lockstring definition. # to all channels in this list. Each channel is described by
# Default user channel for communication # a dictionary keyed with the same keys valid as arguments
CHANNEL_PUBLIC = ("Public", ('ooc',), 'Public discussion', # to the evennia.create.create_channel() function.
"control:perm(Wizards);listen:all();send:all()") # Note: Evennia will treat the first channel in this list as
# General info about the server # the general "public" channel and the second as the
CHANNEL_MUDINFO = ("MUDinfo", '', 'Informative messages', # general "mud info" channel. Other channels beyond that
"control:perm(Immortals);listen:perm(Immortals);send:false()") # are up to the admin to design and call appropriately.
# Channel showing when new people connecting DEFAULT_CHANNELS = [
CHANNEL_CONNECTINFO = ("MUDconnections", '', 'Connection log', # public channel
"control:perm(Immortals);listen:perm(Wizards);send:false()") {"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 # External Channel connections