Make DEFAULT_CHANNELS auto-recreate missing channels. Add new CHANNEL_MUDINFO setting.
This commit is contained in:
parent
dd8b3c1ba2
commit
c520ef86c9
6 changed files with 65 additions and 19 deletions
|
|
@ -16,6 +16,9 @@ without arguments starts a full interactive Python console.
|
||||||
global scripts regardless of how they were created.
|
global scripts regardless of how they were created.
|
||||||
- Change settings to always use lists instead of tuples, to make mutable
|
- Change settings to always use lists instead of tuples, to make mutable
|
||||||
settings easier to add to. (#1912)
|
settings easier to add to. (#1912)
|
||||||
|
- Make new `CHANNEL_MUDINFO` setting for specifying the mudinfo channel
|
||||||
|
- Make `CHANNEL_CONNECTINFO` take full channel definition
|
||||||
|
- Make `DEFAULT_CHANNELS` list auto-create channels missing at reload
|
||||||
|
|
||||||
|
|
||||||
## Evennia 0.9 (2018-2019)
|
## Evennia 0.9 (2018-2019)
|
||||||
|
|
|
||||||
|
|
@ -76,6 +76,12 @@ def check_errors(settings):
|
||||||
if hasattr(settings, "GAME_DIRECTORY_LISTING"):
|
if hasattr(settings, "GAME_DIRECTORY_LISTING"):
|
||||||
raise DeprecationWarning(game_directory_deprecation)
|
raise DeprecationWarning(game_directory_deprecation)
|
||||||
|
|
||||||
|
chan_connectinfo = settings.CHANNEL_CONNECTINFO
|
||||||
|
if chan_connectinfo is not None and not isinstance(chan_connectinfo, dict):
|
||||||
|
raise DeprecationWarning("settings.CHANNEL_CONNECTINFO has changed. It "
|
||||||
|
"must now be either None or a dict "
|
||||||
|
"specifying the properties of the channel to create.")
|
||||||
|
|
||||||
|
|
||||||
def check_warnings(settings):
|
def check_warnings(settings):
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
|
|
@ -124,6 +124,17 @@ def create_channels():
|
||||||
logger.log_info("Initial setup: Creating default channels ...")
|
logger.log_info("Initial setup: Creating default channels ...")
|
||||||
|
|
||||||
goduser = get_god_account()
|
goduser = get_god_account()
|
||||||
|
|
||||||
|
channel_mudinfo = settings.CHANNEL_MUDINFO
|
||||||
|
if not channel_mudinfo:
|
||||||
|
raise RuntimeError("settings.CHANNEL_MUDINFO must be defined.")
|
||||||
|
channel = create.create_channel(**channel_mudinfo)
|
||||||
|
channel.connect(goduser)
|
||||||
|
|
||||||
|
channel_connectinfo = settings.CHANNEL_CONNECTINFO
|
||||||
|
if channel_connectinfo:
|
||||||
|
channel = create.create_channel(**channel_connectinfo)
|
||||||
|
|
||||||
for channeldict in settings.DEFAULT_CHANNELS:
|
for channeldict in settings.DEFAULT_CHANNELS:
|
||||||
channel = create.create_channel(**channeldict)
|
channel = create.create_channel(**channeldict)
|
||||||
channel.connect(goduser)
|
channel.connect(goduser)
|
||||||
|
|
|
||||||
|
|
@ -459,6 +459,30 @@ class Evennia(object):
|
||||||
TASK_HANDLER.load()
|
TASK_HANDLER.load()
|
||||||
TASK_HANDLER.create_delays()
|
TASK_HANDLER.create_delays()
|
||||||
|
|
||||||
|
# check so default channels exist
|
||||||
|
from evennia.comms.models import ChannelDB
|
||||||
|
from evennia.accounts.models import AccountDB
|
||||||
|
from evennia.utils.create import create_channel
|
||||||
|
|
||||||
|
god_account = AccountDB.objects.get(id=1)
|
||||||
|
# mudinfo
|
||||||
|
mudinfo_chan = settings.CHANNEL_MUDINFO
|
||||||
|
if not mudinfo_chan:
|
||||||
|
raise RuntimeError("settings.CHANNEL_MUDINFO must be defined.")
|
||||||
|
if not ChannelDB.objects.filter(db_key=mudinfo_chan['key']):
|
||||||
|
channel = create_channel(**mudinfo_chan)
|
||||||
|
channel.connect(god_account)
|
||||||
|
# connectinfo
|
||||||
|
connectinfo_chan = settings.CHANNEL_MUDINFO
|
||||||
|
if connectinfo_chan:
|
||||||
|
if not ChannelDB.objects.filter(db_key=mudinfo_chan['key']):
|
||||||
|
channel = create_channel(**connectinfo_chan)
|
||||||
|
# default channels
|
||||||
|
for chan_info in settings.DEFAULT_CHANNELS:
|
||||||
|
if not ChannelDB.objects.filter(db_key=chan_info['key']):
|
||||||
|
channel = create_channel(**chan_info)
|
||||||
|
channel.connect(god_account)
|
||||||
|
|
||||||
# delete the temporary setting
|
# delete the temporary setting
|
||||||
ServerConfig.objects.conf("server_restart_mode", delete=True)
|
ServerConfig.objects.conf("server_restart_mode", delete=True)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -304,7 +304,7 @@ class ServerSession(Session):
|
||||||
cchan = channel and settings.CHANNEL_CONNECTINFO
|
cchan = channel and settings.CHANNEL_CONNECTINFO
|
||||||
if cchan:
|
if cchan:
|
||||||
try:
|
try:
|
||||||
cchan = ChannelDB.objects.get_channel(cchan[0])
|
cchan = ChannelDB.objects.get_channel(cchan['key'])
|
||||||
cchan.msg("[%s]: %s" % (cchan.key, message))
|
cchan.msg("[%s]: %s" % (cchan.key, message))
|
||||||
except Exception:
|
except Exception:
|
||||||
logger.log_trace()
|
logger.log_trace()
|
||||||
|
|
|
||||||
|
|
@ -661,30 +661,32 @@ 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
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
||||||
# This is a list of global channels created by the
|
# The mudinfo channel must always exist; it is used by Evennia itself to
|
||||||
# initialization script the first time Evennia starts.
|
# relay status messages, connection info etc to staff. The superuser will be
|
||||||
# The superuser (user #1) will be automatically subscribed
|
# automatically subscribed to this channel and it will be recreated on a
|
||||||
# to all channels in this list. Each channel is described by
|
# reload if deleted. This is a dict specifying the kwargs needed to create
|
||||||
# a dictionary keyed with the same keys valid as arguments
|
# the channel .
|
||||||
# to the evennia.create.create_channel() function.
|
CHANNEL_MUDINFO = {
|
||||||
# Note: Evennia will treat the first channel in this list as
|
"key": "MudInfo",
|
||||||
# the general "public" channel and the second as the
|
"aliases": "",
|
||||||
# general "mud info" channel. Other channels beyond that
|
"desc": "Connection log",
|
||||||
# are up to the admin to design and call appropriately.
|
"locks": "control:perm(Developer);listen:perm(Admin);send:false()"}
|
||||||
|
# These are additional channels to offer. Usually, at least 'public'
|
||||||
|
# should exist. The superuser will automatically be subscribed to all channels
|
||||||
|
# in this list. New entries will be created on the next reload. But
|
||||||
|
# removing or updating a same-key channel from this list will NOT automatically
|
||||||
|
# change/remove it in the game, that needs to be done manually.
|
||||||
DEFAULT_CHANNELS = [
|
DEFAULT_CHANNELS = [
|
||||||
# public channel
|
# public channel
|
||||||
{"key": "Public",
|
{"key": "Public",
|
||||||
"aliases": ('ooc', 'pub'),
|
"aliases": ('pub'),
|
||||||
"desc": "Public discussion",
|
"desc": "Public discussion",
|
||||||
"locks": "control:perm(Admin);listen:all();send:all()"},
|
"locks": "control:perm(Admin);listen:all();send:all()"},
|
||||||
# connection/mud info
|
|
||||||
{"key": "MudInfo",
|
|
||||||
"aliases": "",
|
|
||||||
"desc": "Connection log",
|
|
||||||
"locks": "control:perm(Developer);listen:perm(Admin);send:false()"}
|
|
||||||
]
|
]
|
||||||
# Extra optional channel for receiving connection messages ("<account> has (dis)connected").
|
# Optional channel info (same form as CHANNEL_MUDINFO) for the channel to
|
||||||
# While the MudInfo channel will also receieve this, this channel is meant for non-staffers.
|
# receive connection messages ("<account> has (dis)connected"). While the
|
||||||
|
# MudInfo channel will also receieve this info, this channel is meant for
|
||||||
|
# non-staffers.
|
||||||
CHANNEL_CONNECTINFO = None
|
CHANNEL_CONNECTINFO = None
|
||||||
|
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue