from pyrogram import Client, filters
from pyrogram.types import Message
import io
import sys

api_id = "your api id get it from https://my.telegram.org/apps"
api_hash = "your api hash get it from https://my.telegram.org/apps"
bot_token = "your token"

app = Client(bot_token, api_id=api_id, api_hash=api_hash)

# Handler for /eval command
@app.on_message(filters.command("eval"))
async def evaluate_code(client: Client, message: Message):
    # Extract the code from the message
    code = message.text.split(" ", maxsplit=1)[1]

    try:
        # Redirect standard output to a variable
        stdout = io.StringIO()
        sys.stdout = stdout

        # Execute the code
        exec(code)

        # Restore standard output
        sys.stdout = sys.__stdout__

        # Get the captured output
        output = stdout.getvalue()

        # Send the output back to the group
        await message.reply(f"Result: {output}")
    except Exception as e:
        # If there's an error, send the error message back to the group
        client.send_message(
            chat_id=message.chat.id,
            text=f"Error: {str(e)}",
            reply_to_message_id=message.message_id,
        )


# Start the client
app.run()

Execution Bot/main.py
anupammaurya6767/Botzy
import os
import telegram
from telegram.ext import Updater, CommandHandler, MessageHandler, Filters
import libtorrent as lt
import time

# Telegram bot token (replace with your own token)
TOKEN = "your_telegram_token"

# Path to the directory where downloaded torrents will be saved
DOWNLOAD_PATH = "path_to_download_directory"

# Initialize the Telegram bot
bot = telegram.Bot(token=TOKEN)

# Dictionary to store torrent handles
torrent_handles = {}

# Function to handle the '/start' command
def start(update, context):
    context.bot.send_message(
        chat_id=update.effective_chat.id, text="Welcome to the Torrent Downloader Bot!"
    )

# Function to handle torrent download command
def download_torrent(update, context):
    # Get the user's message
    message = update.message.text

    # Extract the torrent link
    torrent_link = message.split(" ")[1]

    # Create a session for torrent downloading
    ses = lt.session()

    # Set download directory
    ses.set_download_settings({"save_path": DOWNLOAD_PATH})

    # Add the torrent to the session
    handle = lt.add_magnet_uri(ses, torrent_link)

    # Start downloading the torrent
    ses.start_dht()
    ses.start_lsd()
    ses.start_upnp()
    ses.start_natpmp()

    # Check if the torrent has been successfully added
    if handle.is_valid():
        # Set download location for the torrent
        handle.set_download_mode(lt.torrent_handle.download_mode_t(1))
        
        # Save the handle for future reference
        torrent_handles[update.effective_chat.id] = handle

        update.message.reply_text("Downloading the torrent...")
    else:
        update.message.reply_text("Invalid torrent link.")

# Function to check download progress
def progress(update, context):
    if update.effective_chat.id not in torrent_handles:
        update.message.reply_text("No active downloads.")
        return

    handle = torrent_handles[update.effective_chat.id]
    status = handle.status()
    progress = int(status.progress * 100)
    update.message.reply_text(f"Download Progress: {progress}%")

# Function to list downloaded torrents
def list_torrents(update, context):
    torrent_list = os.listdir(DOWNLOAD_PATH)
    if not torrent_list:
        update.message.reply_text("No downloaded torrents.")
        return

    update.message.reply_text("List of downloaded torrents:")
    for torrent in torrent_list:
        update.message.reply_text(torrent)

# Function to pause an ongoing download
def pause(update, context):
    if update.effective_chat.id not in torrent_handles:
        update.message.reply_text("No active downloads to pause.")
        return

    handle = torrent_handles[update.effective_chat.id]
    handle.pause()
    update.message.reply_text("Download paused.")

# Function to resume a paused download
def resume(update, context):
    if update.effective_chat.id not in torrent_handles:
        update.message.reply_text("No paused downloads to resume.")
        return

    handle = torrent_handles[update.effective_chat.id]
    handle.resume()
    update.message.reply_text("Download resumed.")

# Function to cancel and remove a download
def cancel(update, context):
    if update.effective_chat.id not in torrent_handles:
        update.message.reply_text("No active downloads to cancel.")
        return

    handle = torrent_handles[update.effective_chat.id]
    handle.abort()
    del torrent_handles[update.effective_chat.id]
    update.message.reply_text("Download canceled and removed.")

# Function to delete a downloaded torrent
def delete(update, context):
    message = update.message.text

    if len(message.split(" ")) < 2:
        update.message.reply_text("Please provide the name of the torrent to delete.")
        return

    torrent_name = message.split(" ")[1]

    try:
        os.remove(os.path.join(DOWNLOAD_PATH, torrent_name))
        update.message.reply_text(f"Torrent '{torrent_name}' deleted successfully.")
    except Exception as e:
        update.message.reply_text(f"Failed to delete torrent: {e}")

# Function to handle any other messages
def echo(update, context):
    context.bot.send_message(
        chat_id=update.effective_chat.id, text="Sorry, I don't understand that command."
    )

# Main function to run the Telegram bot
def main():
    # Create an instance of the Updater class
    updater = Updater(TOKEN, use_context=True)

    # Get the dispatcher to register handlers
    dispatcher = updater.dispatcher

    # Register the handlers
    dispatcher.add_handler(CommandHandler("start", start))
    dispatcher.add_handler(CommandHandler("download", download_torrent))
    dispatcher.add_handler(CommandHandler("progress", progress))
    dispatcher.add_handler(CommandHandler("list", list_torrents))
    dispatcher.add_handler(CommandHandler("pause", pause))
    dispatcher.add_handler(CommandHandler("resume", resume))
    dispatcher.add_handler(CommandHandler("cancel", cancel))
    dispatcher.add_handler(CommandHandler("delete", delete))
    dispatcher.add_handler(MessageHandler(Filters.text & (~Filters.command), echo))

    # Start the bot
    updater.start_polling()

    # Run the bot until Ctrl+C is pressed
    updater.idle()

if __name__ == "__main__":
    main()

Telegram-Torrent-Bot/bot.py
anupammaurya6767/Botzy
# Import the necessary libraries
from twilio.rest import Client
from flask import Flask, request, redirect
from twilio.twiml.messaging_response import MessagingResponse

# Set up your Twilio account credentials
account_sid = 'your_account_sid'
auth_token = 'your_auth_token'
client = Client(account_sid, auth_token)

# Create a Flask web application
app = Flask(__name__)

# Define a dictionary to store poll questions and options
polls = {}

# Define a function to send poll questions to users
def send_poll_question(to, question, options):
    message_body = f"{question}\nOptions: {', '.join(options)}"
    client.messages.create(body=message_body, from_='your_twilio_number', to=to)

# Handle incoming WhatsApp messages
@app.route('/webhook', methods=['POST'])
def webhook():
    from_number = request.values.get('From', None)
    body = request.values.get('Body', None)

    if body.lower() == 'start':
        # Start a new poll
        polls[from_number] = {'question': '', 'options': []}
        return str(MessagingResponse().message("Enter your poll question:"))
    elif from_number in polls:
        if not polls[from_number]['question']:
            # Store the poll question
            polls[from_number]['question'] = body
            return str(MessagingResponse().message("Enter poll options (comma-separated):"))
        else:
            # Store poll options
            options = body.split(',')
            polls[from_number]['options'] = [option.strip() for option in options]

            # Send the poll question and options
            send_poll_question(from_number, polls[from_number]['question'], polls[from_number]['options'])

            # Clear the poll data
            del polls[from_number]

    return str(MessagingResponse().message("Invalid command. Send 'start' to create a new poll."))

if __name__ == '__main__':
    app.run(debug=True)

Whatsapp-bot/WhatsApp-Poll-Bot/poll.py
anupammaurya6767/Botzy
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
import time
from bs4 import BeautifulSoup

def get_contact_info(driver, person):
    try:
        # XPath for the search input field
        inp_xpath_search = "//p[@class='selectable-text copyable-text iq0m558w g0rxnol2']"
        search_input = driver.find_element(By.XPATH, inp_xpath_search)

        # Set the value and trigger events
        search_input.clear()
        search_input.send_keys(person)
        search_input.send_keys(Keys.RETURN)
        time.sleep(5)

        # Click on the user profile
        profile = driver.find_element(By.XPATH, "//div[@class='_2au8k']")
        profile.click()
        time.sleep(10)

        # Get the page source and parse it using BeautifulSoup
        html = driver.page_source
        soup = BeautifulSoup(html, "html.parser")

        # Find the container element
        container = soup.find("div", {"class": "lhggkp7q qq0sjtgm ebjesfe0 jxacihee tkdu00h0"})

        # Find and print the user's name
        name = container.find("h2")
        print("User's Name:", name.text)

        # Find and print the user's number
        number = container.find("div", {"class": "a4ywakfo qt60bha0"})
        print("User's Number:", number.text)

        # Find and print the top groups the user is in, if any
        groups = container.find("div", {"class": "_3YS_f _2A1R8"})
        if groups:
            print("Top Groups:")
            group = []
            for items in groups:
                group.append(items.find("div", {"class": "y_sn4"}).text)
            print(group)
        else:
            print("No groups in common")

        # Find and print any common interests or details
        about = container.find("span", {"class": "cw3vfol9 _11JPr selectable-text copyable-text"})
        if about:
            print("About:", about.text)
        else:
            print("No About")

    except Exception as e:
        print("Exception Occurred:", e)

def main():
    try:
        # Initialize the Chrome WebDriver
        driver = webdriver.Chrome()

        # Open the WhatsApp Web URL
        driver.get("https://web.whatsapp.com/")

        # Prompt the user to scan the QR code manually
        print("Scan QR Code")

        # Wait for the user to scan the QR code manually for 60 seconds
        time.sleep(60)

        print("Enter name of person")
        person = input()
        time.sleep(2)

        get_contact_info(driver, person)

    except Exception as e:
        print("Exception Occurred:", e)
    finally:
        # Close the WebDriver
        driver.quit()

if __name__ == "__main__":
    main()

Whatsapp-bot/WhatsApp-Profile-Info-bot/profile.py
anupammaurya6767/Botzy
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.common.exceptions import NoSuchElementException
import time

def main():
    try:
        # Initialize the WebDriver
        driver = webdriver.Chrome()

        # Open WhatsApp Web
        driver.get("https://web.whatsapp.com/")

        # Wait for the user to scan the QR code manually for 10 seconds
        input("Scan the QR code manually and press Enter after scanning...")

        # Find the group name element
        group_name = find_element_with_retry(
            driver, "//span[@title='Group Name']"
        )  # Replace 'Group Name' with the name of the group you want to tag

        if group_name:
            group_name.click()

            # Find the message box
            message_box = find_element_with_retry(
                driver, "//div[@class='_2S1VP copyable-text selectable-text']"
            )

            if message_box:
                message_box.click()

                # Type the message
                message_box.send_keys("@everyone")

                # Send the message
                send_button = find_element_with_retry(
                    driver, "//button[@class='_35EW6']"
                )

                if send_button:
                    send_button.click()
                    print("Message sent successfully.")
                else:
                    print("Send button not found.")
            else:
                print("Message box not found.")
        else:
            print("Group not found.")

    except Exception as e:
        print("An error occurred:", str(e))
    finally:
        # Close the browser
        driver.quit()

def find_element_with_retry(driver, xpath, max_attempts=3):
    attempts = 0
    while attempts < max_attempts:
        try:
            element = driver.find_element_by_xpath(xpath)
            return element
        except NoSuchElementException:
            attempts += 1
            time.sleep(2)  # Wait for 2 seconds before retrying
    return None

if __name__ == "__main__":
    main()

Whatsapp-bot/WhatsApp-Tag-all-bot/tagll.py
anupammaurya6767/Botzy
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
import time
from bs4 import BeautifulSoup

def get_contact_info(driver, person):
    try:
        # Wait for the user to scan the QR code manually for 60 seconds
        input("Scan the QR code manually and press Enter after scanning...")

        # XPath for the search input field
        inp_xpath_search = "//p[@class='selectable-text copyable-text iq0m558w g0rxnol2']"
        search_input = driver.find_element(By.XPATH, inp_xpath_search)

        # Set the value and trigger events
        search_input.clear()
        search_input.send_keys(person)
        search_input.send_keys(Keys.RETURN)
        time.sleep(5)

        # Click on the user profile
        profile = driver.find_element(By.XPATH, "//div[@class='_2au8k']")
        profile.click()
        time.sleep(10)

        # Get the page source and parse it using BeautifulSoup
        html = driver.page_source
        soup = BeautifulSoup(html, "html.parser")

        # Find the container element
        container = soup.find("div", {"class": "lhggkp7q qq0sjtgm ebjesfe0 jxacihee tkdu00h0"})

        # Find and print the user's name
        name = container.find("h2")
        if name:
            print("User's Name:", name.text)
        else:
            print("User's Name not found.")

        # Find and print the user's number
        number = container.find("div", {"class": "a4ywakfo qt60bha0"})
        if number:
            print("User's Number:", number.text)
        else:
            print("User's Number not found.")

        # Find and print the top groups the user is in, if any
        groups = container.find("div", {"class": "_3YS_f _2A1R8"})
        if groups:
            print("Top Groups:")
            group = [item.text for item in groups.find_all("div", {"class": "y_sn4"})]
            print(group)
        else:
            print("No groups in common.")

        # Find and print any common interests or details
        about = container.find("span", {"class": "cw3vfol9 _11JPr selectable-text copyable-text"})
        if about:
            print("About:", about.text)
        else:
            print("About not found.")

    except Exception as e:
        print("Exception Occurred:", str(e))

def main():
    try:
        # Initialize the Chrome WebDriver
        driver = webdriver.Chrome()

        # Open the WhatsApp Web URL
        driver.get("https://web.whatsapp.com/")

        print("Enter name of person")
        person = input()
        time.sleep(2)

        get_contact_info(driver, person)

    except Exception as e:
        print("Exception Occurred:", str(e))
    finally:
        # Close the WebDriver
        driver.quit()

if __name__ == "__main__":
    main()

Whatsapp-bot/WhatsApp-image-bot/image-bot.py
anupammaurya6767/Botzy