mirror of
https://github.com/tgbot-collection/ytdlbot.git
synced 2024-11-10 09:12:45 +08:00
Fix ping
command by separating detailed output into a new stats
command; ping
now displays only the ping result. (#398)
* rewrote spdl to feel more integrated and add support for terabox.com links * small typo fix and terabox link extraction improvement * another tweak to improve terabox link extraction * Update sp_downloader.py Add progress bar to spdl Instagram downloads * improvement on instagram download to show filename while downloading * reformat * Fix `ping` command by separating detailed output into a new `stats` command
This commit is contained in:
parent
2e458231e9
commit
d1e702f111
2 changed files with 28 additions and 3 deletions
|
@ -294,18 +294,19 @@ refer guide here [kubernetes](k8s.md)
|
|||
```
|
||||
start - Let's start
|
||||
about - What's this bot?
|
||||
ping - Bot running status
|
||||
help - Help
|
||||
spdl - Use to download specific link downloader links
|
||||
ytdl - Download video in group
|
||||
direct - Download file directly
|
||||
settings - Set your preference
|
||||
buy - Buy token
|
||||
direct - Download file directly
|
||||
sub - Subscribe to YouTube Channel
|
||||
unsub - Unsubscribe from YouTube Channel
|
||||
sub_count - Check subscription status, owner only.
|
||||
uncache - Delete cache for this link, owner only.
|
||||
purge - Delete all tasks, owner only.
|
||||
ping - Ping the Bot
|
||||
stats - Bot running status
|
||||
show_history - Show download history
|
||||
clear_history - Clear download history
|
||||
```
|
||||
|
|
|
@ -11,6 +11,7 @@ import contextlib
|
|||
import json
|
||||
import logging
|
||||
import os
|
||||
import threading
|
||||
import random
|
||||
import re
|
||||
import tempfile
|
||||
|
@ -201,11 +202,34 @@ def purge_handler(client: Client, message: types.Message):
|
|||
|
||||
@app.on_message(filters.command(["ping"]))
|
||||
def ping_handler(client: Client, message: types.Message):
|
||||
redis = Redis()
|
||||
chat_id = message.chat.id
|
||||
client.send_chat_action(chat_id, enums.ChatAction.TYPING)
|
||||
message_sent = False
|
||||
def send_message_and_measure_ping():
|
||||
start_time = int(round(time.time() * 1000))
|
||||
reply = client.send_message(chat_id, "Starting Ping...")
|
||||
end_time = int(round(time.time() * 1000))
|
||||
ping_time = int(round(end_time - start_time))
|
||||
message_sent = True
|
||||
if message_sent:
|
||||
message.reply_text(f"Ping: {ping_time:.2f} ms", quote=True)
|
||||
time.sleep(0.5)
|
||||
client.edit_message_text(chat_id=reply.chat.id, message_id=reply.id, text="Ping Calculation Complete.")
|
||||
time.sleep(1)
|
||||
client.delete_messages(chat_id=reply.chat.id, message_ids=reply.id)
|
||||
|
||||
thread = threading.Thread(target=send_message_and_measure_ping)
|
||||
thread.start()
|
||||
|
||||
|
||||
@app.on_message(filters.command(["stats"]))
|
||||
def stats_handler(client: Client, message: types.Message):
|
||||
redis = Redis()
|
||||
chat_id = message.chat.id
|
||||
client.send_chat_action(chat_id, enums.ChatAction.TYPING)
|
||||
if os.uname().sysname == "Darwin" or ".heroku" in os.getenv("PYTHONHOME", ""):
|
||||
bot_info = "ping unavailable."
|
||||
bot_info = "Stats Unavailable."
|
||||
else:
|
||||
bot_info = get_runtime("ytdlbot_ytdl_1", "YouTube-dl")
|
||||
if message.chat.username == OWNER:
|
||||
|
|
Loading…
Reference in a new issue