Skip to content

Instantly share code, notes, and snippets.

View AmirSbss's full-sized avatar
♾️

Amirh. Safavi AmirSbss

♾️
View GitHub Profile
@AmirSbss
AmirSbss / validator.py
Last active August 31, 2020 14:46
Telegram MTProxy link validator
from urllib import parse
import string
import base64
import traceback
def validate(proxy_link):
try:
if proxy_link.startswith("tg://proxy") or proxy_link.replace("https://", "").startswith("t.me/proxy"):
args = dict(parse.parse_qsl(parse.urlsplit(proxy_link).query))
if args.get("server") and args.get("port") and args.get("secret"):
@AmirSbss
AmirSbss / idpay.py
Created September 15, 2019 15:17
IDPay API interface for Python
import requests
import json
# DOCS: https://idpay.ir/web-service/v1.1/index.html
class IDPay:
API_URL = "https://api.idpay.ir/v1.1/payment"
@AmirSbss
AmirSbss / example.py
Last active March 25, 2023 05:37
FFMpeg tools in python with progress callback
from ffmpeg import *
def progress(duration, time, process_name):
print(f"{time} from {duration} seconds is fixed, Process name: {process_name}")
def streamable(input_file, output_file):
args = ['-movflags', 'faststart', '-strict', '-2']
return ffmpeg(input_file, output_file, args, progress, ["Test Progress!"])
# You can run this in a thread
streamable("input.mp4", "output.mp4")
@AmirSbss
AmirSbss / asyncApiRequest.php
Last active October 20, 2022 16:28
Request to telegram API asynchronous from php (2 times faster than normal request)
<?php
/**
* Created by PhpStorm.
* User: amirsbss
* Date: 11/3/18
* Time: 1:08 AM
*/
define('BOT_TOKEN', 'TOKEN');
define('API_URL', 'https://api.telegram.org/bot'.BOT_TOKEN.'/');
function multipartFormData($data=[], $files=[])
@AmirSbss
AmirSbss / proxies.py
Created June 9, 2018 22:01
Hotgram free Socks5 proxies, 10 different servers, Python3
import urllib.request
import json
import base64
from Crypto.Cipher import AES as _AES
import random
class AES(object):
def __init__(self, key="KCH@LQj#>6VCqqLg", iv="YC'2bmK=b%#NQ?9j"):
self.bs = 16
self.cipher = _AES.new(key, _AES.MODE_CBC, iv)
@AmirSbss
AmirSbss / Encr.php
Last active May 4, 2018 07:46
PHP encryption method
<?php
/**
* @property string
*/
function encr($raw) {
$encoded = "";
$seprated = str_split(base64_encode($raw));
$empty = [];
while (count($seprated) > 0) {
@AmirSbss
AmirSbss / redis.py
Last active June 1, 2022 19:21
Use redis document-oriented!
import string
import random
import pickle
from redis import StrictRedis
def random_id(lenght=8, letters=string.ascii_letters + string.digits):
return "".join(random.choice(letters) for _ in range(lenght))
@AmirSbss
AmirSbss / antispam.py
Last active May 30, 2023 16:33
Cached anti spam system for telegram bots written in python
import time as tm
spams = {}
msgs = 4 # Messages in
max = 5 # Seconds
ban = 300 # Seconds
def is_spam(user_id):
try:
usr = spams[user_id]
usr["messages"] += 1