Skip to content
This repository was archived by the owner on Mar 11, 2022. It is now read-only.

Commit 8a19a26

Browse files
authored
Update bot.py
1 parent 36a1d55 commit 8a19a26

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

bot.py

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717

1818
# MY_NICKS = {"secura": "Some Nick",
1919
# "suna": "Another Nick"}
20+
21+
# If you have the same nick in all servers:
22+
# MY_NICKS = defaultdict(lambda: "Your Nick")
23+
2024
MY_NICKS = get_nick_and_pw("all")
2125

2226

@@ -460,7 +464,7 @@ async def Login(ctx, *, nick):
460464
server = ctx.channel.name
461465
if nick.lower() == MY_NICKS[server].lower():
462466
session = sessions[server]
463-
sessions[server] = login.login(server, session)
467+
sessions[server] = login.login(server)
464468

465469
@bot.command()
466470
async def shutdown(ctx, *, nick):
@@ -477,9 +481,23 @@ async def on_message(message):
477481
f = StringIO()
478482
with redirect_stdout(f):
479483
await bot.invoke(ctx)
480-
output = f.getvalue()
481-
if output:
484+
output = f.getvalue()
485+
486+
if "notLoggedIn" in output:
487+
f = StringIO()
488+
login.login(ctx.channel.name)
489+
with redirect_stdout(f):
490+
await bot.invoke(ctx)
491+
output = f.getvalue()
492+
493+
if len(output) > 100 or "http" in output:
494+
embed = discord.Embed()
495+
embed.add_field(name=os.environ['nick'], value=output[:1000])
496+
if output[1000:]:
497+
embed.add_field(name="Page 2", value=output[1000:2000])
482498
# Sending the output (all prints) to your channel.
499+
await ctx.send(embed=embed)
500+
else:
483501
await ctx.send(output[:2000])
484502
f.close()
485503

0 commit comments

Comments
 (0)