This commit is contained in:
BennyThink 2022-03-12 13:32:05 +08:00
parent 9cbf0133ab
commit fea447d1d3
No known key found for this signature in database
GPG Key ID: 6CD0DBDA5235D481
4 changed files with 20 additions and 1 deletions

View File

@ -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

View File

@ -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:

View File

@ -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):

View File

@ -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