Untitled
unknown
plain_text
a year ago
6.8 kB
28
Indexable
Never
import os from os import environ import random from info import * import asyncio import pytz from pyrogram import Client, filters, enums from pyrogram.errors import ChatAdminRequired, FloodWait from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup from ia_filterdb import Media, get_file_details, unpack_new_file_id, get_bad_files from users_chats_db import db from Script import script from connections_mdb import active_connection import re from datetime import datetime, date import pyrogram import string import requests import aiohttp from time import time from uuid import uuid4 from pyrogram import Client, filters import base64 import uuid from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup from multishort import short_url # Constants bot_name = "autodeletenewbot" TOKEN_TIMEOUT = int("60") # Replace with the actual token timeout in seconds # Create a new Pyrogram client SESSION = "TOKENBOT" # Replace with your desired session name API_ID = "" # Replace with your actual API ID API_HASH = "" # Replace with your actual API hash BOT_TOKEN = "" # Replace with your actual bot token # Create a new Pyrogram client app = Client( name=SESSION, api_id=API_ID, api_hash=API_HASH, bot_token=BOT_TOKEN ) # User data storage user_data = {} TOKENS = {} VERIFIED = {} #DQ_ @app.on_message(filters.command("start") & filters.incoming) async def start(client, message): if message.chat.type in [enums.ChatType.GROUP, enums.ChatType.SUPERGROUP]: buttons = [[ InlineKeyboardButton('⤬ ONWER ⤬', url='http://t.me/starkownerbot') ],[ InlineKeyboardButton('✇ SEARCH ✇', url='https://google.com') ]] reply_markup = InlineKeyboardMarkup(buttons) await message.reply_text( text="<b>WELCOME TO THIS IS TOKEN SYS TESTING</b>", reply_markup=reply_markup) await asyncio.sleep(2) if len(message.command) != 2: buttons = [[ InlineKeyboardButton('⤬ ONWER ⤬', url='http://t.me/starkownerbot') ],[ InlineKeyboardButton('✇ SEARCH ✇', url='https://google.com') ]] reply_markup = InlineKeyboardMarkup(buttons) await message.reply_text( text="<b>WELCOME TO THIS IS TOKEN SYS TESTING</b>", reply_markup=reply_markup) return data = message.command[1] try: pre, file_id = data.split('_', 1) except: file_id = data pre = "" if data.split("-", 1)[0] == "verify": userid = data.split("-", 2)[1] token = data.split("-", 3)[2] if str(message.from_user.id) != str(userid): return await message.reply_text("<b>Invalid link or Expired link !</b>") is_valid = await check_token(client, userid, token) if is_valid == True: await message.reply_text( f"<b>Hey {message.from_user.mention}, You are successfully varified !\nNow you have unlimited access for all movies upto today midnight.</b>") await verify_user(client, userid, token) else: return await message.reply_text("<b>Invalid link or Expired link !</b>") files_ = await get_file_details(file_id) if not files_: pre, file_id = ((base64.urlsafe_b64decode(data + "=" * (-len(data) % 4))).decode("ascii")).split("_", 1) try: if not await check_verification(client, message.from_user.id) and VERIFY == True: btn = [[ InlineKeyboardButton("Verify", url=await get_token(client, message.from_user.id, f"https://telegram.me/{bot_name}?start=")) ]] await message.reply_text( text="<b>You are not verified !\nKindly verify to continue !</b>", reply_markup=InlineKeyboardMarkup(btn) ) return except: pass if not await check_verification(client, message.from_user.id) and VERIFY == True: btn = [[ InlineKeyboardButton("Verify", url=await get_token(client, message.from_user.id, f"https://telegram.me/{bot_name}?start=")) ]] await message.reply_text( text="<b>You are not verified !\nKindly verify to continue !</b>", reply_markup=InlineKeyboardMarkup(btn) ) return async def check_token(bot, userid, token): user = await bot.get_users(userid) if not await db.is_user_exist(user.id): await db.add_user(user.id, user.first_name) await bot.send_message(LOG_CHANNEL, script.LOG_TEXT_P.format(user.id, user.mention)) if user.id in TOKENS.keys(): TKN = TOKENS[user.id] if token in TKN.keys(): is_used = TKN[token] if is_used == True: return False else: return True else: return False async def get_token(bot, userid, link): user = await bot.get_users(userid) if not await db.is_user_exist(user.id): await db.add_user(user.id, user.first_name) await bot.send_message(LOG_CHANNEL, script.LOG_TEXT_P.format(user.id, user.mention)) token = ''.join(random.choices(string.ascii_letters + string.digits, k=7)) TOKENS[user.id] = {token: False} link = f"{link}verify-{user.id}-{token}" shortened_verify_url = await short_url(link) return str(shortened_verify_url) async def verify_user(bot, userid, token): user = await bot.get_users(userid) if not await db.is_user_exist(user.id): await db.add_user(user.id, user.first_name) await bot.send_message(LOG_CHANNEL, script.LOG_TEXT_P.format(user.id, user.mention)) TOKENS[user.id] = {token: True} tz = pytz.timezone('Asia/Kolkata') today = date.today() VERIFIED[user.id] = str(today) async def check_verification(bot, userid): user = await bot.get_users(userid) if not await db.is_user_exist(user.id): await db.add_user(user.id, user.first_name) await bot.send_message(LOG_CHANNEL, script.LOG_TEXT_P.format(user.id, user.mention)) tz = pytz.timezone('Asia/Kolkata') today = date.today() if user.id in VERIFIED.keys(): EXP = VERIFIED[user.id] years, month, day = EXP.split('-') comp = date(int(years), int(month), int(day)) if comp<today: return False else: return True else: return False # Start the client if __name__ == "__main__": app.run()