|
20 | 20 | from utils import errors, fmt, guards |
21 | 21 |
|
22 | 22 | from .enums import LobbyParam0, ScoreCategory, Status |
23 | | -from .tools import SteamUserConverter, extract_hero_index, is_allowed_to_add_notable, rank_medal_display_name |
| 23 | +from .tools import ( |
| 24 | + PARTY_MEMBERS_PATTERN, |
| 25 | + SteamUserConverter, |
| 26 | + extract_hero_index, |
| 27 | + is_allowed_to_add_notable, |
| 28 | + rank_medal_display_name, |
| 29 | +) |
24 | 30 |
|
25 | 31 | if TYPE_CHECKING: |
26 | 32 | from collections.abc import Callable, Coroutine |
@@ -1193,6 +1199,32 @@ async def process_pending_abandons(self) -> None: |
1193 | 1199 | # FRIEND PROFILE COMMANDS # |
1194 | 1200 | ################################# |
1195 | 1201 |
|
| 1202 | + @commands.command() |
| 1203 | + async def party(self, ctx: IreContext) -> None: |
| 1204 | + """Show notable players in the current party.""" |
| 1205 | + friend = await self.find_friend_account(ctx.broadcaster.id) |
| 1206 | + party = friend.rich_presence.raw.get("party") |
| 1207 | + if party is None: |
| 1208 | + msg = "Streamer is not in a party." |
| 1209 | + await ctx.send(msg) |
| 1210 | + return |
| 1211 | + |
| 1212 | + steam32_ids = [m.id for m in map(steam.ID, PARTY_MEMBERS_PATTERN.findall(party))] |
| 1213 | + |
| 1214 | + query = """ |
| 1215 | + SELECT nickname, friend_id |
| 1216 | + FROM ttv_dota_notable_players |
| 1217 | + WHERE friend_id = ANY($1); |
| 1218 | + """ |
| 1219 | + rows = await self.bot.pool.fetch(query, steam32_ids) |
| 1220 | + nickname_mapping = {row["friend_id"]: row["nickname"] for row in rows} |
| 1221 | + |
| 1222 | + known_party_members = " \N{BULLET} ".join(nickname_mapping.values()) |
| 1223 | + unknown_party_members = " \N{BULLET} ".join(str(id_) for id_ in steam32_ids if id_ not in nickname_mapping) |
| 1224 | + |
| 1225 | + response = f"{known_party_members} | Unknown party members: {unknown_party_members}" |
| 1226 | + await ctx.send(response) |
| 1227 | + |
1196 | 1228 | async def score_response_helper(self, broadcaster_id: str, stream_started_at: datetime.datetime | None = None) -> str: |
1197 | 1229 | """Helper function to get !wl commands response.""" |
1198 | 1230 | clause = "AND m.start_time > $2" if stream_started_at else "" |
|
0 commit comments