diff --git a/Balance py b/Balance py new file mode 100644 index 0000000..6059ba6 --- /dev/null +++ b/Balance py @@ -0,0 +1,220 @@ +import math +import asyncio +from datetime import datetime, timedelta +from telegram.ext import CommandHandler +from Grabber import application, user_collection +import math +import random +import time + +async def balance(update, context): + user_id = update.effective_user.id + + user_data = await user_collection.find_one({'id': user_id}) + + if user_data: + balance_amount = user_data.get('balance', 0) + bank_balance = math.floor(bank_balance) + balance_message = f"Your Current Balance Is : $ `{balance_amount}` Gold coins!!" + else: + balance_message = "You are not eligible To be a Hunter ๐Ÿ‚" + + await update.message.reply_text(balance_message) + +pay_cooldown = {} + +async def pay(update, context): + sender_id = update.effective_user.id + + if not update.message.reply_to_message: + await update.message.reply_text("Please reply To a Hunter to /pay.") + return + + if update.message.reply_to_message.from_user and update.message.reply_to_message.from_user.id == sender_id: + await update.message.reply_text("You can't give $ Gold coins To Yourself!") + return + + # Check if the user has executed /pay recently and enforce cooldown + if sender_id in pay_cooldown: + last_execution_time = pay_cooldown[sender_id] + if (datetime.utcnow() - last_execution_time) < timedelta(minutes=30): + await update.message.reply_text("You can pay /pay again after 30 Minutes!!...") + return + + if not update.message.reply_to_message: + await update.message.reply_text("Please reply a Hunter to /pay.") + return + + recipient_id = update.message.reply_to_message.from_user.id + recipient_first_name = update.message.reply_to_message.from_user.first_name + recipient_username = update.message.reply_to_message.from_user.username + + try: + amount = int(context.args[0]) + except (IndexError, ValueError): + await update.message.reply_text("Invaild amount, use /pay ") + return + + if amount < 0: + await update.message.reply_text("Amount must be positive BKL !!!") + return + elif amount > 1000000: + await update.message.reply_text("You can pay upto $ `10,00,000` Gold coins in one payment !!") + return + + sender_data = await user_collection.find_one({'id': sender_id}) + if not sender_data or sender_data.get('balance', 0) < amount: + await update.message.reply_text("insufficient amount to pay !!.") + return + + await user_collection.update_one( + {'id': sender_id}, + {'$inc': {'balance': -amount}} + ) + await user_collection.update_one( + {'id': recipient_id}, + {'$inc': {'balance': amount}} + ) + + pay_cooldown[sender_id] = datetime.utcnow() + + recipient_link = f"https://t.me/{recipient_username}" if recipient_username else f"https://t.me/user{recipient_id}" + success_message = f"success ! You paid $ `{amount}` Gold coins to [{recipient_first_name}]!" + + await update.message.reply_markdown(success_message) + +async def mtop(update, context): + # Retrieve the top 10 users with the highest balance + top_users = await user_collection.find({}, projection={'id': 1, 'first_name': 1, 'last_name': 1, 'balance': 1}).sort('balance', -1).limit(10).to_list(10) + + # Create a message with the top users + top_users_message = "Top 10 Rich Hunters data.\n\n" + for i, user in enumerate(top_users, start=1): + first_name = user.get('first_name', 'Unknown') + last_name = user.get('last_name', '') + user_id = user.get('id', 'Unknown') + + full_name = f"{first_name} {last_name}" if last_name else first_name + + top_users_message += f"{i}. {full_name}, $ `{user.get('balance', 0)}` Gold Coins\n" + + photo_path = 'https://telegra.ph/file/07283c3102ae87f3f2833.png' + await update.message.reply_photo(photo=photo_path, caption=top_users_message, parse_mode='HTML') + + +from datetime import datetime, timedelta + +async def format_time_delta(delta): + seconds = delta.total_seconds() + hours, remainder = divmod(seconds, 3600) + minutes, seconds = divmod(remainder, 60) + return f"{int(hours)}h {int(minutes)}m {int(seconds)}s" + +async def daily_reward(update, context): + user_id = update.effective_user.id + user_data = await user_collection.find_one({'id': user_id}, projection={'last_daily_reward': 1, 'balance': 1}) + + if user_data: + last_claimed_date = user_data.get('last_daily_reward') + + if last_claimed_date and last_claimed_date.date() == datetime.utcnow().date(): + remaining_time = timedelta(days=1) - (datetime.utcnow() - last_claimed_date) + formatted_time = await format_time_delta(remaining_time) + await update.message.reply_text(f"Soory ! hunter but you already claimed . Next reward in: `{formatted_time}`.") + return + + await user_collection.update_one( + {'id': user_id}, + {'$inc': {'balance': 2000}, '$set': {'last_daily_reward': datetime.utcnow()}} + ) + + await update.message.reply_text("Congratulations! You claim $ `2000` Gold coins as a daily reward.") + +async def roll(update, context): + user_id = update.effective_user.id + try: + amount = int(context.args[0]) + choice = context.args[1].upper() # Assuming the second argument is ODD or EVEN + except (IndexError, ValueError): + await update.message.reply_text("Invalid usage, please use /roll ") + return + + if amount < 0: + await update.message.reply_text("Amount must be positive.") + return + + user_data = await user_collection.find_one({'id': user_id}) + if not user_data: + await update.message.reply_text("User data not found.") + return + + balance_amount = user_data.get('balance', 0) + if amount < balance_amount * 0.07: + await update.message.reply_text("You can bet more than 7% of your balance.") + return + + if balance_amount < amount: + await update.message.reply_text("Insufficient balance to place the bet.") + return + + # Send the dice emoji + dice_message = await context.bot.send_dice(update.effective_chat.id, "๐ŸŽฒ") + + # Extract the dice value + dice_value = dice_message.dice.value + + # Check if the dice roll is odd or even + dice_result = "ODD" if dice_value % 2 != 0 else "EVEN" + + xp_change = 0 # Initialize XP change + + if choice == dice_result: + # User wins, update balance and add XP + xp_change = 4 + await user_collection.update_one( + {'id': user_id}, + {'$inc': {'balance': amount, 'user_xp': xp_change}} + ) + await update.message.reply_text(f"Dice roll: {dice_value}\nYou won! Your balance increased by {amount * 2}.") + else: + # User loses, deduct bet amount from balance and subtract XP + xp_change = -2 + await user_collection.update_one( + {'id': user_id}, + {'$inc': {'balance': -amount, 'user_xp': xp_change}} + ) + await update.message.reply_text(f"Dice roll: {dice_value}\nYou lost! {amount} deducted from your balance.") + + # Notify user about XP change + await update.message.reply_text(f"XP change: {xp_change}") + +application.add_handler(CommandHandler("roll", roll, block=False)) + +async def xp(update, context): + user_id = update.effective_user.id + user_data = await user_collection.find_one({'id': user_id}) + + if not user_data: + await update.message.reply_text("User data not found.") + return + + xp = user_data.get('user_xp', 0) + level = math.floor(math.sqrt(xp / 100)) + 1 + + if level > 100: + level = 100 + + ranks = {1: "E", 10: "D", 30: "C", 50: "B", 70: "A", 90: "S"} + rank = next((rank for xp_limit, rank in ranks.items() if level <= xp_limit), None) + + message = f"Your current level is `{level}`\nand your rank is `{rank}`." + + await update.message.reply_text(message) + +application.add_handler(CommandHandler("xp", xp, block=False)) +application.add_handler(CommandHandler("roll", roll, block=False)) +application.add_handler(CommandHandler("bal", balance, block=False)) +application.add_handler(CommandHandler("pay", pay, block=False)) + +application.add_handler(CommandHandler("Tophunters", mtop, block=False)) +application.add_handler(CommandHandler("claim", daily_reward, block=False)) diff --git a/Changetime b/Changetime new file mode 100644 index 0000000..761c354 --- /dev/null +++ b/Changetime @@ -0,0 +1,78 @@ +from pymongo import ReturnDocument +from telegram import Update +from telegram.ext import CommandHandler, CallbackContext +from Grabber import application, OWNER_ID, user_totals_collection + +async def change_time(update: Update, context: CallbackContext) -> None: + user = update.effective_user + chat = update.effective_chat + + try: + member = await chat.get_member(user.id) + if member.status not in ('administrator', 'creator'): + await update.message.reply_text('You do not have permission to use this command.') + return + + args = context.args + if len(args) != 1: + await update.message.reply_text('Incorrect format. Please use: /changetime NUMBER') + return + + new_frequency = int(args[0]) + if new_frequency < 100: + await update.message.reply_text('The message frequency must be greater than or equal to 100.') + return + + if new_frequency > 10000: + await update.message.reply_text('Thats too much buddy. Use below 10000') + return + + chat_frequency = await user_totals_collection.find_one_and_update( + {'chat_id': str(chat.id)}, + {'$set': {'message_frequency': new_frequency}}, + upsert=True, + return_document=ReturnDocument.AFTER + ) + + await update.message.reply_text(f'Successfully changed character appearance frequency to every {new_frequency} messages.') + except Exception as e: + await update.message.reply_text('Failed to change character appearance frequency.') + + +async def change_time_sudo(update: Update, context: CallbackContext) -> None: + sudo_user_ids = {6890857225, 1307669968} + user = update.effective_user + + try: + if user.id not in sudo_user_ids: + await update.message.reply_text('You do not have permission to use this command.') + return + + args = context.args + if len(args) != 1: + await update.message.reply_text('Incorrect format. Please use: /changetime NUMBER') + return + + new_frequency = int(args[0]) + if new_frequency < 1: + await update.message.reply_text('The message frequency must be greater than or equal to 1.') + return + + if new_frequency > 10000: + await update.message.reply_text('Thats too much buddy. Use below 10000') + return + + chat_frequency = await user_totals_collection.find_one_and_update( + {'chat_id': str(update.effective_chat.id)}, + {'$set': {'message_frequency': new_frequency}}, + upsert=True, + return_document=ReturnDocument.AFTER + ) + + await update.message.reply_text(f'Successfully changed character appearance frequency to every {new_frequency} messages.') + except Exception as e: + await update.message.reply_text('Failed to change character appearance frequency.') + + +application.add_handler(CommandHandler("ctime", change_time_sudo, block=False)) +application.add_handler(CommandHandler("changetime", change_time, block=False)) diff --git a/Give py b/Give py new file mode 100644 index 0000000..0ed3680 --- /dev/null +++ b/Give py @@ -0,0 +1,116 @@ +from pyrogram import Client, filters +from Grabber import db, collection, top_global_groups_collection, group_user_totals_collection, user_collection, user_totals_collection +import asyncio +from Grabber import Grabberu as app +from Grabber import sudo_users + +DEV_LIST = [6961287189] + +async def give_character(receiver_id, character_id): + character = await collection.find_one({'id': character_id}) + + if character: + try: + await user_collection.update_one( + {'id': receiver_id}, + {'$push': {'characters': character}} + ) + + img_url = character['img_url'] + caption = ( + f"Successfully Given To {receiver_id}\n" + f"Information As Follows\n" + f" โœ… Rarity: {character['rarity']}\n" + f"๐Ÿซ‚ Anime: {character['anime']}\n" + f"๐Ÿ’• Name: {character['name']}\n" + f"๐Ÿฟ ID: {character['id']}" + ) + + return img_url, caption + except Exception as e: + print(f"Error updating user: {e}") + raise + else: + raise ValueError("Character not found.") + +@app.on_message(filters.command(["give"]) & filters.reply & filters.user(DEV_LIST)) +async def give_character_command(client, message): + if not message.reply_to_message: + await message.reply_text("You need to reply to a user's message to give a character!") + return + try: + character_id = str(message.text.split()[1]) + receiver_id = message.reply_to_message.from_user.id + + result = await give_character(receiver_id, character_id) + + if result: + img_url, caption = result + await message.reply_photo(photo=img_url, caption=caption) + except (IndexError, ValueError) as e: + await message.reply_text(str(e)) + except Exception as e: + print(f"Error in give_character_command: {e}") + await message.reply_text("An error occurred while processing the command.") + + +async def add_all_characters_for_user(user_id): + user = await user_collection.find_one({'id': user_id}) + + if user: + all_characters_cursor = collection.find({}) + all_characters = await all_characters_cursor.to_list(length=None) + + existing_character_ids = {character['id'] for character in user['characters']} + new_characters = [character for character in all_characters if character['id'] not in existing_character_ids] + + if new_characters: + await user_collection.update_one( + {'id': user_id}, + {'$push': {'characters': {'$each': new_characters}}} + ) + + return f"Successfully added characters for user {user_id}" + else: + return f"No new characters to add for user {user_id}" + else: + return f"User with ID {user_id} not found." + +@app.on_message(filters.command(["add"]) & filters.user(DEV_LIST)) +async def add_characters_command(client, message): + user_id_to_add_characters_for = message.from_user.id + result_message = await add_all_characters_for_user(user_id_to_add_characters_for) + await message.reply_text(result_message) + + +async def kill_character(receiver_id, character_id): + character = await collection.find_one({'id': character_id}) + + if character: + try: + await user_collection.update_one( + {'id': receiver_id}, + {'$pull': {'characters': {'id': character_id}}} + ) + + return f"Successfully removed character `{character_id}` from user `{receiver_id}`" + except Exception as e: + print(f"Error updating user: {e}") + raise + else: + raise ValueError("Character not found.") + +@app.on_message(filters.command(["kill"]) & filters.reply & filters.user(DEV_LIST)) +async def remove_character_command(client, message): + try: + character_id = str(message.text.split()[1]) + receiver_id = message.reply_to_message.from_user.id + + result_message = await kill_character(receiver_id, character_id) + + await message.reply_text(result_message) + except (IndexError, ValueError) as e: + await message.reply_text(str(e)) + except Exception as e: + print(f"Error in remove_character_command: {e}") + await message.reply_text("An error occurred while processing the command.") diff --git a/Harem py b/Harem py new file mode 100644 index 0000000..c6b2642 --- /dev/null +++ b/Harem py @@ -0,0 +1,140 @@ +from telegram import Update +from itertools import groupby +import urllib.request +import re +import math +from html import escape +import random + +from telegram.ext import CommandHandler, CallbackContext, CallbackQueryHandler +from telegram import InlineKeyboardButton, InlineKeyboardMarkup + +from Grabber import collection, user_collection, application + +async def harem(update: Update, context: CallbackContext, page=0) -> None: + user_id = update.effective_user.id + + user = await user_collection.find_one({'id': user_id}) + if not user: + if update.message: + await update.message.reply_text('๐™”๐™ค๐™ช ๐™ƒ๐™–๐™ซ๐™š ๐™‰๐™ค๐™ฉ ๐™‚๐™ง๐™–๐™— ๐™–๐™ฃ๐™ฎ ๐™’๐™–๐™ž๐™›๐™ช ๐™”๐™š๐™ฉ...') + else: + await update.callback_query.edit_message_text('๐™”๐™ค๐™ช ๐™ƒ๐™–๐™ซ๐™š ๐™‰๐™ค๐™ฉ ๐™‚๐™ง๐™–๐™— ๐™–๐™ฃ๐™ฎ ๐™’๐™–๐™ž๐™›๐™ช ๐™”๐™š๐™ฉ...') + return + + characters = sorted(user['characters'], key=lambda x: (x['anime'], x['id'])) + + character_counts = {k: len(list(v)) for k, v in groupby(characters, key=lambda x: x['id'])} + + + unique_characters = list({character['id']: character for character in characters}.values()) + + + total_pages = math.ceil(len(unique_characters) / 7) + + if page < 0 or page >= total_pages: + page = 0 + + harem_message = f"{escape(update.effective_user.first_name)}'s Harem - Page {page+1}/{total_pages}\n" + + + current_characters = unique_characters[page*7:(page+1)*7] + + + current_grouped_characters = {k: list(v) for k, v in groupby(current_characters, key=lambda x: x['anime'])} + + for anime, characters in current_grouped_characters.items(): + harem_message += f'\nโฅฑ {anime} {len(characters)}/{await collection.count_documents({"anime": anime})}\n' + + for character in characters: + + count = character_counts[character['id']] # Get the count from the character_counts dictionary + harem_message += f'โžฅ{character["id"]}| {character["rarity"]} |{character["name"]} ร—{count}\n' + + + total_count = len(user['characters']) + + keyboard = [[InlineKeyboardButton(f"See Collection ({total_count})", switch_inline_query_current_chat=f"collection.{user_id}")]] + + + if total_pages > 1: + + nav_buttons = [] + if page > 0: + nav_buttons.append(InlineKeyboardButton("โฌ…๏ธ", callback_data=f"harem:{page-1}:{user_id}")) + if page < total_pages - 1: + nav_buttons.append(InlineKeyboardButton("โžก๏ธ", callback_data=f"harem:{page+1}:{user_id}")) + keyboard.append(nav_buttons) + + reply_markup = InlineKeyboardMarkup(keyboard) + + if 'favorites' in user and user['favorites']: + + fav_character_id = user['favorites'][0] + fav_character = next((c for c in user['characters'] if c['id'] == fav_character_id), None) + + if fav_character and 'img_url' in fav_character: + if update.message: + await update.message.reply_photo(photo=fav_character['img_url'], parse_mode='HTML', caption=harem_message, reply_markup=reply_markup) + else: + + if update.callback_query.message.caption != harem_message: + await update.callback_query.edit_message_caption(caption=harem_message, reply_markup=reply_markup, parse_mode='HTML') + else: + if update.message: + await update.message.reply_text(harem_message, parse_mode='HTML', reply_markup=reply_markup) + else: + + if update.callback_query.message.text != harem_message: + await update.callback_query.edit_message_text(harem_message, parse_mode='HTML', reply_markup=reply_markup) + else: + + if user['characters']: + + random_character = random.choice(user['characters']) + + if 'img_url' in random_character: + if update.message: + await update.message.reply_photo(photo=random_character['img_url'], parse_mode='HTML', caption=harem_message, reply_markup=reply_markup) + else: + + if update.callback_query.message.caption != harem_message: + await update.callback_query.edit_message_caption(caption=harem_message, reply_markup=reply_markup, parse_mode='HTML') + else: + if update.message: + await update.message.reply_text(harem_message, parse_mode='HTML', reply_markup=reply_markup) + else: + + if update.callback_query.message.text != harem_message: + await update.callback_query.edit_message_text(harem_message, parse_mode='HTML', reply_markup=reply_markup) + else: + if update.message: + await update.message.reply_text("Your List is Empty :)") + + +async def harem_callback(update: Update, context: CallbackContext) -> None: + query = update.callback_query + data = query.data + + + _, page, user_id = data.split(':') + + + page = int(page) + user_id = int(user_id) + + + if query.from_user.id != user_id: + await query.answer("its Not Your Harem", show_alert=True) + return + + + await harem(update, context, page) + + + + +application.add_handler(CommandHandler(["harem"], harem,block=False)) +harem_handler = CallbackQueryHandler(harem_callback, pattern='^harem', block=False) +application.add_handler(harem_handler) + diff --git a/Inlinepy b/Inlinepy new file mode 100644 index 0000000..c5a2d53 --- /dev/null +++ b/Inlinepy @@ -0,0 +1,86 @@ +from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup +import re +from pyrogram import Client, filters, types, enums +import asyncio +import time +from html import escape +from cachetools import TTLCache +from pymongo import MongoClient, ASCENDING +from Grabber import Grabberu as app +from Grabber import user_collection, collection, db + +# MongoDB indexes +db.characters.create_index([('id', ASCENDING)]) +db.characters.create_index([('anime', ASCENDING)]) +db.characters.create_index([('img_url', ASCENDING)]) + +db.user_collection.create_index([('characters.id', ASCENDING)]) +db.user_collection.create_index([('characters.name', ASCENDING)]) +db.user_collection.create_index([('characters.img_url', ASCENDING)]) + +all_characters_cache = TTLCache(maxsize=10000, ttl=36000) +user_collection_cache = TTLCache(maxsize=10000, ttl=60) + +@app.on_inline_query() +async def inlinequery(client: Client, query: types.InlineQuery): + offset = int(query.offset) if query.offset else 0 + + if query.query.startswith('collection.'): + user_id, *search_terms = query.query.split(' ')[0].split('.')[1], ' '.join(query.query.split(' ')[1:]) + if user_id.isdigit(): + if user_id in user_collection_cache: + user = user_collection_cache[user_id] + else: + user = await user_collection.find_one({'id': int(user_id)}) + user_collection_cache[user_id] = user + + if user: + all_characters = list({v['id']:v for v in user['characters']}.values()) + if search_terms: + regex = re.compile(' '.join(search_terms), re.IGNORECASE) + all_characters = [character for character in all_characters if regex.search(character['name']) or regex.search(character['anime'])] + else: + all_characters = [] + else: + all_characters = [] + else: + if query.query: + regex = re.compile(query.query, re.IGNORECASE) + all_characters = list(await collection.find({"$or": [{"name": regex}, {"anime": regex}]}).to_list(length=None)) + else: + if 'all_characters' in all_characters_cache: + all_characters = all_characters_cache['all_characters'] + else: + all_characters = list(await collection.find({}).to_list(length=None)) + all_characters_cache['all_characters'] = all_characters + + characters = all_characters[offset:offset+50] + if len(characters) > 50: + characters = characters[:50] + next_offset = str(offset + 50) + else: + next_offset = str(offset + len(characters)) + + results = [] + for character in characters: + global_count = await user_collection.count_documents({'characters.id': character['id']}) + anime_characters = await collection.count_documents({'anime': character['anime']}) + total_characters = len(all_characters) + title = str(total_characters) + if query.query.startswith('collection.'): + user_character_count = sum(c['id'] == character['id'] for c in user['characters']) + user_anime_characters = sum(c['anime'] == character['anime'] for c in user['characters']) + caption = f" Look At {(escape(user.get('first_name', user['id'])))}'s Character\n\n๐ŸŒธ: {character['name']} (x{user_character_count})\n๐Ÿ–๏ธ: {character['anime']} ({user_anime_characters}/{anime_characters})\n{character['rarity']}\n\n๐Ÿ†”๏ธ: {character['id']}" + else: + caption = f"Look At This Character !!\n\n๐ŸŒธ: {character['name']}\n๐Ÿ–๏ธ: {character['anime']}\n{character['rarity']}\n๐Ÿ†”๏ธ: {character['id']}\n\nGlobally Guessed {global_count} Times..." + results.append( + types.InlineQueryResultPhoto( + title=title, + thumb_url=character['img_url'], + photo_url=character['img_url'], + caption=caption, + parse_mode=enums.ParseMode.HTML + ) + ) + + await client.answer_inline_query(query.id, results, next_offset=next_offset, cache_time=5, is_gallery=True) diff --git a/Inty py b/Inty py new file mode 100644 index 0000000..be31195 --- /dev/null +++ b/Inty py @@ -0,0 +1,68 @@ +import logging +import sys +import time + +StartTime = time.time() + +# enable logging +logging.basicConfig( + format="%(asctime)s - %(levelname)s - %(name)s - %(message)s", + handlers=[logging.FileHandler("log.txt"), logging.StreamHandler()], + level=logging.INFO, +) + +logging.getLogger("apscheduler").setLevel(logging.ERROR) + +logging.getLogger("pyrate_limiter").setLevel(logging.ERROR) +LOGGER = logging.getLogger(__name__) + +# if version < 3.6, stop bot. +if sys.version_info[0] < 3 or sys.version_info[1] < 6: + LOGGER.error( + "You MUST have a python version of at least 3.6! Multiple features depend on this. Bot quitting." + ) + quit(1) + +LOAD = [] +NO_LOAD = [] + +def __list_all_modules(): + import glob + from os.path import basename, dirname, isfile + + # This generates a list of modules in this folder for the * in __main__ to work. + mod_paths = glob.glob(dirname(__file__) + "/*.py") + all_modules = [ + basename(f)[:-3] + for f in mod_paths + if isfile(f) and f.endswith(".py") and not f.endswith("__init__.py") + ] + + if LOAD or NO_LOAD: + to_load = LOAD + if to_load: + if not all( + any(mod == module_name for module_name in all_modules) + for mod in to_load + ): + LOGGER.error("Invalid loadorder names, Quitting...") + quit(1) + + all_modules = sorted(set(all_modules) - set(to_load)) + to_load = list(all_modules) + to_load + + else: + to_load = all_modules + + if NO_LOAD: + LOGGER.info("Not loading: {}".format(NO_LOAD)) + return [item for item in to_load if item not in NO_LOAD] + + return to_load + + return all_modules + + +ALL_MODULES = __list_all_modules() +LOGGER.info("Modules to load: %s", str(ALL_MODULES)) +__all__ = ALL_MODULES + ["ALL_MODULES"] diff --git a/Ledaraby b/Ledaraby new file mode 100644 index 0000000..3a32c07 --- /dev/null +++ b/Ledaraby @@ -0,0 +1,198 @@ +import os +import random +import html + +from telegram import Update +from telegram.ext import CommandHandler, CallbackContext + +from Grabber import (application, PHOTO_URL, OWNER_ID, + user_collection, top_global_groups_collection, top_global_groups_collection, + group_user_totals_collection) + +from Grabber import sudo_users as SUDO_USERS + +photo = random.choice(PHOTO_URL) + +async def global_leaderboard(update: Update, context: CallbackContext) -> None: + + cursor = top_global_groups_collection.aggregate([ + {"$project": {"group_name": 1, "count": 1}}, + {"$sort": {"count": -1}}, + {"$limit": 10} + ]) + leaderboard_data = await cursor.to_list(length=10) + + leaderboard_message = "TOP 10 GROUPS WHO GUESSED MOST CHARACTERS\n\n" + + for i, group in enumerate(leaderboard_data, start=1): + group_name = html.escape(group.get('group_name', 'Unknown')) + + if len(group_name) > 10: + group_name = group_name[:15] + '...' + count = group['count'] + leaderboard_message += f'{i}. {group_name} โžพ {count}\n' + + + photo_url = random.choice(photo) + + await update.message.reply_photo(photo=photo_url, caption=leaderboard_message, parse_mode='HTML') + +async def ctop(update: Update, context: CallbackContext) -> None: + chat_id = update.effective_chat.id + + cursor = group_user_totals_collection.aggregate([ + {"$match": {"group_id": chat_id}}, + {"$project": {"username": 1, "first_name": 1, "character_count": "$count"}}, + {"$sort": {"character_count": -1}}, + {"$limit": 10} + ]) + leaderboard_data = await cursor.to_list(length=10) + + leaderboard_message = "TOP 10 USERS WHO GUESSED CHARACTERS MOST TIME IN THIS GROUP..\n\n" + + for i, user in enumerate(leaderboard_data, start=1): + username = user.get('username', 'Unknown') + first_name = html.escape(user.get('first_name', 'Unknown')) + + if len(first_name) > 10: + first_name = first_name[:15] + '...' + character_count = user['character_count'] + leaderboard_message += f'{i}. {first_name} โžพ {character_count}\n' + + photo_url = random.choice(photo) + + await update.message.reply_photo(photo=photo_url, caption=leaderboard_message, parse_mode='HTML') + + +async def leaderboard(update: Update, context: CallbackContext) -> None: + + cursor = user_collection.aggregate([ + {"$project": {"username": 1, "first_name": 1, "character_count": {"$size": "$characters"}}}, + {"$sort": {"character_count": -1}}, + {"$limit": 10} + ]) + leaderboard_data = await cursor.to_list(length=10) + + leaderboard_message = "TOP 10 USERS WITH MOST CHARACTERS\n\n" + + for i, user in enumerate(leaderboard_data, start=1): + username = user.get('username', 'Unknown') + first_name = html.escape(user.get('first_name', 'Unknown')) + + if len(first_name) > 10: + first_name = first_name[:15] + '...' + character_count = user['character_count'] + leaderboard_message += f'{i}. {first_name} โžพ {character_count}\n' + + photo_url = random.choice(photo) + + await update.message.reply_photo(photo=photo_url, caption=leaderboard_message, parse_mode='HTML') + + +async def broadcast(update: Update, context: CallbackContext) -> None: + + if str(update.effective_user.id) == OWNER_ID: + + if update.message.reply_to_message is None: + await update.message.reply_text('Please reply to a message to broadcast.') + return + + + all_users = await user_collection.find({}).to_list(length=None) + all_groups = await group_user_totals_collection.find({}).to_list(length=None) + + unique_user_ids = set(user['id'] for user in all_users) + unique_group_ids = set(group['group_id'] for group in all_groups) + + total_sent = 0 + total_failed = 0 + + + for user_id in unique_user_ids: + try: + await context.bot.forward_message(chat_id=user_id, from_chat_id=update.effective_chat.id, message_id=update.message.reply_to_message.message_id) + total_sent += 1 + except Exception: + total_failed += 1 + + + for group_id in unique_group_ids: + try: + await context.bot.forward_message(chat_id=group_id, from_chat_id=update.effective_chat.id, message_id=update.message.reply_to_message.message_id) + total_sent += 1 + except Exception: + total_failed += 1 + + + await context.bot.send_message( + chat_id=update.effective_chat.id, + text=f'Broadcast report:\n\nTotal messages sent successfully: {total_sent}\nTotal messages failed to send: {total_failed}' + ) + else: + await update.message.reply_text('Only Murat Can use') + + +async def stats(update: Update, context: CallbackContext) -> None: + + if str(update.effective_user.id) not in OWNER_ID: + update.message.reply_text('only For Sudo users...') + return + + + user_count = await user_collection.count_documents({}) + + + group_count = await group_user_totals_collection.distinct('group_id') + + + await update.message.reply_text(f'Total Users: {user_count}\nTotal groups: {len(group_count)}') + + + + +async def send_users_document(update: Update, context: CallbackContext) -> None: + if str(update.effective_user.id) not in SUDO_USERS: + update.message.reply_text('only For Sudo users...') + return + cursor = user_collection.find({}) + users = [] + async for document in cursor: + users.append(document) + user_list = "" + for user in users: + user_list += f"{user['first_name']}\n" + with open('users.txt', 'w') as f: + f.write(user_list) + with open('users.txt', 'rb') as f: + await context.bot.send_document(chat_id=update.effective_chat.id, document=f) + os.remove('users.txt') + +async def send_groups_document(update: Update, context: CallbackContext) -> None: + if str(update.effective_user.id) not in SUDO_USERS: + update.message.reply_text('Only For Sudo users...') + return + cursor = top_global_groups_collection.find({}) + groups = [] + async for document in cursor: + groups.append(document) + group_list = "" + for group in groups: + group_list += f"{group['group_name']}\n" + group_list += "\n" + with open('groups.txt', 'w') as f: + f.write(group_list) + with open('groups.txt', 'rb') as f: + await context.bot.send_document(chat_id=update.effective_chat.id, document=f) + os.remove('groups.txt') + + +application.add_handler(CommandHandler('ctop', ctop, block=False)) +application.add_handler(CommandHandler('stats', stats, block=False)) +application.add_handler(CommandHandler('TopGroups', global_leaderboard, block=False)) + +application.add_handler(CommandHandler('list', send_users_document, block=False)) +application.add_handler(CommandHandler('groups', send_groups_document, block=False)) + + +application.add_handler(CommandHandler('top', leaderboard, block=False)) +application.add_handler(CommandHandler('broadcast', broadcast, block=False)) diff --git a/Main py b/Main py new file mode 100644 index 0000000..776d552 --- /dev/null +++ b/Main py @@ -0,0 +1,251 @@ +import importlib +import time +import random +import re +import asyncio +from html import escape + +from telegram import InlineKeyboardButton, InlineKeyboardMarkup +from telegram import InlineKeyboardMarkup, InlineKeyboardButton +from telegram import Update +from telegram.ext import CommandHandler, CallbackContext, MessageHandler, filters + +from Grabber import collection, top_global_groups_collection, group_user_totals_collection, user_collection, user_totals_collection, Grabberu +from Grabber import application, LOGGER +from Grabber.modules import ALL_MODULES + + +locks = {} +message_counters = {} +spam_counters = {} +last_characters = {} +sent_characters = {} +first_correct_guesses = {} +message_counts = {} + + +for module_name in ALL_MODULES: + imported_module = importlib.import_module("Grabber.modules." + module_name) + + +last_user = {} +warned_users = {} +def escape_markdown(text): + escape_chars = r'\*_`\\~>#+-=|{}.!' + return re.sub(r'([%s])' % re.escape(escape_chars), r'\\\1', text) + + +async def message_counter(update: Update, context: CallbackContext) -> None: + chat_id = str(update.effective_chat.id) + user_id = update.effective_user.id + + if chat_id not in locks: + locks[chat_id] = asyncio.Lock() + lock = locks[chat_id] + + async with lock: + + chat_frequency = await user_totals_collection.find_one({'chat_id': chat_id}) + if chat_frequency: + message_frequency = chat_frequency.get('message_frequency', 100) + else: + message_frequency = 100 + + + if chat_id in last_user and last_user[chat_id]['user_id'] == user_id: + last_user[chat_id]['count'] += 1 + if last_user[chat_id]['count'] >= 10: + + if user_id in warned_users and time.time() - warned_users[user_id] < 600: + return + else: + + await update.message.reply_text(f"โš ๏ธ ๐˜ฟ๐™ค๐™ฃ'๐™ฉ ๐™Ž๐™ฅ๐™–๐™ข {update.effective_user.first_name}...\n๐™”๐™ค๐™ช๐™ง ๐™ˆ๐™š๐™จ๐™จ๐™–๐™œ๐™š๐™จ ๐™’๐™ž๐™ก๐™ก ๐™—๐™š ๐™ž๐™œ๐™ฃ๐™ค๐™ง๐™š๐™™ ๐™›๐™ค๐™ง 10 ๐™ˆ๐™ž๐™ฃ๐™ช๐™ฉ๐™š๐™จ...") + warned_users[user_id] = time.time() + return + else: + last_user[chat_id] = {'user_id': user_id, 'count': 1} + + + if chat_id in message_counts: + message_counts[chat_id] += 1 + else: + message_counts[chat_id] = 1 + + + if message_counts[chat_id] % message_frequency == 0: + await send_image(update, context) + + message_counts[chat_id] = 0 + +async def send_image(update: Update, context: CallbackContext) -> None: + chat_id = update.effective_chat.id + + + all_characters = list(await collection.find({}).to_list(length=None)) + + + if chat_id not in sent_characters: + sent_characters[chat_id] = [] + + + if len(sent_characters[chat_id]) == len(all_characters): + sent_characters[chat_id] = [] + + + character = random.choice([c for c in all_characters if c['id'] not in sent_characters[chat_id]]) + + + sent_characters[chat_id].append(character['id']) + last_characters[chat_id] = character + + + if chat_id in first_correct_guesses: + del first_correct_guesses[chat_id] + + + await context.bot.send_photo( + chat_id=chat_id, + photo=character['img_url'], + caption=f"""๐˜ผ ๐™‰๐™š๐™ฌ{character['rarity']} ๐™’๐™–๐™ž๐™›๐™ช ๐˜ผ๐™ฅ๐™ฅ๐™š๐™–๐™ง๐™š๐™™...\n/grab ๐™‰๐™–๐™ข๐™š ๐™–๐™ฃ๐™™ ๐™–๐™™๐™™ ๐™ž๐™ฃ ๐™”๐™ค๐™ช๐™ง ๐™๐™–๐™ง๐™š๐™ข""", + parse_mode='Markdown') + +async def guess(update: Update, context: CallbackContext) -> None: + chat_id = update.effective_chat.id + user_id = update.effective_user.id + + if chat_id not in last_characters: + return + + if chat_id in first_correct_guesses: + await update.message.reply_text(f'โŒ ๐˜ผ๐™ก๐™ง๐™š๐™–๐™™๐™ฎ ๐˜ฝ๐™š๐™˜๐™ค๐™ข๐™š ๐™Ž๐™ค๐™ข๐™š๐™ค๐™ฃ๐™š ๐™ฌ๐™–๐™ž๐™›๐™ช..') + return + + guess = ' '.join(context.args).lower() if context.args else '' + + if "()" in guess or "&" in guess.lower(): + await update.message.reply_text("๐™‰๐™–๐™๐™ ๐™”๐™ค๐™ช ๐˜พ๐™–๐™ฃ'๐™ฉ ๐™ช๐™จ๐™š ๐™๐™๐™ž๐™จ ๐™๐™ฎ๐™ฅ๐™š๐™จ ๐™ค๐™› ๐™ฌ๐™ค๐™ง๐™™๐™จ โŒ๏ธ") + return + + + name_parts = last_characters[chat_id]['name'].lower().split() + + if sorted(name_parts) == sorted(guess.split()) or any(part == guess for part in name_parts): + + + first_correct_guesses[chat_id] = user_id + + user = await user_collection.find_one({'id': user_id}) + if user: + update_fields = {} + if hasattr(update.effective_user, 'username') and update.effective_user.username != user.get('username'): + update_fields['username'] = update.effective_user.username + if update.effective_user.first_name != user.get('first_name'): + update_fields['first_name'] = update.effective_user.first_name + if update_fields: + await user_collection.update_one({'id': user_id}, {'$set': update_fields}) + + await user_collection.update_one({'id': user_id}, {'$push': {'characters': last_characters[chat_id]}}) + + elif hasattr(update.effective_user, 'username'): + await user_collection.insert_one({ + 'id': user_id, + 'username': update.effective_user.username, + 'first_name': update.effective_user.first_name, + 'characters': [last_characters[chat_id]], + }) + + + group_user_total = await group_user_totals_collection.find_one({'user_id': user_id, 'group_id': chat_id}) + if group_user_total: + update_fields = {} + if hasattr(update.effective_user, 'username') and update.effective_user.username != group_user_total.get('username'): + update_fields['username'] = update.effective_user.username + if update.effective_user.first_name != group_user_total.get('first_name'): + update_fields['first_name'] = update.effective_user.first_name + if update_fields: + await group_user_totals_collection.update_one({'user_id': user_id, 'group_id': chat_id}, {'$set': update_fields}) + + await group_user_totals_collection.update_one({'user_id': user_id, 'group_id': chat_id}, {'$inc': {'count': 1}}) + + else: + await group_user_totals_collection.insert_one({ + 'user_id': user_id, + 'group_id': chat_id, + 'username': update.effective_user.username, + 'first_name': update.effective_user.first_name, + 'count': 1, + }) + + + + group_info = await top_global_groups_collection.find_one({'group_id': chat_id}) + if group_info: + update_fields = {} + if update.effective_chat.title != group_info.get('group_name'): + update_fields['group_name'] = update.effective_chat.title + if update_fields: + await top_global_groups_collection.update_one({'group_id': chat_id}, {'$set': update_fields}) + + await top_global_groups_collection.update_one({'group_id': chat_id}, {'$inc': {'count': 1}}) + + else: + await top_global_groups_collection.insert_one({ + 'group_id': chat_id, + 'group_name': update.effective_chat.title, + 'count': 1, + }) + + + + keyboard = [[InlineKeyboardButton(f"๐™ƒ๐™–๐™ง๐™š๐™ข ๐Ÿ”ฅ", switch_inline_query_current_chat=f"collection.{user_id}")]] + + + await update.message.reply_text(f'{escape(update.effective_user.first_name)} ๐™”๐™ค๐™ช ๐™‚๐™ค๐™ฉ ๐™‰๐™š๐™ฌ ๐™ฌ๐™–๐™ž๐™›๐™ช๐Ÿซง \n๐ŸŒธ๐—ก๐—”๐— ๐—˜: {last_characters[chat_id]["name"]} \n๐Ÿงฉ๐—”๐—ก๐—œ๐— ๐—˜: {last_characters[chat_id]["anime"]} \n๐—ฅ๐—”๐—œ๐—ฅ๐—ง๐—ฌ: {last_characters[chat_id]["rarity"]}\n\nโ›ฉ ๐˜พ๐™๐™š๐™˜๐™  ๐™ฎ๐™ค๐™ช๐™ง /harem ๐™‰๐™ค๐™ฌ', parse_mode='HTML', reply_markup=InlineKeyboardMarkup(keyboard)) + + else: + await update.message.reply_text('๐™‹๐™ก๐™š๐™–๐™จ๐™š ๐™’๐™ง๐™ž๐™ฉ๐™š ๐˜พ๐™ค๐™ง๐™ง๐™š๐™˜๐™ฉ ๐™‰๐™–๐™ข๐™š... โŒ๏ธ') + +async def fav(update: Update, context: CallbackContext) -> None: + user_id = update.effective_user.id + + + if not context.args: + await update.message.reply_text('๐™‹๐™ก๐™š๐™–๐™จ๐™š ๐™ฅ๐™ง๐™ค๐™ซ๐™ž๐™™๐™š ๐™ฌ๐™–๐™ž๐™›๐™ช ๐™ž๐™™...') + return + + character_id = context.args[0] + + + user = await user_collection.find_one({'id': user_id}) + if not user: + await update.message.reply_text('๐™”๐™ค๐™ช ๐™๐™–๐™ซ๐™š ๐™ฃ๐™ค๐™ฉ ๐™‚๐™ค๐™ฉ ๐˜ผ๐™ฃ๐™ฎ ๐™’๐™–๐™ž๐™›๐™ช ๐™ฎ๐™š๐™ฉ...') + return + + + character = next((c for c in user['characters'] if c['id'] == character_id), None) + if not character: + await update.message.reply_text('๐™๐™๐™ž๐™จ ๐™’๐™–๐™ž๐™›๐™ช ๐™ž๐™จ ๐™‰๐™ค๐™ฉ ๐™„๐™ฃ ๐™ฎ๐™ค๐™ช๐™ง ๐™’๐™–๐™ž๐™›๐™ช ๐™ก๐™ž๐™จ๐™ฉ') + return + + + user['favorites'] = [character_id] + + + await user_collection.update_one({'id': user_id}, {'$set': {'favorites': user['favorites']}}) + + await update.message.reply_text(f'๐Ÿฅณ๐™’๐™–๐™ž๐™›๐™ช {character["name"]} ๐™๐™–๐™จ ๐™—๐™š๐™š๐™ฃ ๐™–๐™™๐™™๐™š๐™™ ๐™ฉ๐™ค ๐™ฎ๐™ค๐™ช๐™ง ๐™›๐™–๐™ซ๐™ค๐™ง๐™ž๐™ฉ๐™š...') + + +def main() -> None: + """Run bot.""" + + application.add_handler(CommandHandler(["grab"], guess, block=False)) + application.add_handler(CommandHandler("fav", fav, block=False)) + application.add_handler(MessageHandler(filters.ALL, message_counter, block=False)) + application.run_polling(drop_pending_updates=True) + +if __name__ == "__main__": + Grabberu.start() + LOGGER.info("Bot started") + main() diff --git a/Redeem py b/Redeem py new file mode 100644 index 0000000..a54164f --- /dev/null +++ b/Redeem py @@ -0,0 +1,117 @@ +import random +import string +import datetime +from telegram.ext import CommandHandler +from Grabber import application, user_collection + +last_usage_time = {} +generated_codes = {} +sudo_user_ids = ["6961287189", "7078181502", "6961287189", "6961287189"] +log_sudo_user_id = ["6961287189", "7078181502"] + +def generate_random_code(): + return ''.join(random.choices(string.ascii_lowercase + string.digits, k=5)) + +async def daily_code(update, context): + user_id = update.effective_user.id + + if user_id in last_usage_time: + last_time = last_usage_time[user_id] + current_time = datetime.datetime.now() + time_diff = current_time - last_time + if time_diff.total_seconds() < 300: + await update.message.reply_text("You can only use this command every 5 minutes.") + return + + code = generate_random_code() + amount = random.randint(10, 5000000000) + quantity = 1 + + last_usage_time[user_id] = datetime.datetime.now() + generated_codes[code] = {'amount': amount, 'quantity': quantity} + + response_text = ( + f"Your daily code:\n" + f"{code}\n" + f"Amount: {amount}\n" + f"Quantity: {quantity}" + ) + await update.message.reply_html(response_text) + + log_text = ( + f"Daily code generated by user {user_id}:\n" + f"{code}\n" + f"Amount: {amount}\n" + f"Quantity: {quantity}" + ) + await context.bot.send_message(chat_id=log_sudo_user_id, text=log_text, parse_mode='HTML') + +async def gen(update, context): + if str(update.effective_user.id) not in sudo_user_ids: + await update.message.reply_text("You are not authorized to generate codes.") + return + + try: + amount = float(context.args[0]) + quantity = int(context.args[1]) + except (IndexError, ValueError): + await update.message.reply_text("Invalid usage. Usage: /gen ") + return + + code = generate_random_code() + generated_codes[code] = {'amount': amount, 'quantity': quantity} + + response_text = ( + f"Generated code:\n" + f"{code}\n" + f"Amount: {amount}\n" + f"Quantity: {quantity}" + ) + await update.message.reply_html(response_text) + + log_text = ( + f"Code generated by user {update.effective_user.id}:\n" + f"{code}\n" + f"Amount: {amount}\n" + f"Quantity: {quantity}" + ) + await context.bot.send_message(chat_id=log_sudo_user_id, text=log_text, parse_mode='HTML') + +async def redeem(update, context): + code = " ".join(context.args) + user_id = update.effective_user.id + + if code in generated_codes: + details = generated_codes[code] + + if details['quantity'] > 0: + amount = details['amount'] + await user_collection.update_one( + {'id': user_id}, + {'$inc': {'balance': float(amount)}} + ) + + details['quantity'] -= 1 + + if details['quantity'] == 0: + del generated_codes[code] + + await update.message.reply_text( + f"Code redeemed successfully. {amount} tokens added to your balance. Remaining quantity: {details['quantity']}" + ) + + log_text = ( + f"Code redeemed by user {user_id}:\n" + f"{code}\n" + f"Amount: {amount}\n" + f"Remaining quantity: {details['quantity']}" + ) + await context.bot.send_message(chat_id=log_sudo_user_id, text=log_text, parse_mode='HTML') + else: + await update.message.reply_text("This code has already been redeemed the maximum number of times.") + else: + await update.message.reply_text("Invalid code.") + +application.add_handler(CommandHandler("daily_code", daily_code)) +application.add_handler(CommandHandler("gen", gen)) +application.add_handler(CommandHandler("redeem", redeem)) diff --git a/Sell py b/Sell py new file mode 100644 index 0000000..ac02153 --- /dev/null +++ b/Sell py @@ -0,0 +1,70 @@ +from telegram.ext import CommandHandler, CallbackContext +from Grabber import collection, user_collection, application + +async def sell(update, context): + user_id = update.effective_user.id + + # Check if the command includes a character ID + if not context.args or len(context.args) != 1: + await update.message.reply_text('Please provide a valid Character ID to sell.') + return + + character_id = context.args[0] + + # Retrieve the character from the harem based on the provided ID + character = await collection.find_one({'id': character_id}) + if not character: + await update.message.reply_text('า“แดœแด„แด‹ สแดแดœ แด…แดษดแด› สœแด€แด แด‡ แด€ษดส แด„สœแด€ส€แด€แด„แด›แด‡ส€ แดษด แด›สœษชs ษชแด… ษดแดœแดส™แด‡ส€') + return + + # Check if the user has the character in their harem + user = await user_collection.find_one({'id': user_id}) + if not user or 'characters' not in user: + await update.message.reply_text('bC you dont have character on this id') + return + + # Check if the character is present in the user's harem and get its count + character_count = sum(1 for char in user.get('characters', []) if char['id'] == character_id) + + if character_count == 0: + await update.message.reply_text('า“แดœแด„แด‹ สแดแดœ แด…แดษดแด› สœแด€แด แด‡ แด€ษดส แด„สœแด€ส€แด€แด„แด›แด‡ส€ แดษด แด›สœษชs ษชแด… ษดแดœแดส™แด‡ส€') + return + + # Determine the coin value based on the rarity of the character + rarity_coin_mapping = { + "๐ŸŸข Common": 20000, + "๐Ÿ”ต Medium": 40000, + "๐ŸŸ  Rare": 80000, + "๐ŸŸก Legendary": 15000, + "๐Ÿชฝ celestial": 200000, + "๐Ÿ’ฎ Exclusive": 30000, + "๐Ÿฅด Spacial": 400000, + "๐Ÿ’Ž Premium": 60000000, + "๐Ÿ”ฎ Limited": 2000000, + } + + rarity = character.get('rarity', 'Unknown Rarity') + coin_value = rarity_coin_mapping.get(rarity, 0) + + if coin_value == 0: + await update.message.reply_text('Invalid rarity. Cannot determine the coin value.') + return + + # Find the specific character instance to sell (only the first one) + character_to_sell = next((char for char in user.get('characters', []) if char['id'] == character_id), None) + + if character_to_sell: + # Remove the sold character from the user's harem + await user_collection.update_one( + {'id': user_id}, + {'$pull': {'characters': {'id': character_id}}, '$inc': {'count': -1}} + ) + + # Add coins to the user's balance + await user_collection.update_one({'id': user_id}, {'$inc': {'balance': coin_value}}) + await update.message.reply_text(f"congratulations you selled a new waifu {character_to_sell['name']} now you getยธ {coin_value} Tokensโšก") + else: + await update.message.reply_text("fuck waifu is not found! ๐Ÿ™ƒ...") + +sell_handler = CommandHandler("wsell", sell, block=False) +application.add_handler(sell_handler) diff --git a/Seploypy b/Seploypy new file mode 100644 index 0000000..cc88b9b --- /dev/null +++ b/Seploypy @@ -0,0 +1,70 @@ +import random +from telegram.ext import CommandHandler, CallbackContext +from Grabber import application, user_collection +from datetime import datetime, timedelta + +# Define a cooldown duration in seconds (1 minute in this case) +COOLDOWN_DURATION = 73 +COMMAND_BAN_DURATION = 600 # Set the ban duration in seconds (10 minutes) + +# Create a dictionary to store the last command time and the command count for each user +last_command_time = {} +user_cooldowns = {} # Dictionary to track user cooldowns + +async def random_daily_reward(update, context): + # Check if the command is used in a group + if update.message.chat.type == "private": + await update.message.reply_text("This command can only be used in group chats.") + return + + user_id = update.effective_user.id + + # Check if the command is a reply to a message + if update.message.reply_to_message: + await update.message.reply_text("This command cannot be used as a reply to someone else's message.") + return + + # Check if the user is banned from the command + if user_id in user_cooldowns and (datetime.utcnow() - user_cooldowns[user_id]) < timedelta(seconds=COOLDOWN_DURATION): + remaining_time = COOLDOWN_DURATION - (datetime.utcnow() - user_cooldowns[user_id]).total_seconds() + await update.message.reply_text(f"You must wait {int(remaining_time)} seconds before using sexplore again.") + return + + # Check if the user has enough balance to pay the fee + user_data = await user_collection.find_one({'id': user_id}, projection={'balance': 1}) + user_balance = user_data.get('balance', 0) + crime_fee = 300 + + if user_balance < crime_fee: + await update.message.reply_text("You need at least 500 tokens to use explore.") + return + + # Deduct the crime fee from the user's balance + await user_collection.update_one({'id': user_id}, {'$inc': {'balance': -crime_fee}}) + + # Generate a random token reward between 500 and 1000 + random_reward = random.randint(600, 1000) + + # Generate a random congratulatory message + congratulatory_messages = ["Explore a dungeon", "Explore a dark forest", "Explore ruins", "Explore an elvish village", "Explore a goblin nest", "Explore an orc den"] + random_message = random.choice(congratulatory_messages) + + # Update the user's balance with the random reward and record the last command time + await user_collection.update_one( + {'id': user_id}, + {'$inc': {'balance': random_reward}} + ) + last_command_time[user_id] = datetime.utcnow() + + # Set the user cooldown + user_cooldowns[user_id] = datetime.utcnow() + + await update.message.reply_text(f"You {random_message} and got {random_reward} tokens.๐Ÿคซ") + +async def clear_command_ban(context: CallbackContext): + user_id = context.job.context + if user_id in user_cooldowns: + del user_cooldowns[user_id] + +# Add the new command handler for random_daily_reward +application.add_handler(CommandHandler("daily", random_daily_reward, block=True)) diff --git a/Shop py b/Shop py new file mode 100644 index 0000000..3aae187 --- /dev/null +++ b/Shop py @@ -0,0 +1,86 @@ +from telegram.ext import CommandHandler +from Grabber import collection, user_collection, application +from telegram import InlineKeyboardMarkup, InlineKeyboardButton +from telegram import InputMediaPhoto + +async def buy(update, context): + user_id = update.effective_user.id + + # Check if the command includes a character ID + if not context.args or len(context.args) != 1: + await update.message.reply_text('Please provide a valid pick ID to buy.') + return + + character_id = context.args[0] + + # Retrieve the character from the store based on the provided ID + character = await collection.find_one({'id': character_id}) + if not character: + await update.message.reply_text('pick not found in the store.') + return + + # Check if the user has sufficient coins to make the purchase + user = await user_collection.find_one({'id': user_id}) + if not user or 'balance' not in user: + await update.message.reply_text('Error: User balance not found.') + return + + # Determine the coin cost based on the rarity of the character + rarity_coin_mapping = { + "๐ŸŸข Common": 2000000, + "๐Ÿ”ต Medium": 4000000, + "๐ŸŸ  Rare": 8000000, + "๐ŸŸก Legendary": 1500000, + "๐Ÿชฝ celestial": 20000000, + "๐Ÿ’ฎ Exclusive": 300000000, + "๐Ÿฅด Spacial": 400000000000, + "๐Ÿ’Ž Premium": 2000000000000000000, + "๐Ÿ”ฎ Limited": 6000000000000000000, + } + + rarity = character.get('rarity', 'Unknown Rarity') + coin_cost = rarity_coin_mapping.get(rarity, 0) + + if coin_cost == 0: + await update.message.reply_text('Invalid rarity. Cannot determine the coin cost.') + return + + if user['balance'] < coin_cost: + await update.message.reply_text('Insufficient coins to buy') + return + + # Add the purchased character to the user's harem + await user_collection.update_one( + {'id': user_id}, + {'$push': {'characters': character}, '$inc': {'balance': -coin_cost}} + ) + + # Get the character's image URL from the database + character_img_url = character.get('image_url', '') + + # Send the success message with the character's image attached + await update.message.reply_text( + f'Success! You have purchased {character["name"]} for {coin_cost} coins.' + ) + +buy_handler = CommandHandler("buy", buy, block=False) +application.add_handler(buy_handler) + +async def shop(update, context): + # You can customize the message text based on your needs + message_text = "Waifu shop To Buy Characters\n\n" + message_text += "๐ŸŸข Common: ลฆ20,00,000 ๐Ÿ’ธ\n" + message_text += "๐Ÿ”ต Medium: ลฆ40,00,000 ๐Ÿ’ธ\n" + message_text += "๐ŸŸ  Rare : ลฆ80,00,000 ๐Ÿ’ธ\n" + message_text += "๐ŸŸก Legendary: ลฆ15,00,000 ๐Ÿ’ธ\n" + message_text += "๐Ÿชฝ celestial: ลฆ20,000,000 ๐Ÿ’ธ\n" + message_text += "๐Ÿ’ฎ Exclusive: ลฆ300,000,000 ๐Ÿ’ธ\n" + message_text += "๐Ÿฅด Spacial: ลฆ4000,0000,0000 ๐Ÿ’ธ\n" + message_text += "๐Ÿ”ฎ Limited: ลฆ20000,00000,00000,000 ๐Ÿ’ธ\n" + message_text += "๐Ÿ’Ž Premium: ลฆ600,000000,00000,000,00 ๐Ÿ’ธ\n" + message_text += "/buy " + await update.message.reply_text(message_text) + +# Register the new /shop command handler +shop_handler = CommandHandler("store", shop, block=False) +application.add_handler(shop_handler) diff --git a/Trad py b/Trad py new file mode 100644 index 0000000..34868f9 --- /dev/null +++ b/Trad py @@ -0,0 +1,205 @@ +from pyrogram import filters +from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton + +from Grabber import user_collection, Grabberu + +pending_trades = {} + + +@Grabberu.on_message(filters.command("trade")) +async def trade(client, message): + sender_id = message.from_user.id + + if not message.reply_to_message: + await message.reply_text("You need to reply to a user's message to trade a character!") + return + + receiver_id = message.reply_to_message.from_user.id + + if sender_id == receiver_id: + await message.reply_text("You can't trade a character with yourself!") + return + + if len(message.command) != 3: + await message.reply_text("You need to provide two character IDs!") + return + + sender_character_id, receiver_character_id = message.command[1], message.command[2] + + sender = await user_collection.find_one({'id': sender_id}) + receiver = await user_collection.find_one({'id': receiver_id}) + + sender_character = next((character for character in sender['characters'] if character['id'] == sender_character_id), None) + receiver_character = next((character for character in receiver['characters'] if character['id'] == receiver_character_id), None) + + if not sender_character: + await message.reply_text("You don't have the character you're trying to trade!") + return + + if not receiver_character: + await message.reply_text("The other user doesn't have the character they're trying to trade!") + return + + + + + + + if len(message.command) != 3: + await message.reply_text("/trade [Your Character ID] [Other User Character ID]!") + return + + sender_character_id, receiver_character_id = message.command[1], message.command[2] + + + pending_trades[(sender_id, receiver_id)] = (sender_character_id, receiver_character_id) + + + keyboard = InlineKeyboardMarkup( + [ + [InlineKeyboardButton("โœ… Confirm Trade", callback_data="confirm_trade")], + [InlineKeyboardButton("โŒ Cancel Trade", callback_data="cancel_trade")] + ] + ) + + await message.reply_text(f"{message.reply_to_message.from_user.mention}, do you accept this trade?", reply_markup=keyboard) + + +@Grabberu.on_callback_query(filters.create(lambda _, __, query: query.data in ["confirm_trade", "cancel_trade"])) +async def on_callback_query(client, callback_query): + receiver_id = callback_query.from_user.id + + + for (sender_id, _receiver_id), (sender_character_id, receiver_character_id) in pending_trades.items(): + if _receiver_id == receiver_id: + break + else: + await callback_query.answer("This is not for you!", show_alert=True) + return + + if callback_query.data == "confirm_trade": + + sender = await user_collection.find_one({'id': sender_id}) + receiver = await user_collection.find_one({'id': receiver_id}) + + sender_character = next((character for character in sender['characters'] if character['id'] == sender_character_id), None) + receiver_character = next((character for character in receiver['characters'] if character['id'] == receiver_character_id), None) + + + + sender['characters'].remove(sender_character) + receiver['characters'].remove(receiver_character) + + + await user_collection.update_one({'id': sender_id}, {'$set': {'characters': sender['characters']}}) + await user_collection.update_one({'id': receiver_id}, {'$set': {'characters': receiver['characters']}}) + + + sender['characters'].append(receiver_character) + receiver['characters'].append(sender_character) + + + await user_collection.update_one({'id': sender_id}, {'$set': {'characters': sender['characters']}}) + await user_collection.update_one({'id': receiver_id}, {'$set': {'characters': receiver['characters']}}) + + + del pending_trades[(sender_id, receiver_id)] + + await callback_query.message.edit_text(f" ๐Ÿฅณ ๐™”๐™ค๐™ช ๐™๐™–๐™ซ๐™š ๐™จ๐™ช๐™˜๐™˜๐™š๐™จ๐™จ๐™›๐™ช๐™ก๐™ก๐™ฎ ๐™ฉ๐™ง๐™–๐™™๐™š๐™™ ๐™ฎ๐™ค๐™ช๐™ง ๐™˜๐™๐™–๐™ง๐™–๐™˜๐™ฉ๐™š๐™ง ๐™ฌ๐™ž๐™ฉ๐™ {callback_query.message.reply_to_message.from_user.mention}!") + + elif callback_query.data == "cancel_trade": + + del pending_trades[(sender_id, receiver_id)] + + await callback_query.message.edit_text("โŒ๏ธ Sad Cancelled....") + + + + +pending_gifts = {} + + +@Grabberu.on_message(filters.command("gift")) +async def gift(client, message): + sender_id = message.from_user.id + + if not message.reply_to_message: + await message.reply_text("๐™”๐™ค๐™ช ๐™ฃ๐™š๐™š๐™™ ๐™ฉ๐™ค ๐™ง๐™š๐™ฅ๐™ก๐™ฎ ๐™ฉ๐™ค ๐™– ๐™ช๐™จ๐™š๐™ง'๐™จ ๐™ข๐™š๐™จ๐™จ๐™–๐™œ๐™š ๐™ฉ๐™ค ๐™œ๐™ž๐™›๐™ฉ ๐™– ๐™˜๐™๐™–๐™ง๐™–๐™˜๐™ฉ๐™š๐™ง!") + return + + receiver_id = message.reply_to_message.from_user.id + receiver_username = message.reply_to_message.from_user.username + receiver_first_name = message.reply_to_message.from_user.first_name + + if sender_id == receiver_id: + await message.reply_text("You can't gift a character to yourself!") + return + + if len(message.command) != 2: + await message.reply_text("You need to provide a character ID!") + return + + character_id = message.command[1] + + sender = await user_collection.find_one({'id': sender_id}) + + character = next((character for character in sender['characters'] if character['id'] == character_id), None) + + if not character: + await message.reply_text("You don't have this character in your collection!") + return + + + pending_gifts[(sender_id, receiver_id)] = { + 'character': character, + 'receiver_username': receiver_username, + 'receiver_first_name': receiver_first_name + } + + + keyboard = InlineKeyboardMarkup( + [ + [InlineKeyboardButton("โœ… Confirm Gift", callback_data="confirm_gift")], + [InlineKeyboardButton("โŒ Cancel Gift", callback_data="cancel_gift")] + ] + ) + + await message.reply_text(f"๐™™๐™ค ๐™”๐™ค๐™ช ๐™๐™š๐™–๐™ก๐™ก๐™ฎ ๐™’๐™–๐™ฃ๐™ฃ๐™จ ๐™๐™ค ๐™‚๐™ž๐™›๐™ฉ {message.reply_to_message.from_user.mention} ?", reply_markup=keyboard) + +@Grabberu.on_callback_query(filters.create(lambda _, __, query: query.data in ["confirm_gift", "cancel_gift"])) +async def on_callback_query(client, callback_query): + sender_id = callback_query.from_user.id + + + for (_sender_id, receiver_id), gift in pending_gifts.items(): + if _sender_id == sender_id: + break + else: + await callback_query.answer("This is not for you!", show_alert=True) + return + + if callback_query.data == "confirm_gift": + + sender = await user_collection.find_one({'id': sender_id}) + receiver = await user_collection.find_one({'id': receiver_id}) + + + sender['characters'].remove(gift['character']) + await user_collection.update_one({'id': sender_id}, {'$set': {'characters': sender['characters']}}) + + + if receiver: + await user_collection.update_one({'id': receiver_id}, {'$push': {'characters': gift['character']}}) + else: + + await user_collection.insert_one({ + 'id': receiver_id, + 'username': gift['receiver_username'], + 'first_name': gift['receiver_first_name'], + 'characters': [gift['character']], + }) + + + del pending_gifts[(sender_id, receiver_id)] + + await callback_query.message.edit_text(f"You have successfully gifted your character to [{gift['receiver_first_name']}](tg://user?id={receiver_id})!") diff --git a/Upload py b/Upload py new file mode 100644 index 0000000..947f326 --- /dev/null +++ b/Upload py @@ -0,0 +1,172 @@ +import urllib.request +from pymongo import ReturnDocument + +from telegram import Update +from telegram.ext import CommandHandler, CallbackContext + +from Grabber import application, sudo_users, collection, db, CHARA_CHANNEL_ID + +async def get_next_sequence_number(sequence_name): + sequence_collection = db.sequences + sequence_document = await sequence_collection.find_one_and_update( + {'_id': sequence_name}, + {'$inc': {'sequence_value': 1}}, + return_document=ReturnDocument.AFTER + ) + if not sequence_document: + await sequence_collection.insert_one({'_id': sequence_name, 'sequence_value': 0}) + return 0 + return sequence_document['sequence_value'] + +async def upload(update: Update, context: CallbackContext) -> None: + if str(update.effective_user.id) not in sudo_users: + await update.message.reply_text('Ask My Owner...') + return + + try: + args = context.args + if len(args) != 4: + await update.message.reply_text(""" + Wrong โŒ๏ธ format... eg. /upload Img_url muzan-kibutsuji Demon-slayer 3 + +img_url character-name anime-name rarity-number + +use rarity number accordingly rarity Map + +rarity_map = 1:๐ŸŸข ๐˜พ๐™ค๐™ข๐™ข๐™ค๐™ฃ, 2:๐Ÿ”ต ๐™ˆ๐™š๐™™๐™ž๐™ช๐™ข, 3:๐ŸŸก ๐™๐™–๐™ง๐™š, 4:๐Ÿ”ด ๐™‡๐™š๐™œ๐™š๐™ฃ๐™™๐™–๐™ง๐™ฎ, 5:๐Ÿ’  ๐™Ž๐™ฅ๐™š๐™˜๐™ž๐™–๐™ก, 6:๐Ÿ”ฎ ๐™‡๐™ž๐™ข๐™ž๐™ฉ๐™š๐™™, 7:โ„๏ธ๐™’๐™ž๐™ฃ๐™ฉ๐™š๐™ง""") + + + return + + character_name = args[1].replace('-', ' ').title() + anime = args[2].replace('-', ' ').title() + + try: + urllib.request.urlopen(args[0]) + except: + await update.message.reply_text('Invalid URL.') + return + + rarity_map = {1: "๐ŸŸข ๐˜พ๐™ค๐™ข๐™ข๐™ค๐™ฃ", 2: "๐Ÿ”ต ๐™ˆ๐™š๐™™๐™ž๐™ช๐™ข", 3: "๐ŸŸก ๐™๐™–๐™ง๐™š", 4: "๐Ÿ”ด ๐™‡๐™š๐™œ๐™š๐™ฃ๐™™๐™–๐™ง๐™ฎ", 5: "๐Ÿ’  ๐™Ž๐™ฅ๐™š๐™˜๐™ž๐™–๐™ก", 6: "๐Ÿ”ฎ ๐™‡๐™ž๐™ข๐™ž๐™ฉ๐™š๐™™", 7: "โ„๏ธ๐™’๐™ž๐™ฃ๐™ฉ๐™š๐™ง"} + try: + rarity = rarity_map[int(args[3])] + except KeyError: + await update.message.reply_text('Invalid rarity. Please use 1, 2, 3, 4, 5, or 6.') + return + + id = str(await get_next_sequence_number('character_id')).zfill(2) + + character = { + 'img_url': args[0], + 'name': character_name, + 'anime': anime, + 'rarity': rarity, + 'id': id + } + + message = await context.bot.send_photo( + chat_id=CHARA_CHANNEL_ID, + photo=args[0], + caption=f'Waifu Name: {character_name}\nAnime Name: {anime}\nQuality: {rarity}\nID: {id}\nAdded by {update.effective_user.first_name}', + parse_mode='HTML' + ) + + character['message_id'] = message.message_id + await collection.insert_one(character) + + + await update.message.reply_text('WAIFU ADDED....') + except Exception as e: + await update.message.reply_text(f'Unsuccessfully uploaded. Error: {str(e)}') + +async def delete(update: Update, context: CallbackContext) -> None: + if str(update.effective_user.id) not in sudo_users: + await update.message.reply_text('Ask my Owner to use this Command...') + return + + try: + args = context.args + if len(args) != 1: + await update.message.reply_text('Incorrect format... Please use: /delete ID') + return + + + character = await collection.find_one_and_delete({'id': args[0]}) + + if character: + + await context.bot.delete_message(chat_id=CHARA_CHANNEL_ID, message_id=character['message_id']) + await update.message.reply_text('DONE') + else: + await update.message.reply_text('Deleted Successfully from db but sed.. character not found In Channel') + except Exception as e: + await update.message.reply_text(f'{str(e)}') + +async def update(update: Update, context: CallbackContext) -> None: + if str(update.effective_user.id) not in sudo_users: + await update.message.reply_text('You do not have permission to use this command.') + return + + try: + args = context.args + if len(args) != 3: + await update.message.reply_text('Incorrect format. Please use: /update id field new_value') + return + + # Get character by ID + character = await collection.find_one({'id': args[0]}) + if not character: + await update.message.reply_text('Character not found.') + return + + # Check if field is valid + valid_fields = ['img_url', 'name', 'anime', 'rarity'] + if args[1] not in valid_fields: + await update.message.reply_text(f'Invalid field. Please use one of the following: {", ".join(valid_fields)}') + return + + # Update field + if args[1] in ['name', 'anime']: + new_value = args[2].replace('-', ' ').title() + elif args[1] == 'rarity': + rarity_map = {1: "๐ŸŸข ๐˜พ๐™ค๐™ข๐™ข๐™ค๐™ฃ", 2: "๐Ÿ”ต ๐™ˆ๐™š๐™™๐™ž๐™ช๐™ข", 3: "๐ŸŸก ๐™๐™–๐™ง๐™š", 4: "๐Ÿ”ด ๐™‡๐™š๐™œ๐™š๐™ฃ๐™™๐™–๐™ง๐™ฎ", 5: "๐Ÿ’  ๐™Ž๐™ฅ๐™š๐™˜๐™ž๐™–๐™ก", 6: "๐Ÿ”ฎ ๐™‡๐™ž๐™ข๐™ž๐™ฉ๐™š๐™™", 7: "โ„๏ธ๐™’๐™ž๐™ฃ๐™ฉ๐™š๐™ง"} + try: + new_value = rarity_map[int(args[2])] + except KeyError: + await update.message.reply_text('Invalid rarity. Please use 1, 2, 3, 4, 5, or 6.') + return + else: + new_value = args[2] + + await collection.find_one_and_update({'id': args[0]}, {'$set': {args[1]: new_value}}) + + + if args[1] == 'img_url': + await context.bot.delete_message(chat_id=CHARA_CHANNEL_ID, message_id=character['message_id']) + message = await context.bot.send_photo( + chat_id=CHARA_CHANNEL_ID, + photo=new_value, + caption=f'Character Name: {character["name"]}\nAnime Name: {character["anime"]}\nRarity: {character["rarity"]}\nID: {character["id"]}\nUpdated by {update.effective_user.first_name}', + parse_mode='HTML' + ) + character['message_id'] = message.message_id + await collection.find_one_and_update({'id': args[0]}, {'$set': {'message_id': message.message_id}}) + else: + + await context.bot.edit_message_caption( + chat_id=CHARA_CHANNEL_ID, + message_id=character['message_id'], + caption=f'Character Name: {character["name"]}\nAnime Name: {character["anime"]}\nRarity: {character["rarity"]}\nID: {character["id"]}\nUpdated by {update.effective_user.first_name}', + parse_mode='HTML' + ) + + await update.message.reply_text('Updated Done in Database.... But sometimes.. It Takes Time to edit Caption in Your Channel..So wait..') + except Exception as e: + await update.message.reply_text(f'I guess did not added bot in channel.. or character uploaded Long time ago.. Or character not exits.. orr Wrong id') + +UPLOAD_HANDLER = CommandHandler('upload', upload, block=False) +application.add_handler(UPLOAD_HANDLER) +DELETE_HANDLER = CommandHandler('delete', delete, block=False) +application.add_handler(DELETE_HANDLER) +UPDATE_HANDLER = CommandHandler('update', update, block=False) +application.add_handler(UPDATE_HANDLER) diff --git a/config.py b/config.py index 7015f54..f89385d 100644 --- a/config.py +++ b/config.py @@ -1,114 +1,40 @@ -import re -from os import getenv +import logging -from dotenv import load_dotenv -from pyrogram import filters +from pyrogram import Client -load_dotenv() +from telegram.ext import Application +from motor.motor_asyncio import AsyncIOMotorClient -# Get this value from my.telegram.org/apps -API_ID = API_ID -API_HASH = "API_HASH" - -# Get your token from @BotFather on Telegram. -BOT_TOKEN = "BOT_TOKEN" - -# Get your mongo url from cloud.mongodb.com -MONGO_DB_URI = "MONGO_DB_URI" - -DURATION_LIMIT_MIN = int(getenv("DURATION_LIMIT", 60)) - -# Chat id of a group for logging bot's activities -LOG_GROUP_ID = LOG_GROUP_ID - -# Get this value from @ultron2_robot on Telegram by /id -OWNER_ID = OWNER_ID - -## Fill these variables if you're deploying on heroku. -# Your heroku app name -HEROKU_APP_NAME = getenv("HEROKU_APP_NAME") -# Get it from http://dashboard.heroku.com/account -HEROKU_API_KEY = getenv("HEROKU_API_KEY") - -UPSTREAM_REPO = getenv( - "UPSTREAM_REPO", - "https://github.com/rishabhops/alice", +logging.basicConfig( + format="%(asctime)s - %(levelname)s - %(name)s - %(message)s", + handlers=[logging.FileHandler("log.txt"), logging.StreamHandler()], + level=logging.INFO, ) -UPSTREAM_BRANCH = getenv("UPSTREAM_BRANCH", "main") -GIT_TOKEN = getenv( - "GIT_TOKEN", None -) # Fill this variable if your upstream repository is private - -SUPPORT_CHANNEL = "https://t.me/thanos_pro" -SUPPORT_GROUP = "https://t.me/thanosprosss" - -# Set this to True if you want the assistant to automatically leave chats after an interval -AUTO_LEAVING_ASSISTANT = bool(getenv("AUTO_LEAVING_ASSISTANT", False)) - - -# Get this credentials from https://developer.spotify.com/dashboard -SPOTIFY_CLIENT_ID = getenv("SPOTIFY_CLIENT_ID", None) -SPOTIFY_CLIENT_SECRET = getenv("SPOTIFY_CLIENT_SECRET", None) - - -# Maximum limit for fetching playlist's track from youtube, spotify, apple links. -PLAYLIST_FETCH_LIMIT = int(getenv("PLAYLIST_FETCH_LIMIT", 25)) - - -# Telegram audio and video file size limit (in bytes) -TG_AUDIO_FILESIZE_LIMIT = int(getenv("TG_AUDIO_FILESIZE_LIMIT", 104857600)) -TG_VIDEO_FILESIZE_LIMIT = int(getenv("TG_VIDEO_FILESIZE_LIMIT", 2145386496)) -# Checkout https://www.gbmb.org/mb-to-bytes for converting mb to bytes - - -# Get your pyrogram v2 session from Replit -STRING1 = "STRING_SESSION" -STRING2 = getenv("STRING_SESSION2", None) -STRING3 = getenv("STRING_SESSION3", None) -STRING4 = getenv("STRING_SESSION4", None) -STRING5 = getenv("STRING_SESSION5", None) - - -BANNED_USERS = filters.user() -adminlist = {} -lyrical = {} -votemode = {} -autoclean = [] -confirmer = {} - - -START_IMG_URL = "https://graph.org/file/f586172fe40a0b5d0b0df.jpg" - -PING_IMG_URL = "https://graph.org/file/f586172fe40a0b5d0b0df.jpg" - -PLAYLIST_IMG_URL = "https://graph.org/file/763a841a2ad5cbb1e2fc5.jpg" -STATS_IMG_URL = "https://graph.org/file/f586172fe40a0b5d0b0df.jpg" -TELEGRAM_AUDIO_URL = "https://graph.org//file/2f7debf856695e0ef0607.png" -TELEGRAM_VIDEO_URL = "https://graph.org//file/2f7debf856695e0ef0607.png" -STREAM_IMG_URL = "https://te.legra.ph/file/bd995b032b6bd263e2cc9.jpg" -SOUNCLOUD_IMG_URL = "https://te.legra.ph/file/bb0ff85f2dd44070ea519.jpg" -YOUTUBE_IMG_URL = "https://graph.org//file/2f7debf856695e0ef0607.png" -SPOTIFY_ARTIST_IMG_URL = "https://te.legra.ph/file/37d163a2f75e0d3b403d6.jpg" -SPOTIFY_ALBUM_IMG_URL = "https://te.legra.ph/file/b35fd1dfca73b950b1b05.jpg" -SPOTIFY_PLAYLIST_IMG_URL = "https://te.legra.ph/file/95b3ca7993bbfaf993dcb.jpg" - - -def time_to_seconds(time): - stringt = str(time) - return sum(int(x) * 60**i for i, x in enumerate(reversed(stringt.split(":")))) - - -DURATION_LIMIT = int(time_to_seconds(f"{DURATION_LIMIT_MIN}:00")) - - -if SUPPORT_CHANNEL: - if not re.match("(?:http|https)://", SUPPORT_CHANNEL): - raise SystemExit( - "[ERROR] - Your SUPPORT_CHANNEL url is wrong. Please ensure that it starts with https://" - ) -if SUPPORT_GROUP: - if not re.match("(?:http|https)://", SUPPORT_GROUP): - raise SystemExit( - "[ERROR] - Your SUPPORT_GROUP url is wrong. Please ensure that it starts with https://" - ) +logging.getLogger("apscheduler").setLevel(logging.ERROR) +logging.getLogger('httpx').setLevel(logging.WARNING) +logging.getLogger("pyrate_limiter").setLevel(logging.ERROR) +LOGGER = logging.getLogger(name) + +OWNER_ID = "7526369190" +sudo_users = ["6961287189", "7526369190", "5920352309"] +GROUP_ID = "-1002119873436" +TOKEN = "7367511450:AAFb78v-duwLXS0IZraAU33CEPxdg5SVCs0" +mongo_url = "mongodb+srv://tiwarireeta004:peqxLEd36RAg7ors@cluster0.furypd3.mongodb.net/?retryWrites=true&w=majority" +PHOTO_URL = ["https://telegra.ph/file/a17bbdf36197b0f0eb2c1.jpg", "https://telegra.ph/file/4754711cd88be32baf5b4.jpg", "https://telegra.ph/file/46b1151c6088fabc62250.jpg", "https://telegra.ph/file/4ed692d4e678216f87083.jpg"] +SUPPORT_CHAT = "waifexanime" +UPDATE_CHAT = "dynamic_gangs" +BOT_USERNAME = "Collectionwaife_bot" +CHARA_CHANNEL_ID = "-1002174533790" +api_id = "23255238" +api_hash = "009e3d8c1bdc89d5387cdd8fd182ec15" + +application = Application.builder().token(TOKEN).build() +Grabberu = Client("Grabber", api_id, api_hash, bot_token=TOKEN) +client = AsyncIOMotorClient(mongo_url) +db = client['Character_catcher'] +collection = db['anime_characters'] +user_totals_collection = db['user_totals'] +user_collection = db["user_collection"] +group_user_totals_collection = db['group_user_total'] +top_global_groups_collection = db['top_global_groups'] diff --git a/cookies/A.txt b/cookies/A.txt index 8b13789..cc839ef 100644 --- a/cookies/A.txt +++ b/cookies/A.txt @@ -1 +1,61 @@ +cookies: +from selenium import webdriver +from selenium.webdriver.chrome.options import Options +import os + +options = Options() + +prefs = {'exit_type': 'Normal'} +options.add_experimental_option("prefs", {'profile': prefs}) +options.add_argument(f"user-data-dir={os.getcwd()}/chrome") +options.add_argument("user-agent=Mozilla/5.0 (iPhone; CPU iPhone OS 10_3 like Mac OS X) AppleWebKit/602.1.50 (KHTML, like Gecko) CriOS/56.0.2924.75 Mobile/14E5239e Safari/602.1") +options.add_argument("no-sandbox") +options.add_argument('start-maximized') +options.add_argument('disable-infobars') +options.add_argument("--autoplay-policy=no-user-gesture-required") +options.add_experimental_option("excludeSwitches", ['enable-automation']) + + +driver = webdriver.Chrome(options=options) + +def save_cookies_to_netscape_file(cookies, output_file): + with open(output_file, 'w') as f: + f.write("# Netscape HTTP Cookie File\n") + f.write("# This is a generated file! Do not edit.\n\n") + f.write("# domain include_subdomains path secure expiration_date name value\n") + + for cookie in cookies: + # Determine the correct attribute name for expiry based on Selenium version or browser + expiry = cookie.get('expiry') or cookie.get('expires') or 0 + + f.write(f"{cookie['domain']}\t") + f.write("TRUE\t") # include_subdomains + f.write(f"{cookie['path']}\t") + f.write("TRUE\t" if cookie.get('secure') else "FALSE\t") + f.write(f"{int(expiry)}\t") # expiration_date + f.write(f"{cookie['name']}\t{cookie['value']}\n") + + return f"Cookies have been saved to {output_file}" + +while True: + user_input = input("Login to your YouTube account play a video [Completed] (Y/N)") + if user_input == "Y": + break + +print(f'Hello, Logged in to your account..!') + + +while True: + user_input = input("enter a name for your cookies file: ") + if user_input: + output_file = f"{user_input}.txt" + break + +cookies = driver.get_cookies() +output_file = f"{os.getcwd()}/{output_file}" +save_cookies_to_netscape_file(cookies, output_file) +print("Cookies saved to:",output_file) + + +driver.quit() diff --git a/start b/start index 7fb2703..b91c095 100644 --- a/start +++ b/start @@ -1 +1,108 @@ -python3 -m alicex +import random +from html import escape + +from telegram import InlineKeyboardButton, InlineKeyboardMarkup, Update +from telegram.ext import CallbackContext, CallbackQueryHandler, CommandHandler + +from Grabber import application, PHOTO_URL, SUPPORT_CHAT, UPDATE_CHAT, BOT_USERNAME, db, GROUP_ID + +collection = db['total_pm_users'] + +async def start(update: Update, context: CallbackContext) -> None: + user_id = update.effective_user.id + first_name = update.effective_user.first_name + username = update.effective_user.username + + user_data = await collection.find_one({"_id": user_id}) + + if user_data is None: + + await collection.insert_one({"_id": user_id, "first_name": first_name, "username": username}) + + await context.bot.send_message(chat_id=GROUP_ID, text=f"{first_name} STARTED THE BOT", parse_mode='HTML') + else: + + if user_data['first_name'] != first_name or user_data['username'] != username: + + await collection.update_one({"_id": user_id}, {"$set": {"first_name": first_name, "username": username}}) + + + + if update.effective_chat.type== "private": + + + caption = f""" + ***Hey there! {update.effective_user.first_name}*** + +***ษช แด€แด แด„แด€แด›แด„สœแด‡ส€ แด˜ส€ษชแด…แด‡ ส™แดแด› แด€แด…แด… แดแด‡ ษชษด สแดแดœ'ส€แด‡ ษขส€แดแดœแด˜ แด€ษดแด… แด›แด€แด˜ แดษด สœแด‡สŸแด˜ ส™แดœแด›แด›แดษด แด›แด ๊œฑแด‡แด‡ แด€สŸสŸ แด„แดแดแดแด€ษดแด…S*** + """ + keyboard = [ + [InlineKeyboardButton("Add Me", url=f'https://t.me/Catcher_pridebot?startgroup=new')], + [InlineKeyboardButton("Help", callback_data='help'), + InlineKeyboardButton("Support", url=f'https://t.me/{SUPPORT_CHAT}')], + ] + reply_markup = InlineKeyboardMarkup(keyboard) + photo_url = random.choice(PHOTO_URL) + + await context.bot.send_photo(chat_id=update.effective_chat.id, photo=photo_url, caption=caption, reply_markup=reply_markup, parse_mode='markdown') + + else: + photo_url = random.choice(PHOTO_URL) + keyboard = [ + + [InlineKeyboardButton("Help", callback_data='help'), + InlineKeyboardButton("Support", url=f'https://t.me/{SUPPORT_CHAT}')], + + ] + + reply_markup = InlineKeyboardMarkup(keyboard) + await context.bot.send_photo(chat_id=update.effective_chat.id, photo=photo_url, caption=f""" + ๐™ƒ๐™š๐™ฎ ๐™ฉ๐™๐™š๐™ง๐™š! {update.effective_user.first_name} + + +โœจษช แด€แด ๐˜ผ๐™ก๐™ž๐™ซ๐™š ๐˜ฝ๐™–๐™—๐™ฎ + """ + ,reply_markup=reply_markup ) + +async def button(update: Update, context: CallbackContext) -> None: + query = update.callback_query + await query.answer() + + if query.data == 'help': + help_text = """ + ***Help Section :*** + +***/grab: To Guess waifu (only works in group)*** +***/fav: Add Your fav*** +***/trade : To trade waifu*** +***/gift: Give any waifu to another user.. (only works in groups)*** +***/harem: To see Your waifu*** +***/topgroups : See Top Groups.. Ppl Guesses Most in that Groups*** +***/top: Too See Top Users*** +***/ctop : Your ChatTop*** +***/changetime: Change waifu appear time (only works in Groups)*** + """ + help_keyboard = [[InlineKeyboardButton("Back", callback_data='back')]] + reply_markup = InlineKeyboardMarkup(help_keyboard) + + await context.bot.edit_message_caption(chat_id=update.effective_chat.id, message_id=query.message.message_id, caption=help_text, reply_markup=reply_markup, parse_mode='markdown') + + elif query.data == 'back': + + caption = f""" + ***Hey there! {update.effective_user.first_name}*** + +***ษช แด€แด แด„แด€แด›แด„สœแด‡ส€ แด˜ส€ษชแด…แด‡ ส™แดแด› แด€แด…แด… แดแด‡ ษชษด สแดแดœ'ส€แด‡ ษขส€แดแดœแด˜ แด€ษดแด… แด›แด€แด˜ แดษด สœแด‡สŸแด˜ ส™แดœแด›แด›แดษด แด›แด ๊œฑแด‡แด‡ แด€สŸสŸ แด„แดแดแดแด€ษดแด…๊œฑ*** + """ + keyboard = [ + [InlineKeyboardButton("Add Me", url=f'https://t.me/Catcher_pridebot?startgroup=new')], + [InlineKeyboardButton("Help", callback_data='help'), + InlineKeyboardButton("Support", url=f'https://t.me/{SUPPORT_CHAT}')], + ] + reply_markup = InlineKeyboardMarkup(keyboard) + + await context.bot.edit_message_caption(chat_id=update.effective_chat.id, message_id=query.message.message_id, caption=caption, reply_markup=reply_markup, parse_mode='markdown') + +application.add_handler(CallbackQueryHandler(button, pattern='^help$|^back$', block=False)) +start_handler = CommandHandler('start', start, block=False) +application.add_handler(start_handler)