Skip to content

Instantly share code, notes, and snippets.

View painor's full-sized avatar

painor painor

  • TopCode Softwares
  • Tunisia
View GitHub Profile
@painor
painor / FastTelethon.py
Last active April 2, 2024 07:40
This will increase the download/upload speed when using telethon
# copied from https://github.com/tulir/mautrix-telegram/blob/master/mautrix_telegram/util/parallel_file_transfer.py
# Copyright (C) 2021 Tulir Asokan
import asyncio
import hashlib
import inspect
import logging
import math
import os
from collections import defaultdict
from typing import Optional, List, AsyncGenerator, Union, Awaitable, DefaultDict, Tuple, BinaryIO
@painor
painor / README.MD
Last active March 26, 2024 04:50
Convert TDesktop tdata folders to GramJS sessions.

tdata converter

Converts tdata folder to a GramJS session for usage in a userbot.

Usage

Usage is simple. the main() function accepts a folder path (absolute or relative) and will return and print the session string if it found one.

Limitation

@painor
painor / README.md
Last active March 21, 2024 19:41
Trivia bot telethon

Trivia bot

A small trivia bot made for my yotube tutorial

If anything wasn't clear you can PM me at @painor

بوت بسيط تم صنعه من اجل فيديو اليوتيب التعليمي

اذا كان شيء غير واضح يمكنك التواصل معي في التلغرام على المعرف التالي @painor

@painor
painor / unmarshal.py
Last active October 14, 2023 11:04
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
@painor
painor / call.py
Created February 2, 2019 00:55
Make a call using pyrogram
#This is taken from https://github.com/LonamiWebs/Telethon-calls/blob/master/calls.py and modified
import hashlib
import os
import random
from pyrogram import Client
from pyrogram.api.functions.messages import GetDhConfig
from pyrogram.api.functions.phone import RequestCall
from pyrogram.api.types import PhoneCallProtocol
@painor
painor / README.MD
Last active August 28, 2022 21:59
import GramJS session into Telethon

Import GramJS session into Telethon

Requirements

GramJS version 2.X+

Telethon version 1.X+

This will print out python code that you can use to use the same session in telethon.

@painor
painor / call.ts
Created February 9, 2022 21:41
Make a call in telegram using GramJS
import { StoreSession} from "telegram/sessions";
import { TelegramClient } from "telegram/client/TelegramClient";
import { Api } from "./tl";
import { generateRandomBigInt, readBigIntFromBuffer, readBufferFromBigInt, sha256 } from "telegram/Helpers";
import bigInt from "big-integer";
const apiId = ;
from time import sleep
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.wait import WebDriverWait
driver = webdriver.Chrome()
driver.get("https://humanbenchmark.com/tests/reactiontime")
input("ready ?")
@painor
painor / contact.php
Created January 1, 2021 16:09
Small php contact to telegram script
<?php
function get_client_ip()
{
$ipaddress = '';
if (isset($_SERVER['HTTP_CLIENT_IP'])) $ipaddress = $_SERVER['HTTP_CLIENT_IP'];
else if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) $ipaddress = $_SERVER['HTTP_X_FORWARDED_FOR'];
else if (isset($_SERVER['HTTP_X_FORWARDED'])) $ipaddress = $_SERVER['HTTP_X_FORWARDED'];
else if (isset($_SERVER['HTTP_FORWARDED_FOR'])) $ipaddress = $_SERVER['HTTP_FORWARDED_FOR'];
else if (isset($_SERVER['HTTP_FORWARDED'])) $ipaddress = $_SERVER['HTTP_FORWARDED'];
else if (isset($_SERVER['REMOTE_ADDR'])) $ipaddress = $_SERVER['REMOTE_ADDR'];
@painor
painor / TrashGuy_plotter.py
Created December 10, 2020 13:51
A small helper script to plot timeit results
import matplotlib.pyplot as plt
from timeit import timeit
time_taken = []
number_elements = [*range(15)]
for x in range(1, 16):
string = 'a' * x
best = timeit("for _ in TrashGuy(inp): pass", setup=f"from trashguy import TrashGuy;inp='{string}'", number=1000)
time_taken.append(best)
plt.plot(time_taken, number_elements, color='g', marker='o')