Skip to content

Commit 5b630b7

Browse files
committed
resolve conflicts one more
1 parent b9988e5 commit 5b630b7

8 files changed

Lines changed: 60 additions & 3 deletions

File tree

pyrogram/methods/messages/send_animation.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ async def send_animation(
4848
show_caption_above_media: bool = None,
4949
reply_parameters: "types.ReplyParameters" = None,
5050
schedule_date: datetime = None,
51+
repeat_period: int = None,
5152
protect_content: bool = None,
5253
business_connection_id: str = None,
5354
allow_paid_broadcast: bool = None,
@@ -147,6 +148,9 @@ async def send_animation(
147148
schedule_date (:py:obj:`~datetime.datetime`, *optional*):
148149
Date when the message will be automatically sent.
149150
151+
repeat_period (``int``, *optional*):
152+
Period after which the message will be sent again in seconds.
153+
150154
protect_content (``bool``, *optional*):
151155
Protects the contents of the sent message from forwarding and saving.
152156
@@ -266,6 +270,7 @@ async def progress(current, total):
266270
show_caption_above_media=show_caption_above_media,
267271
reply_parameters=reply_parameters,
268272
schedule_date=schedule_date,
273+
repeat_period=repeat_period,
269274
protect_content=protect_content,
270275
business_connection_id=business_connection_id,
271276
allow_paid_broadcast=allow_paid_broadcast,

pyrogram/methods/messages/send_audio.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ async def send_audio(
4545
effect_id: int = None,
4646
reply_parameters: "types.ReplyParameters" = None,
4747
schedule_date: datetime = None,
48+
repeat_period: int = None,
4849
protect_content: bool = None,
4950
business_connection_id: str = None,
5051
allow_paid_broadcast: bool = None,
@@ -136,6 +137,9 @@ async def send_audio(
136137
schedule_date (:py:obj:`~datetime.datetime`, *optional*):
137138
Date when the message will be automatically sent.
138139
140+
repeat_period (``int``, *optional*):
141+
Period after which the message will be sent again in seconds.
142+
139143
protect_content (``bool``, *optional*):
140144
Protects the contents of the sent message from forwarding and saving.
141145
@@ -232,7 +236,6 @@ async def progress(current, total):
232236
title=title,
233237
)
234238

235-
# Подготавливаем медиа
236239
media, file = await utils.prepare_media_for_upload(
237240
client=self,
238241
file=audio,
@@ -258,6 +261,7 @@ async def progress(current, total):
258261
effect_id=effect_id,
259262
reply_parameters=reply_parameters,
260263
schedule_date=schedule_date,
264+
repeat_period=repeat_period,
261265
protect_content=protect_content,
262266
business_connection_id=business_connection_id,
263267
allow_paid_broadcast=allow_paid_broadcast,

pyrogram/methods/messages/send_document.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ async def send_document(
4242
effect_id: int = None,
4343
reply_parameters: "types.ReplyParameters" = None,
4444
schedule_date: datetime = None,
45+
repeat_period: int = None,
4546
protect_content: bool = None,
4647
business_connection_id: str = None,
4748
allow_paid_broadcast: bool = None,
@@ -127,6 +128,9 @@ async def send_document(
127128
schedule_date (:py:obj:`~datetime.datetime`, *optional*):
128129
Date when the message will be automatically sent.
129130
131+
repeat_period (``int``, *optional*):
132+
Period after which the message will be sent again in seconds.
133+
130134
protect_content (``bool``, *optional*):
131135
Protects the contents of the sent message from forwarding and saving.
132136
@@ -234,6 +238,7 @@ async def progress(current, total):
234238
effect_id=effect_id,
235239
reply_parameters=reply_parameters,
236240
schedule_date=schedule_date,
241+
repeat_period=repeat_period,
237242
protect_content=protect_content,
238243
business_connection_id=business_connection_id,
239244
allow_paid_broadcast=allow_paid_broadcast,

pyrogram/methods/messages/send_photo.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ async def send_photo(
4444
show_caption_above_media: bool = None,
4545
reply_parameters: "types.ReplyParameters" = None,
4646
schedule_date: datetime = None,
47+
repeat_period: int = None,
4748
protect_content: bool = None,
4849
view_once: bool = None,
4950
business_connection_id: str = None,
@@ -126,6 +127,9 @@ async def send_photo(
126127
schedule_date (:py:obj:`~datetime.datetime`, *optional*):
127128
Date when the message will be automatically sent.
128129
130+
repeat_period (``int``, *optional*):
131+
Period after which the message will be sent again in seconds.
132+
129133
protect_content (``bool``, *optional*):
130134
Protects the contents of the sent message from forwarding and saving.
131135
@@ -248,6 +252,7 @@ async def send_photo(
248252
show_caption_above_media=show_caption_above_media,
249253
reply_parameters=reply_parameters,
250254
schedule_date=schedule_date,
255+
repeat_period=repeat_period,
251256
protect_content=protect_content,
252257
business_connection_id=business_connection_id,
253258
allow_paid_broadcast=allow_paid_broadcast,

pyrogram/methods/messages/send_sticker.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ async def send_sticker(
4141
effect_id: int = None,
4242
reply_parameters: "types.ReplyParameters" = None,
4343
schedule_date: datetime = None,
44+
repeat_period: int = None,
4445
protect_content: bool = None,
4546
business_connection_id: str = None,
4647
allow_paid_broadcast: bool = None,
@@ -114,6 +115,9 @@ async def send_sticker(
114115
schedule_date (:py:obj:`~datetime.datetime`, *optional*):
115116
Date when the message will be automatically sent.
116117
118+
repeat_period (``int``, *optional*):
119+
Period after which the message will be sent again in seconds.
120+
117121
protect_content (``bool``, *optional*):
118122
Protects the contents of the sent message from forwarding and saving.
119123
@@ -217,6 +221,7 @@ async def send_sticker(
217221
effect_id=effect_id,
218222
reply_parameters=reply_parameters,
219223
schedule_date=schedule_date,
224+
repeat_period=repeat_period,
220225
protect_content=protect_content,
221226
business_connection_id=business_connection_id,
222227
allow_paid_broadcast=allow_paid_broadcast,

pyrogram/methods/messages/send_video_note.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ async def send_video_note(
4444
effect_id: int = None,
4545
reply_parameters: "types.ReplyParameters" = None,
4646
schedule_date: datetime = None,
47+
repeat_period: int = None,
4748
protect_content: bool = None,
4849
view_once: bool = None,
4950
business_connection_id: str = None,
@@ -122,6 +123,9 @@ async def send_video_note(
122123
schedule_date (:py:obj:`~datetime.datetime`, *optional*):
123124
Date when the message will be automatically sent.
124125
126+
repeat_period (``int``, *optional*):
127+
Period after which the message will be sent again in seconds.
128+
125129
protect_content (``bool``, *optional*):
126130
Protects the contents of the sent message from forwarding and saving.
127131
@@ -231,13 +235,14 @@ async def send_video_note(
231235
client=self,
232236
chat_id=chat_id,
233237
media=media,
234-
caption="", # Video notes don't have captions
238+
caption="",
235239
disable_notification=disable_notification,
236240
message_thread_id=message_thread_id,
237241
direct_messages_topic_id=direct_messages_topic_id,
238242
effect_id=effect_id,
239243
reply_parameters=reply_parameters,
240244
schedule_date=schedule_date,
245+
repeat_period=repeat_period,
241246
protect_content=protect_content,
242247
business_connection_id=business_connection_id,
243248
allow_paid_broadcast=allow_paid_broadcast,

pyrogram/methods/messages/send_voice.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ async def send_voice(
4040
effect_id: int = None,
4141
reply_parameters: "types.ReplyParameters" = None,
4242
schedule_date: datetime = None,
43+
repeat_period: int = None,
4344
protect_content: bool = None,
4445
view_once: bool = None,
4546
business_connection_id: str = None,
@@ -114,6 +115,9 @@ async def send_voice(
114115
schedule_date (:py:obj:`~datetime.datetime`, *optional*):
115116
Date when the message will be automatically sent.
116117
118+
repeat_period (``int``, *optional*):
119+
Period after which the message will be sent again in seconds.
120+
117121
protect_content (``bool``, *optional*):
118122
Protects the contents of the sent message from forwarding and saving.
119123
@@ -232,6 +236,7 @@ async def send_voice(
232236
effect_id=effect_id,
233237
reply_parameters=reply_parameters,
234238
schedule_date=schedule_date,
239+
repeat_period=repeat_period,
235240
protect_content=protect_content,
236241
business_connection_id=business_connection_id,
237242
allow_paid_broadcast=allow_paid_broadcast,

pyrogram/utils.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,22 @@
4040
log = logging.getLogger(__name__)
4141

4242

43+
def get_event_loop() -> asyncio.AbstractEventLoop:
44+
try:
45+
loop = asyncio.get_event_loop()
46+
except RuntimeError:
47+
loop = asyncio.new_event_loop()
48+
asyncio.set_event_loop(loop)
49+
50+
return loop
51+
52+
4353
async def ainput(prompt: str = "", *, hide: bool = False, loop: Optional[asyncio.AbstractEventLoop] = None):
4454
"""Just like the built-in input, but async"""
4555
if isinstance(loop, asyncio.AbstractEventLoop):
4656
loop = loop
4757
else:
48-
loop = asyncio.get_event_loop()
58+
loop = get_event_loop()
4959

5060
with ThreadPoolExecutor(1) as executor:
5161
func = functools.partial(getpass if hide else input, prompt)
@@ -902,6 +912,7 @@ async def send_media(
902912
show_caption_above_media: bool = None,
903913
reply_parameters: "types.ReplyParameters" = None,
904914
schedule_date: datetime = None,
915+
repeat_period: int = None,
905916
protect_content: bool = None,
906917
business_connection_id: str = None,
907918
allow_paid_broadcast: bool = None,
@@ -933,6 +944,7 @@ async def send_media(
933944
),
934945
"random_id": client.rnd_id(),
935946
"schedule_date": datetime_to_timestamp(schedule_date),
947+
"schedule_repeat_period": repeat_period,
936948
"noforwards": protect_content,
937949
"allow_paid_floodskip": allow_paid_broadcast,
938950
"reply_markup": await reply_markup.write(client) if reply_markup else None,
@@ -986,3 +998,14 @@ async def send_media(
986998
)
987999
break
9881000
return message
1001+
1002+
1003+
def get_premium_duration_month_count(day_count: int) -> int:
1004+
return max(1, day_count // 30)
1005+
1006+
1007+
def get_premium_duration_day_count(month_count: int) -> int:
1008+
if month_count <= 0 or month_count > 10000000:
1009+
return 7
1010+
1011+
return month_count * 30 + month_count // 3 + month_count // 12

0 commit comments

Comments
 (0)