-
Notifications
You must be signed in to change notification settings - Fork 29
/
load_speed.py
43 lines (38 loc) · 1.51 KB
/
load_speed.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# This module aimes to provide a response for common question about load speeds.
import re
from telethon import TelegramClient, custom, events
from telethon.extensions import markdown
RESPONSE = (
"If you want to increase up/down speed, you can install `cryptg` via pip.\n"
"This module aims to provide a better encryption/decryption algorithm for Telegram clients.\n"
"If you want to increase speed even further, you can use "
"[this snippet](https://gist.github.com/painor/7e74de80ae0c819d3e9abcf9989a8dd6)\n"
"Be cautious while using it, "
"because it can lead to `FloodWait` error, as it uses multiple simultaneous connections."
)
def init(bot: TelegramClient):
@bot.on(
events.NewMessage(
pattern=re.compile(
r".*((speed|slow|fast).*(up|down)load|(up|down)load.*(speed|slow|fast)).*",
flags=re.DOTALL | re.IGNORECASE,
),
forwards=False,
outgoing=False,
)
)
async def handler(event):
"""Respond to messages like 'speed up my downloads'"""
await event.reply(RESPONSE, link_preview=False)
@bot.on(
events.NewMessage(
pattern=re.compile(
r"#(speed|upload|download)", flags=re.IGNORECASE
),
forwards=False,
)
)
async def handler(event):
"""Respond to messages like '#speed'"""
await event.delete()
await event.respond(RESPONSE, reply_to=event.message.reply_to_msg_id, link_preview=False)