Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
loaded = [c.__module__.split(".")[1] for c in self.bot.cogs.values()]
unloaded = [c.split(".")[1] for c in self._list_cogs()
if c.split(".")[1] not in loaded]
if not unloaded:
unloaded = ["None"]
msg = ("+ Active\n"
"{}\n\n"
"- Inactive\n"
"{}"
"".format(", ".join(sorted(loaded)),
", ".join(sorted(unloaded)))
)
for page in pagify(msg, [" "], shorten_by=16):
await self.bot.say(box(page.lstrip(" "), lang="diff"))
async def _show_alias(self, ctx, command):
"""Shows what command the alias executes."""
server = ctx.message.server
if server.id in self.aliases:
server_aliases = self.aliases[server.id]
if command in server_aliases:
await self.bot.say(box(server_aliases[command]))
else:
await self.bot.say("That alias doesn't exist.")
def get_n_trigger_responses(self, trigger, *, truncate=2000):
msg = ""
responses = trigger.responses
i = 0
for r in responses:
if len(r) > truncate:
r = r[:truncate] + "..."
r = r.replace("`", "\\`").replace("*", "\\*").replace("_", "\\_")
msg += "{}. {}\n".format(i, r)
i += 1
if msg != "":
return box(msg, lang="py")
else:
return None
if not self.already_in_list(unique_accounts, acc):
unique_accounts.append(acc)
if len(unique_accounts) < top:
top = len(unique_accounts)
topten = unique_accounts[:top]
highscore = ""
place = 1
for acc in topten:
highscore += str(place).ljust(len(str(top)) + 1)
highscore += ("{} |{}| ".format(acc.member, acc.server)
).ljust(23 - len(str(acc.balance)))
highscore += str(acc.balance) + "\n"
place += 1
if highscore != "":
for page in pagify(highscore, shorten_by=12):
await self.bot.say(box(page, lang="py"))
else:
await self.bot.say("There are no accounts in the bank.")
async def fonts(self):
"""Get list of fonts"""
font_list = await self.get_fonts()
await self.bot.say(chat.box("\n".join([str(x) for x in font_list])))
if i != 0 and i % 4 == 0:
last = await self.bot.say("There are still {} messages. "
"Type `more` to continue."
"".format(len(result) - (i+1)))
msg = await self.bot.wait_for_message(author=author,
channel=channel,
check=check,
timeout=10)
if msg is None:
try:
await self.bot.delete_message(last)
except:
pass
finally:
break
await self.bot.say(box(page, lang="py"))
roles = self.bot.settings.get_server(server).copy()
_settings = {**self.settings[server.id], **roles}
if "respect_hierarchy" not in _settings:
_settings["respect_hierarchy"] = default_settings["respect_hierarchy"]
if "delete_delay" not in _settings:
_settings["delete_delay"] = "Disabled"
msg = ("Admin role: {ADMIN_ROLE}\n"
"Mod role: {MOD_ROLE}\n"
"Mod-log: {mod-log}\n"
"Delete repeats: {delete_repeats}\n"
"Ban mention spam: {ban_mention_spam}\n"
"Delete delay: {delete_delay}\n"
"Respects hierarchy: {respect_hierarchy}"
"".format(**_settings))
await self.bot.say(box(msg))
async def triviaset(self, ctx):
"""Change trivia settings"""
server = ctx.message.server
if ctx.invoked_subcommand is None:
settings = self.settings[server.id]
msg = box("Red gains points: {BOT_PLAYS}\n"
"Seconds to answer: {DELAY}\n"
"Points to win: {MAX_SCORE}\n"
"Reveal answer on timeout: {REVEAL_ANSWER}\n"
"".format(**settings))
msg += "\nSee {}help triviaset to edit the settings".format(ctx.prefix)
await self.bot.say(msg)
async def send_table(self):
t = "+ Results: \n\n"
for user, score in self.scores.most_common():
t += "+ {}\t{}\n".format(user, score)
await self.bot.say(box(t, lang="diff"))
code = code.strip('` ')
result = None
global_vars = globals().copy()
global_vars['bot'] = self.bot
global_vars['ctx'] = ctx
global_vars['message'] = ctx.message
global_vars['author'] = ctx.message.author
global_vars['channel'] = ctx.message.channel
global_vars['server'] = ctx.message.server
try:
result = eval(code, global_vars, locals())
except Exception as e:
await self.bot.say(box('{}: {}'.format(type(e).__name__, str(e)),
lang="py"))
return
if asyncio.iscoroutine(result):
result = await result
result = str(result)
if not ctx.message.channel.is_private:
censor = (self.bot.settings.email,
self.bot.settings.password,
self.bot.settings.token)
r = "[EXPUNGED]"
for w in censor:
if w is None or w == "":
continue