mirror of
https://github.com/omg-xtao/ytdlbot.git
synced 2025-01-30 17:58:36 +00:00
uncache
This commit is contained in:
parent
9cbf0133ab
commit
fea447d1d3
@ -238,6 +238,7 @@ 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
|
||||
```
|
||||
|
||||
# Test data
|
||||
|
@ -147,7 +147,7 @@ class Redis:
|
||||
return self.r.hget("cache", unique)
|
||||
|
||||
def del_send_cache(self, unique):
|
||||
self.r.hdel("cache", unique)
|
||||
return self.r.hdel("cache", unique)
|
||||
|
||||
|
||||
class MySQL:
|
||||
|
@ -207,6 +207,15 @@ class VIP(Redis, MySQL):
|
||||
text += "{} ==> [{}]({})\n".format(*item)
|
||||
return text
|
||||
|
||||
def del_cache(self, user_link: "str"):
|
||||
unique = self.extract_canonical_link(user_link)
|
||||
caches = self.r.hgetall("cache")
|
||||
count = 0
|
||||
for key in caches:
|
||||
if key.startswith(unique):
|
||||
count += self.del_send_cache(key)
|
||||
return count
|
||||
|
||||
|
||||
class BuyMeACoffee:
|
||||
def __init__(self):
|
||||
|
@ -143,6 +143,15 @@ def patch_handler(client: "Client", message: "types.Message"):
|
||||
hot_patch()
|
||||
|
||||
|
||||
@app.on_message(filters.command(["uncache"]))
|
||||
def patch_handler(client: "Client", message: "types.Message"):
|
||||
username = message.from_user.username
|
||||
link = message.text.split()[1]
|
||||
if username == OWNER:
|
||||
count = VIP().del_cache(link)
|
||||
message.reply_text(f"{count} cache(s) deleted.", quote=True)
|
||||
|
||||
|
||||
@app.on_message(filters.command(["ping"]))
|
||||
def ping_handler(client: "Client", message: "types.Message"):
|
||||
chat_id = message.chat.id
|
||||
|
Loading…
Reference in New Issue
Block a user