forked from m4mallu/inline-tube-mate
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Users in the 'SUDO_USERS' list can broadcast messages to the bot users. Also they can access the subs count. If the 'AUTH_USERS' list is empty, the bot can be used by publicly.
- Loading branch information
Showing
12 changed files
with
214 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# !/usr/bin/env python3 | ||
# -*- coding: utf-8 -*- | ||
# Name : inline-tube-mate [ Telegram ] | ||
# Repo : https://github.com/m4mallu/inine-tube-mate | ||
# Author : Renjith Mangal [ https://t.me/space4renjith ] | ||
# Credits : https://github.com/SpEcHiDe/AnyDLBot | ||
|
||
import os | ||
import threading | ||
from sqlalchemy import create_engine | ||
from sqlalchemy import Column, TEXT, Numeric | ||
from sqlalchemy.ext.declarative import declarative_base | ||
from sqlalchemy.orm import sessionmaker, scoped_session | ||
|
||
|
||
if bool(os.environ.get("ENV", False)): | ||
from sample_config import Config | ||
else: | ||
from config import Config | ||
|
||
|
||
def start() -> scoped_session: | ||
engine = create_engine(Config.DB_URI, client_encoding="utf8") | ||
BASE.metadata.bind = engine | ||
BASE.metadata.create_all(engine) | ||
return scoped_session(sessionmaker(bind=engine, autoflush=False)) | ||
|
||
|
||
BASE = declarative_base() | ||
SESSION = start() | ||
|
||
INSERTION_LOCK = threading.RLock() | ||
|
||
class Ytdl(BASE): | ||
__tablename__ = "ytdl" | ||
id = Column(Numeric, primary_key=True) | ||
|
||
def __init__(self, id): | ||
self.id = id | ||
|
||
Ytdl.__table__.create(checkfirst=True) | ||
|
||
|
||
# ------------------------------------ Add user details ----------------------------- # | ||
async def add_user(id): | ||
with INSERTION_LOCK: | ||
msg = SESSION.query(Ytdl).get(id) | ||
if not msg: | ||
usr = Ytdl(id) | ||
SESSION.add(usr) | ||
SESSION.commit() | ||
else: | ||
pass | ||
|
||
async def query_msg(): | ||
try: | ||
query = SESSION.query(Ytdl.id).order_by(Ytdl.id) | ||
return query | ||
finally: | ||
SESSION.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# !/usr/bin/env python3 | ||
# -*- coding: utf-8 -*- | ||
# Name : inline-tube-mate [ Telegram ] | ||
# Repo : https://github.com/m4mallu/inine-tube-mate | ||
# Author : Renjith Mangal [ https://t.me/space4renjith ] | ||
# Credits : https://github.com/SpEcHiDe/AnyDLBot | ||
|
||
import asyncio | ||
from library.sql import query_msg | ||
from pyrogram.errors import FloodWait | ||
|
||
|
||
async def users_info(bot): | ||
users = 0 | ||
blocked = 0 | ||
identity = await query_msg() | ||
for id in identity: | ||
name = bool() | ||
try: | ||
name = await bot.send_chat_action(int(id[0]), "typing") | ||
except FloodWait as e: | ||
await asyncio.sleep(e.x) | ||
except Exception: | ||
pass | ||
if bool(name): | ||
users += 1 | ||
else: | ||
blocked += 1 | ||
return users, blocked |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters