sub_count

fix #53
This commit is contained in:
BennyThink 2022-02-09 13:47:44 +08:00
parent 19e4f32196
commit cc037deda2
No known key found for this signature in database
GPG key ID: 6CD0DBDA5235D481
3 changed files with 21 additions and 2 deletions

View file

@ -237,6 +237,7 @@ settings - Set your preference
direct - Download file directly
sub - Subscribe to YouTube Channel
unsub - Unsubscribe from YouTube Channel
sub_count - Check subscription status, owner only.
```
# Test data

View file

@ -187,6 +187,18 @@ class VIP(Redis, MySQL):
logging.info("Checking peroidic subscriber...")
return group
def sub_count(self):
sql = """
select user_id, channel.title, channel.link
from subscribe, channel where subscribe.channel_id = channel.channel_id
"""
self.cur.execute(sql)
data = self.cur.fetchall()
text = f"Total {len(data)} subscriptions found.\n\n"
for item in data:
text += "{} ==> [{}]({})\n".format(*item)
return text
class BuyMeACoffee:
def __init__(self):
@ -293,5 +305,3 @@ def subscribe_query():
has = vip.has_newer_update(cid)
if has:
print(f"{has} - {uid}")

View file

@ -171,6 +171,14 @@ def terms_handler(client: "Client", message: "types.Message"):
client.send_message(chat_id, bot_text.terms)
@app.on_message(filters.command(["sub_count"]))
def sub_count_handler(client: "Client", message: "types.Message"):
username = message.from_user.username
chat_id = message.chat.id
if username == OWNER:
client.send_message(chat_id, VIP().sub_count())
@app.on_message(filters.command(["direct"]))
def direct_handler(client: "Client", message: "types.Message"):
chat_id = message.from_user.id