Skip to content

Commit 46ff19f

Browse files
author
Paul Philion
committed
fixing team display
1 parent 289d464 commit 46ff19f

File tree

2 files changed

+22
-18
lines changed

2 files changed

+22
-18
lines changed

netbot/cog_scn.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -304,14 +304,13 @@ async def teams(self, ctx:discord.ApplicationContext, teamname:str=None):
304304
await ctx.respond(self.formatter.format_team(ctx, team))
305305
return
306306
else:
307-
all_teams = [team.name for team in ctx.guild.roles]
307+
all_teams = ", ".join([team.name for team in ctx.guild.roles if team.name.endswith("-team")])
308308
await ctx.respond(f"Unknown team name: {teamname}\nTeams: {all_teams}") # error
309309
else:
310310
# all teams
311-
#teams = "\n- ".join([team.name for team in ctx.guild.roles])
312311
buff = ""
313312
for team in ctx.guild.roles:
314-
buff += self.formatter.format_team(ctx, team)
313+
buff += self.formatter.format_team(ctx, team, inc_users=False)
315314
await ctx.respond(buff)
316315

317316

@@ -330,6 +329,7 @@ async def epics(self, ctx:discord.ApplicationContext):
330329
# format the epics and respond
331330
await ctx.respond(embeds=self.bot.formatter.epics_embed(ctx, epics))
332331

332+
333333
@scn.command(description="list blocked email")
334334
async def blocked(self, ctx:discord.ApplicationContext):
335335
team = self.redmine.user_mgr.cache.get_team_by_name(BLOCKED_TEAM_NAME)

netbot/formatting.py

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -526,22 +526,23 @@ def help_embed(self, _: discord.ApplicationContext) -> discord.Embed:
526526
return embed
527527

528528

529-
async def print_team(self, ctx, team):
530-
msg = f"> **{team.name}**\n"
531-
for user_rec in team.users:
532-
#user = self.redmine.get_user(user_rec.id)
533-
#discord_user = user.custom_fields[0].value or "" # FIXME cf_* lookup
534-
msg += f"{user_rec.name}, "
535-
#msg += f"[{user.id}] **{user_rec.name}** {user.login} {user.mail} {user.custom_fields[0].value}\n"
536-
msg = msg[:-2] + '\n\n'
537-
await ctx.channel.send(msg)
538-
539-
540-
def format_team(self, ctx: discord.ApplicationContext, team: discord.Role) -> str:
529+
# async def print_team(self, ctx, team):
530+
# msg = f"> **{team.name}**\n"
531+
# for user_rec in team.users:
532+
# #user = self.redmine.get_user(user_rec.id)
533+
# #discord_user = user.custom_fields[0].value or "" # FIXME cf_* lookup
534+
# msg += f"{user_rec.name}, "
535+
# #msg += f"[{user.id}] **{user_rec.name}** {user.login} {user.mail} {user.custom_fields[0].value}\n"
536+
# msg = msg[:-2] + '\n\n'
537+
# await ctx.channel.send(msg)
538+
539+
540+
def format_team(self, ctx: discord.ApplicationContext, team: discord.Role, inc_users:bool = True) -> str:
541541
# single line format: teamname: member1, member2
542-
skip_teams = ["blocked", "users", "@everyone", ctx.me.name]
542+
#skip_teams = ["blocked", "users", "@everyone", ctx.me.name]
543+
team_postfix = "-team"
543544

544-
if team and team.name not in skip_teams:
545+
if team and team.name.endswith(team_postfix):
545546
team_channel = ctx.bot.channel_for_team(team.name)
546547
if team_channel:
547548
is_private = False
@@ -554,6 +555,9 @@ def format_team(self, ctx: discord.ApplicationContext, team: discord.Role) -> st
554555
else:
555556
team_name = "**" + team.name + "**"
556557

557-
return f"{team_name}: {', '.join([user.display_name for user in team.members])}\n"
558+
if inc_users:
559+
return f"{team_name}: {', '.join([user.display_name for user in team.members])}\n"
560+
else:
561+
return f"- {team_name}\n"
558562
else:
559563
return ""

0 commit comments

Comments
 (0)