1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-23 19:44:20 +00:00

Add full /cv

This commit is contained in:
Steffo 2018-12-29 01:26:30 +01:00
parent 4b4a7754a1
commit 5ff11f2a98
2 changed files with 13 additions and 9 deletions

View file

@ -428,6 +428,9 @@ class RoyalDiscordBot(discord.Client):
"!cv": self.cmd_cv,
"!summon": self.cmd_cv,
"!play": self.cmd_play,
"!alexaplay": self.cmd_play,
"!okgoogleplay": self.cmd_play,
"!heysiriplay": self.cmd_play,
"!p": self.cmd_play,
"!search": self.cmd_play,
"!file": self.cmd_play,
@ -576,7 +579,8 @@ class RoyalDiscordBot(discord.Client):
while True:
msg = await loop.run_in_executor(executor, connection.recv)
logger.debug(f"Received from the Telegram-Discord pipe: {msg}")
if msg == "get cv":
full_cv = (msg == "get cv full")
if msg.startswith("get cv"):
discord_members = list(self.main_guild.members)
channels = {0: None}
members_in_channels = {0: []}
@ -601,7 +605,7 @@ class RoyalDiscordBot(discord.Client):
message += f"<b>In #{escape(channels[channel].name)}:</b>\n"
for member in members_in_channels[channel]:
# Ignore not-connected non-notable members
if channel == 0 and len(member.roles) < 2:
if not full_cv and channel == 0 and len(member.roles) < 2:
continue
# Ignore offline members
if member.status == discord.Status.offline and member.voice is None:
@ -638,13 +642,9 @@ class RoyalDiscordBot(discord.Client):
# Rich presence
try:
if member.activity.state is not None:
message += f" ({escape(member.activity.state)})"
message += f" ({escape(member.activity.state} | {member.activity.details)})"
except AttributeError:
try:
if member.activity.details is not None:
message += f" ({escape(member.activity.details)})"
except AttributeError:
pass
message += f" (⚠️)"
elif member.activity.type == discord.ActivityType.streaming:
message += f" | 📡 [{escape(member.activity.name)}]({escape(member.activity.url)})"
elif member.activity.type == discord.ActivityType.listening:

View file

@ -107,7 +107,11 @@ def cmd_discord(bot: Bot, update: Update):
if discord_connection is None:
bot.send_message(update.message.chat.id, "⚠ Il bot non è collegato a Discord al momento.")
return
discord_connection.send("get cv")
# dirty hack as usual
if update.message.text.endswith("full"):
discord_connection.send("get cv full")
else:
discord_connection.send("get cv")
message = discord_connection.recv()
bot.send_message(update.message.chat.id, message, disable_web_page_preview=True, parse_mode="HTML")