random delay

This commit is contained in:
BennyThink 2022-02-05 21:47:12 +08:00
parent 955fe2ad1f
commit 5c792aa0c4
No known key found for this signature in database
GPG key ID: 6CD0DBDA5235D481
2 changed files with 3 additions and 0 deletions

View file

@ -10,6 +10,7 @@ __author__ = "Benny <benny.think@gmail.com>"
import logging
import os
import pathlib
import random
import re
import subprocess
import time
@ -43,6 +44,7 @@ def sizeof_fmt(num: int, suffix='B'):
def edit_text(bot_msg, text):
key = f"{bot_msg.chat.id}-{bot_msg.message_id}"
time.sleep(random.random())
# if the key exists, we shouldn't send edit message
if not r.exists(key):
r.set(key, "ok", ex=3)

View file

@ -246,6 +246,7 @@ def download_handler(client: "Client", message: "types.Message"):
red.update_metrics("video_request")
text = bot_text.get_receive_link_text()
time.sleep(random.random() * 3)
bot_msg: typing.Union["types.Message", "typing.Any"] = message.reply_text(text, quote=True)
client.send_chat_action(chat_id, 'upload_video')
ytdl_download_entrance(bot_msg, client, url)