Skip to content

Commit a22036d

Browse files
fix: adjust method formatting and add dynamic attribute access
Corrected indentation for method definitions to align with coding standards. Introduced a `__getattr__` method for dynamic attribute access, improving flexibility when interacting with the `calls` attribute. This ensures better error handling and forwards attribute requests to the first call in the list when applicable.
1 parent e19bc54 commit a22036d

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed

WinxMusic/core/call.py

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,11 @@ async def force_stop_stream(self, chat_id: int):
110110
pass
111111

112112
async def skip_stream(
113-
self,
114-
chat_id: int,
115-
link: str,
116-
video: Union[bool, str] = None,
117-
image: Union[bool, str] = None,
113+
self,
114+
chat_id: int,
115+
link: str,
116+
video: Union[bool, str] = None,
117+
image: Union[bool, str] = None,
118118
):
119119
assistant = await group_assistant(self, chat_id)
120120
audio_stream_quality = await get_audio_bitrate(chat_id)
@@ -250,12 +250,12 @@ async def join_chat(self, chat_id, attempts=1):
250250
raise AssistantErr(_["call_3"].format(type(e).__name__))
251251

252252
async def join_call(
253-
self,
254-
chat_id: int,
255-
original_chat_id: int,
256-
link,
257-
video: Union[bool, str] = None,
258-
image: Union[bool, str] = None,
253+
self,
254+
chat_id: int,
255+
original_chat_id: int,
256+
link,
257+
video: Union[bool, str] = None,
258+
image: Union[bool, str] = None,
259259
):
260260
assistant = await group_assistant(self, chat_id)
261261
audio_stream_quality = await get_audio_bitrate(chat_id)
@@ -623,5 +623,13 @@ async def stream_end_handler(client, update: Update):
623623
return
624624
await self.change_stream(client, update.chat_id)
625625

626+
def __getattr__(self, name):
627+
if not self.calls:
628+
raise AttributeError(f"'{type(self).__name__}' object has no attribute '{name}'")
629+
first_call = self.calls[0]
630+
if hasattr(first_call, name):
631+
return getattr(first_call, name)
632+
raise AttributeError(f"'{type(first_call).__name__}' object has no attribute '{name}'")
633+
626634

627635
Winx = Call()

0 commit comments

Comments
 (0)