Make scripts/objects lists use EvMore. Change EvMore to not justify by default.

This commit is contained in:
Griatch 2020-01-11 15:49:12 +01:00
parent b5aee2c41e
commit 69d85bd184
221 changed files with 2190 additions and 6810 deletions

View file

@ -188,18 +188,14 @@ class CmdDelCom(COMMAND_DEFAULT_CLASS):
if delnicks:
for nick in [
nick
for nick in make_iter(
caller.nicks.get(category="channel", return_obj=True)
)
for nick in make_iter(caller.nicks.get(category="channel", return_obj=True))
if nick and nick.pk and nick.value[3].lower() == chkey
]:
nick.delete()
disconnect = channel.disconnect(account)
if disconnect:
wipednicks = " Eventual aliases were removed." if delnicks else ""
self.msg(
"You stop listening to channel '%s'.%s" % (channel.key, wipednicks)
)
self.msg("You stop listening to channel '%s'.%s" % (channel.key, wipednicks))
return
else:
# we are removing a channel nick
@ -210,10 +206,7 @@ class CmdDelCom(COMMAND_DEFAULT_CLASS):
else:
if caller.nicks.get(ostring, category="channel"):
caller.nicks.remove(ostring, category="channel")
self.msg(
"Your alias '%s' for channel %s was cleared."
% (ostring, channel.key)
)
self.msg("Your alias '%s' for channel %s was cleared." % (ostring, channel.key))
else:
self.msg("You had no such alias defined for this channel.")
@ -347,9 +340,7 @@ class CmdChannels(COMMAND_DEFAULT_CLASS):
"%s%s"
% (
chan.key,
chan.aliases.all()
and "(%s)" % ",".join(chan.aliases.all())
or "",
chan.aliases.all() and "(%s)" % ",".join(chan.aliases.all()) or "",
),
"%s"
% ",".join(
@ -390,9 +381,7 @@ class CmdChannels(COMMAND_DEFAULT_CLASS):
"%s%s"
% (
chan.key,
chan.aliases.all()
and "(%s)" % ",".join(chan.aliases.all())
or "",
chan.aliases.all() and "(%s)" % ",".join(chan.aliases.all()) or "",
),
"%s"
% ",".join(
@ -444,9 +433,7 @@ class CmdCdestroy(COMMAND_DEFAULT_CLASS):
self.msg("You are not allowed to do that.")
return
channel_key = channel.key
message = (
"%s is being destroyed. Make sure to change your aliases." % channel_key
)
message = "%s is being destroyed. Make sure to change your aliases." % channel_key
msgobj = create.create_message(caller, message, channel)
channel.msg(msgobj)
channel.delete()
@ -507,10 +494,7 @@ class CmdCBoot(COMMAND_DEFAULT_CLASS):
self.msg(string)
return
if not channel.subscriptions.has(account):
string = "Account %s is not connected to channel %s." % (
account.key,
channel.key,
)
string = "Account %s is not connected to channel %s." % (account.key, channel.key)
self.msg(string)
return
if "quiet" not in self.switches:
@ -661,9 +645,7 @@ class CmdChannelCreate(COMMAND_DEFAULT_CLASS):
return
# Create and set the channel up
lockstring = "send:all();listen:all();control:id(%s)" % caller.id
new_chan = create.create_channel(
channame.strip(), aliases, description, locks=lockstring
)
new_chan = create.create_channel(channame.strip(), aliases, description, locks=lockstring)
new_chan.connect(caller)
CHANNELHANDLER.update()
self.msg("Created channel %s and connected to it." % new_chan.key)
@ -795,9 +777,7 @@ class CmdPage(COMMAND_DEFAULT_CLASS):
caller = self.caller
# get the messages we've sent (not to channels)
pages_we_sent = Msg.objects.get_messages_by_sender(
caller, exclude_channel_messages=True
)
pages_we_sent = Msg.objects.get_messages_by_sender(caller, exclude_channel_messages=True)
# get last messages we've got
pages_we_got = Msg.objects.get_messages_by_receiver(caller)
@ -915,10 +895,7 @@ def _list_bots(cmd):
"""
ircbots = [
bot
for bot in AccountDB.objects.filter(
db_is_bot=True, username__startswith="ircbot-"
)
bot for bot in AccountDB.objects.filter(db_is_bot=True, username__startswith="ircbot-")
]
if ircbots:
table = cmd.styled_table(
@ -987,9 +964,7 @@ class CmdIRC2Chan(COMMAND_DEFAULT_CLASS):
"""Setup the irc-channel mapping"""
if not settings.IRC_ENABLED:
string = (
"""IRC is not enabled. You need to activate it in game/settings.py."""
)
string = """IRC is not enabled. You need to activate it in game/settings.py."""
self.msg(string)
return
@ -998,11 +973,7 @@ class CmdIRC2Chan(COMMAND_DEFAULT_CLASS):
self.msg(_list_bots(self))
return
if (
"disconnect" in self.switches
or "remove" in self.switches
or "delete" in self.switches
):
if "disconnect" in self.switches or "remove" in self.switches or "delete" in self.switches:
botname = "ircbot-%s" % self.lhs
matches = AccountDB.objects.filter(db_is_bot=True, username=botname)
dbref = utils.dbref(self.lhs)
@ -1132,9 +1103,7 @@ class CmdIRCStatus(COMMAND_DEFAULT_CLASS):
elif option in ("users", "nicklist", "who"):
# retrieve user list. The bot must handles the echo since it's
# an asynchronous call.
self.caller.msg(
"Requesting nicklist from %s (%s:%s)." % (channel, network, port)
)
self.caller.msg("Requesting nicklist from %s (%s:%s)." % (channel, network, port))
ircbot.get_nicklist(self.caller)
elif self.caller.locks.check_lockstring(
self.caller, "dummy:perm(ircstatus) or perm(Developer)"
@ -1182,9 +1151,7 @@ class CmdRSS2Chan(COMMAND_DEFAULT_CLASS):
# checking we have all we need
if not settings.RSS_ENABLED:
string = (
"""RSS is not enabled. You need to activate it in game/settings.py."""
)
string = """RSS is not enabled. You need to activate it in game/settings.py."""
self.msg(string)
return
try:
@ -1203,9 +1170,7 @@ class CmdRSS2Chan(COMMAND_DEFAULT_CLASS):
# show all connections
rssbots = [
bot
for bot in AccountDB.objects.filter(
db_is_bot=True, username__startswith="rssbot-"
)
for bot in AccountDB.objects.filter(db_is_bot=True, username__startswith="rssbot-")
]
if rssbots:
table = self.styled_table(
@ -1218,28 +1183,19 @@ class CmdRSS2Chan(COMMAND_DEFAULT_CLASS):
)
for rssbot in rssbots:
table.add_row(
rssbot.id,
rssbot.db.rss_rate,
rssbot.db.ev_channel,
rssbot.db.rss_url,
rssbot.id, rssbot.db.rss_rate, rssbot.db.ev_channel, rssbot.db.rss_url
)
self.msg(table)
else:
self.msg("No rss bots found.")
return
if (
"disconnect" in self.switches
or "remove" in self.switches
or "delete" in self.switches
):
if "disconnect" in self.switches or "remove" in self.switches or "delete" in self.switches:
botname = "rssbot-%s" % self.lhs
matches = AccountDB.objects.filter(db_is_bot=True, db_key=botname)
if not matches:
# try dbref match
matches = AccountDB.objects.filter(
db_is_bot=True, id=self.args.lstrip("#")
)
matches = AccountDB.objects.filter(db_is_bot=True, id=self.args.lstrip("#"))
if matches:
matches[0].delete()
self.msg("RSS connection destroyed.")
@ -1321,34 +1277,24 @@ class CmdGrapevine2Chan(COMMAND_DEFAULT_CLASS):
maxwidth=_DEFAULT_WIDTH,
)
for gwbot in gwbots:
table.add_row(
gwbot.id, gwbot.db.ev_channel, gwbot.db.grapevine_channel
)
table.add_row(gwbot.id, gwbot.db.ev_channel, gwbot.db.grapevine_channel)
self.msg(table)
else:
self.msg("No grapevine bots found.")
return
if (
"disconnect" in self.switches
or "remove" in self.switches
or "delete" in self.switches
):
if "disconnect" in self.switches or "remove" in self.switches or "delete" in self.switches:
botname = "grapevinebot-%s" % self.lhs
matches = AccountDB.objects.filter(db_is_bot=True, db_key=botname)
if not matches:
# try dbref match
matches = AccountDB.objects.filter(
db_is_bot=True, id=self.args.lstrip("#")
)
matches = AccountDB.objects.filter(db_is_bot=True, id=self.args.lstrip("#"))
if matches:
matches[0].delete()
self.msg("Grapevine connection destroyed.")
else:
self.msg(
"Grapevine connection/bot could not be removed, does it exist?"
)
self.msg("Grapevine connection/bot could not be removed, does it exist?")
return
if not self.args or not self.rhs:
@ -1371,9 +1317,7 @@ class CmdGrapevine2Chan(COMMAND_DEFAULT_CLASS):
self.msg("Reusing bot '%s' (%s)" % (botname, bot.dbref))
else:
# create a new bot
bot = create.create_account(
botname, None, None, typeclass=bots.GrapevineBot
)
bot = create.create_account(botname, None, None, typeclass=bots.GrapevineBot)
bot.start(ev_channel=channel, grapevine_channel=grapevine_channel)
self.msg(f"Grapevine connection created {channel} <-> {grapevine_channel}.")