Skip to content

Instantly share code, notes, and snippets.

View x0x8x's full-sized avatar
🏠
Working from home

x0x8x x0x8x

🏠
Working from home
View GitHub Profile
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",
@CustomIcon
CustomIcon / 1.md
Last active July 23, 2023 17:52 — forked from ColinShark/1.md
start(), idle() and stop() multiple Pyrogram Clients at once.

UPDATED

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.

@idealhack
idealhack / clean-telegram-chat.sh
Last active March 9, 2020 11:12
telegram-chat-cleaner
# 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
@ronik56
ronik56 / leave_all_telegram_groups.py
Last active October 10, 2024 04:10
script to leave all telegram groups
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()
@Poolitzer
Poolitzer / bot.py
Created January 31, 2020 05:53
Ever wanted to download something and send it via telegram without having to save it to a file? Fear not!
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
@Poolitzer
Poolitzer / bot.py
Created December 8, 2019 08:13
no
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):
@ColinShark
ColinShark / 1.md
Last active December 25, 2021 08:51
start(), idle() and stop() multiple Pyrogram Clients at once.

OUTDATED

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.

Update

@Pokurt has updated these scripts to Pyrogram v1

@painor
painor / unmarshal.py
Last active March 8, 2025 12:38
unmarshal python code object string. python2
import marshal
a = marshal.loads("your marshal string data that is a code object here")
import py_compile
import time
import uncompyle6
@Poolitzer
Poolitzer / bot.py
Created October 21, 2019 18:03
An example of how to download bigger files via telethon, coming from ptb
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()
@behf
behf / split.py
Last active May 14, 2020 14:59
split a long text into small chunks, it won't cut your words.
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