Updated to Pyrogram v1.
If you know what you're doing, feel free to use these as a guide.
For any questions, head to @PyrogramLounge.
| from dataclasses import dataclass | |
| from typing import Any, Dict, List, Optional, Union | |
| import sys | |
| from pyrogram.filters import Filter, create | |
| from pyrogram.types import Message, MessageEntity | |
| from typing_extensions import Literal | |
| MessageEntityType = Literal[ | |
| "mention", |
Updated to Pyrogram v1.
If you know what you're doing, feel free to use these as a guide.
For any questions, head to @PyrogramLounge.
| # create a telegram application at https://my.telegram.org/apps | |
| TELEGRAM_CHAT_NAME="" \ | |
| TELEGRAM_CLEAN_DELTA_DAYS="" \ | |
| TELEGRAM_API_ID="" \ | |
| TELEGRAM_API_NAME="" \ | |
| TELEGRAM_API_HASH="" \ | |
| python3 telegram-chat-cleaner.py |
| from telethon.sync import TelegramClient | |
| from telethon.tl.functions.messages import GetDialogsRequest | |
| from telethon.tl.types import InputPeerEmpty | |
| # Go to https://my.telegram.org/apps, sign in, go to API development tools, create an app, copy and paste below: | |
| api_id = 111111 | |
| api_hash = '2o23o13k1o3131' | |
| phone = '+123456789' | |
| client = TelegramClient(phone, api_id, api_hash) | |
| client.connect() |
| import io | |
| def downloader(bot, url, timeout=None): | |
| # if you receive a timeout error, pass an increasing timeout until you don't | |
| buf = bot.request.retrieve(url, timeout=timeout) | |
| # turning the byte stream into a file_like object without actually writing it to a file | |
| file_like = io.BytesIO(buf) | |
| # and returning it | |
| return file_like |
| import logging | |
| from telegram import InlineKeyboardButton, InlineKeyboardMarkup | |
| from telegram.ext import Updater, CommandHandler, CallbackQueryHandler | |
| logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', | |
| level=logging.INFO) | |
| def start_command(update, context): |
These are outdated as they haven't been updated for Pyrogram v1.
If you know what you're doing, feel free to use these as a guide.
For any questions, head to @PyrogramLounge.
@Pokurt has updated these scripts to Pyrogram v1
| import marshal | |
| a = marshal.loads("your marshal string data that is a code object here") | |
| import py_compile | |
| import time | |
| import uncompyle6 |
| import asyncio | |
| from telegram.ext import Updater, MessageHandler, Filters | |
| from telethon.utils import resolve_bot_file_id, get_input_location | |
| from telethon import TelegramClient | |
| import logging | |
| logging.basicConfig() |
| def split_message(text, length=4096, offset=200): | |
| return [text[text.find('\n', i - offset, i + 1) if text.find('\n', i - offset, i + 1) != -1 else i: | |
| text.find('\n', i + length - offset, i + length) if text.find('\n', i + length - offset, | |
| i + length) != -1 else i + length] for | |
| i | |
| in | |
| range(0, len(text), length)] | |
| # Usage, Using Pyrogram |