mirror of
https://github.com/Mayuri-Chan/pyrofork.git
synced 2025-12-29 12:04:51 +00:00
pyrofork: Refactor GiveawayResult
Some checks are pending
Build-docs / build (push) Waiting to run
Pyrofork / build (macos-latest, 3.10) (push) Waiting to run
Pyrofork / build (macos-latest, 3.11) (push) Waiting to run
Pyrofork / build (macos-latest, 3.12) (push) Waiting to run
Pyrofork / build (macos-latest, 3.13) (push) Waiting to run
Pyrofork / build (macos-latest, 3.9) (push) Waiting to run
Pyrofork / build (ubuntu-latest, 3.10) (push) Waiting to run
Pyrofork / build (ubuntu-latest, 3.11) (push) Waiting to run
Pyrofork / build (ubuntu-latest, 3.12) (push) Waiting to run
Pyrofork / build (ubuntu-latest, 3.13) (push) Waiting to run
Pyrofork / build (ubuntu-latest, 3.9) (push) Waiting to run
Some checks are pending
Build-docs / build (push) Waiting to run
Pyrofork / build (macos-latest, 3.10) (push) Waiting to run
Pyrofork / build (macos-latest, 3.11) (push) Waiting to run
Pyrofork / build (macos-latest, 3.12) (push) Waiting to run
Pyrofork / build (macos-latest, 3.13) (push) Waiting to run
Pyrofork / build (macos-latest, 3.9) (push) Waiting to run
Pyrofork / build (ubuntu-latest, 3.10) (push) Waiting to run
Pyrofork / build (ubuntu-latest, 3.11) (push) Waiting to run
Pyrofork / build (ubuntu-latest, 3.12) (push) Waiting to run
Pyrofork / build (ubuntu-latest, 3.13) (push) Waiting to run
Pyrofork / build (ubuntu-latest, 3.9) (push) Waiting to run
Signed-off-by: wulan17 <wulan17@nusantararom.org>
This commit is contained in:
parent
af228e50c7
commit
2343c68264
3 changed files with 7 additions and 10 deletions
|
|
@ -221,7 +221,7 @@ class ExternalReplyInfo(Object):
|
||||||
giveaway = types.Giveaway._parse(client, reply, chats)
|
giveaway = types.Giveaway._parse(client, reply, chats)
|
||||||
media_type = enums.MessageMediaType.GIVEAWAY
|
media_type = enums.MessageMediaType.GIVEAWAY
|
||||||
elif isinstance(media, raw.types.MessageMediaGiveawayResults):
|
elif isinstance(media, raw.types.MessageMediaGiveawayResults):
|
||||||
giveaway_winners = await types.GiveawayResult._parse(client, media)
|
giveaway_winners = await types.GiveawayResult._parse(client, media, users, chats)
|
||||||
media_type = enums.MessageMediaType.GIVEAWAY_RESULT
|
media_type = enums.MessageMediaType.GIVEAWAY_RESULT
|
||||||
elif isinstance(media, raw.types.MessageMediaInvoice):
|
elif isinstance(media, raw.types.MessageMediaInvoice):
|
||||||
invoice = types.Invoice._parse(media)
|
invoice = types.Invoice._parse(media)
|
||||||
|
|
|
||||||
|
|
@ -104,7 +104,9 @@ class GiveawayResult(Object):
|
||||||
"raw.types.MessageActionGiveawayResults",
|
"raw.types.MessageActionGiveawayResults",
|
||||||
"raw.types.MessageMediaGiveawayResults"
|
"raw.types.MessageMediaGiveawayResults"
|
||||||
],
|
],
|
||||||
hide_winners: bool = False
|
hide_winners: bool = False,
|
||||||
|
users: dict = None,
|
||||||
|
chats: dict = None
|
||||||
) -> "GiveawayResult":
|
) -> "GiveawayResult":
|
||||||
chat = None
|
chat = None
|
||||||
giveaway_message = None
|
giveaway_message = None
|
||||||
|
|
@ -112,17 +114,12 @@ class GiveawayResult(Object):
|
||||||
winners = None
|
winners = None
|
||||||
if not hide_winners:
|
if not hide_winners:
|
||||||
chat_id = utils.get_channel_id(giveaway_result.channel_id)
|
chat_id = utils.get_channel_id(giveaway_result.channel_id)
|
||||||
chat = await client.invoke(
|
chat = types.Chat._parse_channel_chat(client, chats.get(giveaway_result.channel_id))
|
||||||
raw.functions.channels.GetChannels(
|
|
||||||
id=[await client.resolve_peer(chat_id)]
|
|
||||||
)
|
|
||||||
)
|
|
||||||
chat = types.Chat._parse_chat(client, chat.chats[0])
|
|
||||||
giveaway_message = await client.get_messages(chat_id, giveaway_result.launch_msg_id)
|
giveaway_message = await client.get_messages(chat_id, giveaway_result.launch_msg_id)
|
||||||
expired_date = utils.timestamp_to_datetime(giveaway_result.until_date)
|
expired_date = utils.timestamp_to_datetime(giveaway_result.until_date)
|
||||||
winners = []
|
winners = []
|
||||||
for winner in giveaway_result.winners:
|
for winner in giveaway_result.winners:
|
||||||
winners.append(await client.get_users(winner))
|
winners.append(types.User._parse(client, users.get(winner, None)))
|
||||||
|
|
||||||
stars = getattr(giveaway_result, "stars", None)
|
stars = getattr(giveaway_result, "stars", None)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1042,7 +1042,7 @@ class Message(Object, Update):
|
||||||
giveaway = await types.Giveaway._parse(client, message, chats)
|
giveaway = await types.Giveaway._parse(client, message, chats)
|
||||||
media_type = enums.MessageMediaType.GIVEAWAY
|
media_type = enums.MessageMediaType.GIVEAWAY
|
||||||
elif isinstance(media, raw.types.MessageMediaGiveawayResults):
|
elif isinstance(media, raw.types.MessageMediaGiveawayResults):
|
||||||
giveaway_result = await types.GiveawayResult._parse(client, message.media)
|
giveaway_result = await types.GiveawayResult._parse(client, message.media, users, chats)
|
||||||
media_type = enums.MessageMediaType.GIVEAWAY_RESULT
|
media_type = enums.MessageMediaType.GIVEAWAY_RESULT
|
||||||
elif isinstance(media, raw.types.MessageMediaStory):
|
elif isinstance(media, raw.types.MessageMediaStory):
|
||||||
story = await types.MessageStory._parse(client, media)
|
story = await types.MessageStory._parse(client, media)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue