Update the comm system to work with the new nicks.

This commit is contained in:
Griatch 2016-06-26 01:20:24 +02:00
parent fba6e079c1
commit 316f03308e
2 changed files with 12 additions and 5 deletions

View file

@ -163,7 +163,7 @@ class CmdDelCom(COMMAND_DEFAULT_CLASS):
chkey = channel.key.lower()
# find all nicks linked to this channel and delete them
for nick in [nick for nick in make_iter(caller.nicks.get(category="channel", return_obj=True))
if nick and nick.strvalue.lower() == chkey]:
if nick and nick.value[3].lower() == chkey]:
nick.delete()
disconnect = channel.disconnect(player)
if disconnect:
@ -297,7 +297,7 @@ class CmdChannels(COMMAND_DEFAULT_CLASS):
comtable.add_row(*["%s%s" % (chan.key, chan.aliases.all() and
"(%s)" % ",".join(chan.aliases.all()) or ""),
"%s" % ",".join(nick.db_key for nick in make_iter(nicks)
if nick and nick.strvalue.lower() == clower),
if nick and nick.value[3].lower() == clower),
chan.db.desc])
caller.msg("\n{wChannel subscriptions{n (use {w@channels{n to list all, {waddcom{n/{wdelcom{n to sub/unsub):{n\n%s" % comtable)
else:
@ -312,7 +312,7 @@ class CmdChannels(COMMAND_DEFAULT_CLASS):
"%s%s" % (chan.key, chan.aliases.all() and
"(%s)" % ",".join(chan.aliases.all()) or ""),
"%s" % ",".join(nick.db_key for nick in make_iter(nicks)
if nick.strvalue.lower() == clower),
if nick.value[3].lower() == clower),
str(chan.locks),
chan.db.desc])
caller.msg("\n{wAvailable channels{n (use {wcomlist{n,{waddcom{n and {wdelcom{n to manage subscriptions):\n%s" % comtable)

View file

@ -660,7 +660,7 @@ class NickHandler(AttributeHandler):
"""
return super(NickHandler, self).has(key, category=category)
def get(self, key=None, category="inputline", **kwargs):
def get(self, key=None, category="inputline", return_tuple=False, **kwargs):
"""
Get the replacement value matching the given key and category
@ -671,10 +671,17 @@ class NickHandler(AttributeHandler):
category (str, optional): the category within which to
retrieve the nick. The "inputline" means replacing data
sent by the user.
return_tuple (bool, optional): return the full nick tuple rather
than just the replacement. For non-template nicks this is just
a string.
kwargs (any, optional): These are passed on to `AttributeHandler.get`.
"""
return super(NickHandler, self).get(key=key, category=category, **kwargs)
if return_tuple or "return_obj" in kwargs:
return super(NickHandler, self).get(key=key, category=category, **kwargs)
else:
retval = super(NickHandler, self).get(key=key, category=category, **kwargs)
return retval[3] if isinstance(retval, tuple) else [tup[3] for tup in make_iter(retval)]
def add(self, key, replacement, category="inputline", **kwargs):
"""