Fixed missing variable in formatting of disconnect string in delcom, made display of @channels more legible and display when someone is Muted rather than not subscribed. Refactored the 'who' list for channels to now be a property of the channel that returns a string of all the subscribers separated by commas, with those who are actively listening (not muted) in bold, and made both '@cwho' and 'allcom who' call to it.
This commit is contained in:
parent
951cd60a6d
commit
c32920999b
2 changed files with 23 additions and 14 deletions
|
|
@ -176,7 +176,7 @@ class CmdDelCom(COMMAND_DEFAULT_CLASS):
|
||||||
disconnect = channel.disconnect(player)
|
disconnect = channel.disconnect(player)
|
||||||
if disconnect:
|
if disconnect:
|
||||||
wipednicks = " Eventual aliases were removed." if delnicks else ""
|
wipednicks = " Eventual aliases were removed." if delnicks else ""
|
||||||
self.msg("You stop listening to channel '%s'.%s" % channel.key)
|
self.msg("You stop listening to channel '%s'.%s" % (channel.key, wipednicks))
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
# we are removing a channel nick
|
# we are removing a channel nick
|
||||||
|
|
@ -249,12 +249,7 @@ class CmdAllCom(COMMAND_DEFAULT_CLASS):
|
||||||
if not channels:
|
if not channels:
|
||||||
string += "No channels."
|
string += "No channels."
|
||||||
for channel in channels:
|
for channel in channels:
|
||||||
string += "\n{w%s:{n\n" % channel.key
|
string += "\n{w%s:{n\n %s" % (channel.key, channel.wholist)
|
||||||
subs = channel.db_subscriptions.all()
|
|
||||||
if subs:
|
|
||||||
string += " " + ", ".join([player.key for player in subs])
|
|
||||||
else:
|
|
||||||
string += " <None>"
|
|
||||||
self.msg(string.strip())
|
self.msg(string.strip())
|
||||||
else:
|
else:
|
||||||
# wrong input
|
# wrong input
|
||||||
|
|
@ -317,13 +312,21 @@ class CmdChannels(COMMAND_DEFAULT_CLASS):
|
||||||
clower = chan.key.lower()
|
clower = chan.key.lower()
|
||||||
nicks = caller.nicks.get(category="channel", return_obj=True)
|
nicks = caller.nicks.get(category="channel", return_obj=True)
|
||||||
nicks = nicks or []
|
nicks = nicks or []
|
||||||
comtable.add_row(*[chan in subs and "{gYes{n" or "{rNo{n",
|
if chan not in subs:
|
||||||
|
substatus = "{rNo{n"
|
||||||
|
elif caller in chan.mutelist:
|
||||||
|
substatus = "{rMuted{n"
|
||||||
|
else:
|
||||||
|
substatus = "{gYes{n"
|
||||||
|
comtable.add_row(*[substatus,
|
||||||
"%s%s" % (chan.key, chan.aliases.all() and
|
"%s%s" % (chan.key, chan.aliases.all() and
|
||||||
"(%s)" % ",".join(chan.aliases.all()) or ""),
|
"(%s)" % ",".join(chan.aliases.all()) or ""),
|
||||||
"%s" % ",".join(nick.db_key for nick in make_iter(nicks)
|
"%s" % ",".join(nick.db_key for nick in make_iter(nicks)
|
||||||
if nick.value[3].lower() == clower),
|
if nick.value[3].lower() == clower),
|
||||||
str(chan.locks),
|
str(chan.locks),
|
||||||
chan.db.desc])
|
chan.db.desc])
|
||||||
|
comtable.reformat_column(0, width=9)
|
||||||
|
comtable.reformat_column(3, width=14)
|
||||||
caller.msg("\n{wAvailable channels{n (use {wcomlist{n,{waddcom{n and {wdelcom{n to manage subscriptions):\n%s" % comtable)
|
caller.msg("\n{wAvailable channels{n (use {wcomlist{n,{waddcom{n and {wdelcom{n to manage subscriptions):\n%s" % comtable)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -511,12 +514,7 @@ class CmdCWho(COMMAND_DEFAULT_CLASS):
|
||||||
self.msg(string)
|
self.msg(string)
|
||||||
return
|
return
|
||||||
string = "\n{CChannel subscriptions{n"
|
string = "\n{CChannel subscriptions{n"
|
||||||
string += "\n{w%s:{n\n" % channel.key
|
string += "\n{w%s:{n\n %s" % (channel.key, channel.wholist)
|
||||||
subs = channel.db_subscriptions.all()
|
|
||||||
if subs:
|
|
||||||
string += " " + ", ".join([player.key for player in subs])
|
|
||||||
else:
|
|
||||||
string += " <None>"
|
|
||||||
self.msg(string.strip())
|
self.msg(string.strip())
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -83,6 +83,17 @@ class DefaultChannel(with_metaclass(TypeclassBase, ChannelDB)):
|
||||||
def mutelist(self):
|
def mutelist(self):
|
||||||
return self.db.mute_list or []
|
return self.db.mute_list or []
|
||||||
|
|
||||||
|
@property
|
||||||
|
def wholist(self):
|
||||||
|
subs = self.db_subscriptions.all()
|
||||||
|
listening = [ob for ob in subs if ob.is_connected and ob not in self.mutelist]
|
||||||
|
if subs:
|
||||||
|
# display listening subscribers in bold
|
||||||
|
string = ", ".join([player.key if player not in listening else "{w%s{n" % player.key for player in subs])
|
||||||
|
else:
|
||||||
|
string = "<None>"
|
||||||
|
return string
|
||||||
|
|
||||||
def mute(self, subscriber):
|
def mute(self, subscriber):
|
||||||
"""
|
"""
|
||||||
Adds an entity to the list of muted subscribers.
|
Adds an entity to the list of muted subscribers.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue